diff --git a/lib/github_changelog_generator/generator/generator_tags.rb b/lib/github_changelog_generator/generator/generator_tags.rb index 01480b575..039435492 100644 --- a/lib/github_changelog_generator/generator/generator_tags.rb +++ b/lib/github_changelog_generator/generator/generator_tags.rb @@ -95,13 +95,12 @@ def version_of_first_item sections.first["version"] if sections && sections.any? end - # Return tags after filtering tags in lists provided by option: --between-tags & --exclude-tags + # Return tags after filtering tags in lists provided by option: --exclude-tags # # @return [Array] def get_filtered_tags(all_tags) filtered_tags = filter_since_tag(all_tags) - filtered_tags = filter_due_tag(filtered_tags) - filter_between_tags(filtered_tags) + filter_due_tag(filtered_tags) end # @param [Array] all_tags all tags @@ -144,23 +143,6 @@ def filter_due_tag(all_tags) filtered_tags end - # @param [Array] all_tags all tags - # @return [Array] filtered tags according :between_tags option - def filter_between_tags(all_tags) - filtered_tags = all_tags - tag_names = filtered_tags.map { |ft| ft["name"] } - - if options[:between_tags] - options[:between_tags].each do |tag| - unless tag_names.include?(tag) - Helper.log.warn "Warning: can't find tag #{tag}, specified with --between-tags option." - end - end - filtered_tags = all_tags.select { |tag| options[:between_tags].include?(tag["name"]) } - end - filtered_tags - end - # @param [Array] all_tags all tags # @return [Array] filtered tags according :exclude_tags or :exclude_tags_regex option def filter_excluded_tags(all_tags) diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index e3a1ab5e8..3e42bfbf9 100755 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -131,9 +131,6 @@ def self.setup_parser(options) opts.on("--issue-line-labels x,y,z", Array, 'The specified labels will be shown in brackets next to each matching issue. Use "ALL" to show all labels. Default is [].') do |list| options[:issue_line_labels] = list end - 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 exclude specified tags") do |list| options[:exclude_tags] = list end diff --git a/man/git-generate-changelog.1.html b/man/git-generate-changelog.1.html index ad35a9224..fda1bc383 100644 --- a/man/git-generate-changelog.1.html +++ b/man/git-generate-changelog.1.html @@ -192,10 +192,6 @@
Issues with the specified labels will be always added to "Implemented enhancements" section. Default is 'enhancement,Enhancement'
---between-tags x,y,z
- -Change log will be filled only between specified tags
---exclude-tags x,y,z
Change log will exclude specified tags
diff --git a/man/git-generate-changelog.html b/man/git-generate-changelog.html index be231c44b..3b67983b1 100644 --- a/man/git-generate-changelog.html +++ b/man/git-generate-changelog.html @@ -184,10 +184,6 @@Issues with the specified labels will be always added to "Implemented enhancements" section. Default is 'enhancement,Enhancement'
---between-tags x,y,z
- -Change log will be filled only between specified tags
---exclude-tags x,y,z
Change log will exclude specified tags
diff --git a/man/git-generate-changelog.md b/man/git-generate-changelog.md index 6a77531da..a6aa166e2 100644 --- a/man/git-generate-changelog.md +++ b/man/git-generate-changelog.md @@ -119,10 +119,6 @@ Automatically generate change log from your tags, issues, labels and pull reques Issues with the specified labels will be always added to "Implemented enhancements" section. Default is 'enhancement,Enhancement' - --between-tags x,y,z - - Change log will be filled only between specified tags - --exclude-tags x,y,z Change log will exclude specified tags diff --git a/spec/unit/generator/generator_tags_spec.rb b/spec/unit/generator/generator_tags_spec.rb index 64dab2427..9b3a93499 100644 --- a/spec/unit/generator/generator_tags_spec.rb +++ b/spec/unit/generator/generator_tags_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + describe GitHubChangelogGenerator::Generator do def tag_with_name(tag) { @@ -12,174 +13,114 @@ def tags_from_strings(tags_strings) end end - describe "#filter_between_tags" do - context "when between_tags nil" do - before do - @generator = GitHubChangelogGenerator::Generator.new(between_tags: nil) - end - - subject do - @generator.get_filtered_tags(tags_from_strings(%w(1 2 3))) - end - it { is_expected.to be_a(Array) } - it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) } - end - context "when between_tags same as input array" do - before do - @generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3)) - end - subject do - @generator.get_filtered_tags(tags_from_strings(%w(1 2 3))) - end - it { is_expected.to be_a(Array) } - it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) } - end - - context "when between_tags filled with correct values" do - before do - @generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2)) - end - subject do - @generator.get_filtered_tags(tags_from_strings(%w(1 2 3))) - end - it { is_expected.to be_a(Array) } - it { is_expected.to match_array(tags_from_strings(%w(1 2))) } - end - - context "when between_tags filled with invalid values" do - before do - @generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 q w)) - end - - subject do - @generator.get_filtered_tags(tags_from_strings(%w(1 2 3))) - end - it { is_expected.to be_a(Array) } - it { is_expected.to match_array(tags_from_strings(%w(1))) } - end - end - - describe "#get_filtered_tags" do - subject do - generator.get_filtered_tags(tags_from_strings(%w(1 2 3 4 5))) - end - - context "respects between tags" do - let(:generator) { GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3)) } - - it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) } - end - end - describe "#filter_excluded_tags" do - subject { generator.filter_excluded_tags(tags_from_strings(%w(1 2 3))) } + subject { generator.filter_excluded_tags(tags_from_strings(%w[1 2 3])) } context "with matching string" do - let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(3)) } + let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w[3]) } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(1 2))) } + it { is_expected.to match_array(tags_from_strings(%w[1 2])) } end context "with non-matching string" do - let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(invalid tags)) } + let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w[invalid tags]) } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) } + it { is_expected.to match_array(tags_from_strings(%w[1 2 3])) } end context "with matching regex" do let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[23]/) } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(1))) } + it { is_expected.to match_array(tags_from_strings(%w[1])) } end context "with non-matching regex" do let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[abc]/) } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) } + it { is_expected.to match_array(tags_from_strings(%w[1 2 3])) } end end describe "#filter_excluded_tags_regex" do - subject { generator.filter_excluded_tags(tags_from_strings(%w(1 2 3))) } + subject { generator.filter_excluded_tags(tags_from_strings(%w[1 2 3])) } context "with matching regex" do let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[23]") } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(1))) } + it { is_expected.to match_array(tags_from_strings(%w[1])) } end context "with non-matching regex" do let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[45]") } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) } + it { is_expected.to match_array(tags_from_strings(%w[1 2 3])) } end end describe "#filter_since_tag" do context "with filled array" do - subject { generator.filter_since_tag(tags_from_strings(%w(1 2 3))) } + subject { generator.filter_since_tag(tags_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_from_strings(%w(1))) } + it { is_expected.to match_array(tags_from_strings(%w[1])) } end context "with invalid since tag" do let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) } + it { is_expected.to match_array(tags_from_strings(%w[1 2 3])) } end end context "with empty array" do - subject { generator.filter_since_tag(tags_from_strings(%w())) } + subject { generator.filter_since_tag(tags_from_strings(%w[])) } 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_from_strings(%w())) } + it { is_expected.to match_array(tags_from_strings(%w[])) } end context "with invalid since tag" do let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w())) } + it { is_expected.to match_array(tags_from_strings(%w[])) } end end end describe "#filter_due_tag" do context "with filled array" do - subject { generator.filter_due_tag(tags_from_strings(%w(1 2 3))) } + subject { generator.filter_due_tag(tags_from_strings(%w[1 2 3])) } context "with valid due tag" do let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(3))) } + it { is_expected.to match_array(tags_from_strings(%w[3])) } end context "with invalid due tag" do let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) } + it { is_expected.to match_array(tags_from_strings(%w[1 2 3])) } end end context "with empty array" do - subject { generator.filter_due_tag(tags_from_strings(%w())) } + subject { generator.filter_due_tag(tags_from_strings(%w[])) } context "with valid due tag" do let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w())) } + it { is_expected.to match_array(tags_from_strings(%w[])) } end context "with invalid due tag" do let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") } it { is_expected.to be_a Array } - it { is_expected.to match_array(tags_from_strings(%w())) } + it { is_expected.to match_array(tags_from_strings(%w[])) } end end end @@ -232,13 +173,13 @@ def tags_from_strings(tags_strings) @generator.sort_tags_by_date(tags) end context "sort unsorted tags" do - let(:tags) { tags_from_strings %w(valid_tag1 valid_tag2 valid_tag3) } + let(:tags) { tags_from_strings %w[valid_tag1 valid_tag2 valid_tag3] } it { is_expected.to be_a_kind_of(Array) } it { is_expected.to match_array(tags.reverse!) } end context "sort sorted tags" do - let(:tags) { tags_from_strings %w(valid_tag3 valid_tag2 valid_tag1) } + let(:tags) { tags_from_strings %w[valid_tag3 valid_tag2 valid_tag1] } it { is_expected.to be_a_kind_of(Array) } it { is_expected.to match_array(tags) }