refactor
This commit is contained in:
parent
e5a619b167
commit
6a0ade1194
|
@ -68,25 +68,11 @@ module GitHubChangelogGenerator
|
||||||
response = @github.repos.tags @options[:user], @options[:project]
|
response = @github.repos.tags @options[:user], @options[:project]
|
||||||
page_i = 0
|
page_i = 0
|
||||||
count_pages = response.count_pages
|
count_pages = response.count_pages
|
||||||
|
|
||||||
response.each_page do |page|
|
response.each_page do |page|
|
||||||
|
|
||||||
if @options[:exclude_tags_filter]
|
|
||||||
body_new = []
|
|
||||||
reg = Regexp.new @options[:exclude_tags_filter]
|
|
||||||
page.body.each do |tag|
|
|
||||||
if !(tag.name =~ reg)
|
|
||||||
body_new << tag
|
|
||||||
end
|
|
||||||
end
|
|
||||||
page.body = body_new
|
|
||||||
end
|
|
||||||
|
|
||||||
page_i += PER_PAGE_NUMBER
|
page_i += PER_PAGE_NUMBER
|
||||||
print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
|
print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
|
||||||
tags.concat(page)
|
tags.concat(page)
|
||||||
end
|
end
|
||||||
|
|
||||||
print_empty_line
|
print_empty_line
|
||||||
|
|
||||||
if tags.count == 0
|
if tags.count == 0
|
||||||
|
|
|
@ -129,12 +129,12 @@ module GitHubChangelogGenerator
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param [Array] all_tags all tags
|
# @param [Array] all_tags all tags
|
||||||
# @return [Array] filtered tags according :exclude_tags option
|
# @return [Array] filtered tags according :exclude_tags or :exclude_tags_regex option
|
||||||
def filter_excluded_tags(all_tags)
|
def filter_excluded_tags(all_tags)
|
||||||
if @options[:exclude_tags]
|
if (@options[:exclude_tags].is_a?(Regexp) || @options[:exclude_tags_regex])
|
||||||
apply_exclude_tags(all_tags)
|
filter_tags_with_regex(all_tags)
|
||||||
elsif @options[:exclude_tags_regex]
|
elsif @options[:exclude_tags]
|
||||||
apply_exclude_tags_regex(all_tags)
|
filter_exact_tags(all_tags)
|
||||||
else
|
else
|
||||||
all_tags
|
all_tags
|
||||||
end
|
end
|
||||||
|
@ -142,18 +142,6 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def apply_exclude_tags(all_tags)
|
|
||||||
if @options[:exclude_tags].is_a?(Regexp)
|
|
||||||
filter_tags_with_regex(all_tags)
|
|
||||||
else
|
|
||||||
filter_exact_tags(all_tags)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def apply_exclude_tags_regex(all_tags)
|
|
||||||
filter_tags_with_regex(all_tags)
|
|
||||||
end
|
|
||||||
|
|
||||||
def filter_tags_with_regex(all_tags)
|
def filter_tags_with_regex(all_tags)
|
||||||
warn_if_nonmatching_regex(all_tags)
|
warn_if_nonmatching_regex(all_tags)
|
||||||
|
|
||||||
|
|
|
@ -116,12 +116,12 @@ module GitHubChangelogGenerator
|
||||||
opts.on("--between-tags x,y,z", Array, "Change log will be filled 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
|
options[:between_tags] = list
|
||||||
end
|
end
|
||||||
opts.on("--exclude-tags-filter [REGEX]", "Apply a regular expression on tag names so that they can be excluded, for example: --exclude-tags-filter \".*\+\d{1,}\" ") do |last|
|
|
||||||
options[:exclude_tags_filter] = last
|
|
||||||
end
|
|
||||||
opts.on("--exclude-tags x,y,z", Array, "Change log will exclude specified tags") do |list|
|
opts.on("--exclude-tags x,y,z", Array, "Change log will exclude specified tags") do |list|
|
||||||
options[:exclude_tags] = list
|
options[:exclude_tags] = list
|
||||||
end
|
end
|
||||||
|
opts.on("--exclude-tags-regex [REGEX]", "Apply a regular expression on tag names so that they can be excluded, for example: --exclude-tags-regex \".*\+\d{1,}\" ") do |last|
|
||||||
|
options[:exclude_tags_regex] = last
|
||||||
|
end
|
||||||
opts.on("--since-tag x", "Change log will start after specified tag") do |v|
|
opts.on("--since-tag x", "Change log will start after specified tag") do |v|
|
||||||
options[:since_tag] = v
|
options[:since_tag] = v
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user