Skip to content

Raise error instead of unhelpful behavior for --since-tag or --due-tag #621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/github_changelog_generator/generator/generator_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def filter_since_tag(all_tags)
[]
end
else
Helper.log.warn "Warning: can't find tag #{tag}, specified with --since-tag option."
raise ChangelogGeneratorError, "Error: can't find tag #{tag}, specified with --since-tag option."
end
end
filtered_tags
Expand All @@ -155,7 +155,7 @@ def filter_due_tag(all_tags)
[]
end
else
Helper.log.warn "Warning: can't find tag #{tag}, specified with --due-tag option."
raise ChangelogGeneratorError, "Error: can't find tag #{tag}, specified with --due-tag option."
end
end
filtered_tags
Expand Down
24 changes: 4 additions & 20 deletions spec/unit/generator/generator_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,24 +191,16 @@ def tags_from_strings(tags_strings)

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 { expect { subject }.to raise_error(GitHubChangelogGenerator::ChangelogGeneratorError) }
end
end

context "with empty array" do
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[])) }
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 { expect { subject }.to raise_error(GitHubChangelogGenerator::ChangelogGeneratorError) }
end
end
end
Expand All @@ -225,24 +217,16 @@ def tags_from_strings(tags_strings)

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 { expect { subject }.to raise_error(GitHubChangelogGenerator::ChangelogGeneratorError) }
end
end

context "with empty array" do
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[])) }
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 { expect { subject }.to raise_error(GitHubChangelogGenerator::ChangelogGeneratorError) }
end
end
end
Expand Down