Resolved #214. Added tests for this case. small refacroting

This commit is contained in:
Petr Korolev
2015-05-26 16:01:23 +03:00
parent 957fa0d3a3
commit 783d8f306e
5 changed files with 54 additions and 15 deletions
@@ -37,7 +37,11 @@ module GitHubChangelogGenerator
#
# @return [Array]
def get_filtered_tags(all_tags)
all_tags = all_tags
filtered_tags = filter_between_tags(all_tags)
filter_excluded_tags(filtered_tags)
end
def filter_between_tags(all_tags)
filtered_tags = all_tags
if @options[:between_tags]
@options[:between_tags].each do |tag|
@@ -49,5 +53,18 @@ module GitHubChangelogGenerator
end
filtered_tags
end
def filter_excluded_tags(all_tags)
filtered_tags = all_tags
if @options[:exclude_tags]
@options[:exclude_tags].each do |tag|
unless all_tags.include? tag
puts "Warning: can't find tag #{tag}, specified with --between-tags option.".yellow
end
end
filtered_tags = all_tags.reject { |tag| @options[:exclude_tags].include? tag }
end
filtered_tags
end
end
end
+4 -1
View File
@@ -84,9 +84,12 @@ module GitHubChangelogGenerator
opts.on("--exclude-labels x,y,z", Array, 'Issues with the specified labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list|
options[:exclude_labels] = list
end
opts.on("--between-tags x,y,z", Array, "Change log will be filed only between specified tags") do |list|
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("--exclude-tags x,y,z", Array, "Change log will be exclude specified tags") do |list|
options[:exclude_tags] = list
end
opts.on("--max-issues [NUMBER]", Integer, "Max number of issues to fetch from GitHub. Default is unlimited") do |max|
options[:max_issues] = max
end