parent
0190d417c2
commit
32f4df5742
|
@ -56,10 +56,29 @@ module GitHubChangelogGenerator
|
||||||
#
|
#
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
def get_filtered_tags(all_tags)
|
def get_filtered_tags(all_tags)
|
||||||
filtered_tags = filter_between_tags(all_tags)
|
filtered_tags = filter_since_tag(all_tags)
|
||||||
|
filtered_tags = filter_between_tags(filtered_tags)
|
||||||
filter_excluded_tags(filtered_tags)
|
filter_excluded_tags(filtered_tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filter_since_tag(all_tags)
|
||||||
|
filtered_tags = all_tags
|
||||||
|
tag = @options[:since_tag]
|
||||||
|
if tag
|
||||||
|
if all_tags.map(&:name).include? tag
|
||||||
|
idx = all_tags.index { |t| t.name == tag }
|
||||||
|
if idx > 0
|
||||||
|
filtered_tags = all_tags[0..idx - 1]
|
||||||
|
else
|
||||||
|
filtered_tags = []
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Helper.log.warn "Warning: can't find tag #{tag}, specified with --since-tag option."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
filtered_tags
|
||||||
|
end
|
||||||
|
|
||||||
def filter_between_tags(all_tags)
|
def filter_between_tags(all_tags)
|
||||||
filtered_tags = all_tags
|
filtered_tags = all_tags
|
||||||
if @options[:between_tags]
|
if @options[:between_tags]
|
||||||
|
|
|
@ -113,6 +113,9 @@ module GitHubChangelogGenerator
|
||||||
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("--since-tag x", "Change log will start after specified tag") do |v|
|
||||||
|
options[:since_tag] = v
|
||||||
|
end
|
||||||
opts.on("--max-issues [NUMBER]", Integer, "Max number of issues to fetch from GitHub. Default is unlimited") do |max|
|
opts.on("--max-issues [NUMBER]", Integer, "Max number of issues to fetch from GitHub. Default is unlimited") do |max|
|
||||||
options[:max_issues] = max
|
options[:max_issues] = max
|
||||||
end
|
end
|
||||||
|
|
|
@ -89,6 +89,22 @@ describe GitHubChangelogGenerator::Generator do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#filter_since_tag" do
|
||||||
|
subject { generator.filter_since_tag(tags_mash_from_strings(%w(1 2 3))) }
|
||||||
|
|
||||||
|
context "with valid since tag" do
|
||||||
|
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
|
||||||
|
it { is_expected.to be_a Array }
|
||||||
|
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with invalid since tag" do
|
||||||
|
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: %w(invalid tags)) }
|
||||||
|
it { is_expected.to be_a Array }
|
||||||
|
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#get_time_of_tag" do
|
describe "#get_time_of_tag" do
|
||||||
current_time = Time.now
|
current_time = Time.now
|
||||||
before(:all) { @generator = GitHubChangelogGenerator::Generator.new }
|
before(:all) { @generator = GitHubChangelogGenerator::Generator.new }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user