From 40dec5346b46fb96a4078910ddea300714e0b091 Mon Sep 17 00:00:00 2001 From: soundstep Date: Fri, 22 Jan 2016 13:32:31 +0000 Subject: [PATCH] filter-tags - Added capability to exclude tags with a regular expression by filtering names. --- lib/github_changelog_generator/fetcher.rb | 14 ++++++++++++++ lib/github_changelog_generator/parser.rb | 3 +++ 2 files changed, 17 insertions(+) diff --git a/lib/github_changelog_generator/fetcher.rb b/lib/github_changelog_generator/fetcher.rb index eef3e6d..1a6d61c 100644 --- a/lib/github_changelog_generator/fetcher.rb +++ b/lib/github_changelog_generator/fetcher.rb @@ -68,11 +68,25 @@ module GitHubChangelogGenerator response = @github.repos.tags @options[:user], @options[:project] page_i = 0 count_pages = response.count_pages + response.each_page do |page| + + if @options[:filter_tags] + body_new = [] + reg = Regexp.new @options[:filter_tags] + page.body.each_with_index do |tag,index| + if !(tag.name =~ reg) + body_new << tag + end + end + page.body = body_new + end + page_i += PER_PAGE_NUMBER print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}") tags.concat(page) end + print_empty_line if tags.count == 0 diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 2f16d9b..4c79889 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -116,6 +116,9 @@ module GitHubChangelogGenerator opts.on("--between-tags x,y,z", Array, "Change log will be filled only between specified tags") do |list| options[:between_tags] = list end + opts.on("--filter-tags [REGEX]", "Apply a regular expression on tag names so that they can be excluded, for example: --filter-tags \".*\+\d{1,}\" ") do |last| + options[:filter_tags] = last + end opts.on("--exclude-tags x,y,z", Array, "Change log will exclude specified tags") do |list| options[:exclude_tags] = list end