diff --git a/lib/github_changelog_generator/generator/generator_tags.rb b/lib/github_changelog_generator/generator/generator_tags.rb index 499edb9..d8f4534 100644 --- a/lib/github_changelog_generator/generator/generator_tags.rb +++ b/lib/github_changelog_generator/generator/generator_tags.rb @@ -129,7 +129,7 @@ module GitHubChangelogGenerator if tag if all_tags.map { |t| t["name"] }.include? tag idx = all_tags.index { |t| t["name"] == tag } - filtered_tags = if idx > 0 + filtered_tags = if idx all_tags[0..idx] else [] diff --git a/spec/unit/generator/generator_tags_spec.rb b/spec/unit/generator/generator_tags_spec.rb index 51fffe1..d9dc6b4 100644 --- a/spec/unit/generator/generator_tags_spec.rb +++ b/spec/unit/generator/generator_tags_spec.rb @@ -182,6 +182,11 @@ describe GitHubChangelogGenerator::Generator do let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") } it { is_expected.to be_a Array } it { is_expected.to match_array(tags_from_strings(%w[1 2])) } + + context "with since tag set to the most recent tag" do + let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "1") } + it { is_expected.to match_array(tags_from_strings(%w[1])) } + end end context "with invalid since tag" do