github_changelog_generator 1.15.2 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,6 +37,7 @@ module GitHubChangelogGenerator
37
37
  exclude_tags
38
38
  exclude_tags_regex
39
39
  filter_issues_by_milestone
40
+ issues_of_open_milestones
40
41
  frontmatter
41
42
  future_release
42
43
  github_endpoint
@@ -44,6 +45,7 @@ module GitHubChangelogGenerator
44
45
  header
45
46
  http_cache
46
47
  include_labels
48
+ include_tags_regex
47
49
  issue_prefix
48
50
  issue_line_labels
49
51
  issue_line_body
@@ -62,6 +64,7 @@ module GitHubChangelogGenerator
62
64
  security_prefix
63
65
  simple_list
64
66
  since_tag
67
+ since_commit
65
68
  ssl_ca_file
66
69
  summary_labels
67
70
  summary_prefix
@@ -37,7 +37,7 @@ module GitHubChangelogGenerator
37
37
  def self.setup_parser(options)
38
38
  OptionParser.new do |opts| # rubocop:disable Metrics/BlockLength
39
39
  opts.banner = "Usage: github_changelog_generator --user USER --project PROJECT [options]"
40
- opts.on("-u", "--user USER", "Username of the owner of target GitHub repo.") do |last|
40
+ opts.on("-u", "--user USER", "Username of the owner of the target GitHub repo OR the namespace of target Github repo if owned by an organization.") do |last|
41
41
  options[:user] = last
42
42
  end
43
43
  opts.on("-p", "--project PROJECT", "Name of project on GitHub.") do |last|
@@ -89,7 +89,7 @@ module GitHubChangelogGenerator
89
89
  options[:add_sections] = v
90
90
  end
91
91
  opts.on("--front-matter [JSON]", "Add YAML front matter. Formatted as JSON because it's easier to add on the command line.") do |v|
92
- options[:frontmatter] = JSON.parse(v).to_yaml + "---\n"
92
+ options[:frontmatter] = "#{JSON.parse(v).to_yaml}---\n"
93
93
  end
94
94
  opts.on("--pr-label [LABEL]", "Set up custom label for pull requests section. Default is \"**Merged pull requests:**\".") do |v|
95
95
  options[:merge_prefix] = v
@@ -109,6 +109,9 @@ module GitHubChangelogGenerator
109
109
  opts.on("--[no-]filter-by-milestone", "Use milestone to detect when issue was resolved. Default is true.") do |last|
110
110
  options[:filter_issues_by_milestone] = last
111
111
  end
112
+ opts.on("--[no-]issues-of-open-milestones", "Include issues of open milestones. Default is true.") do |v|
113
+ options[:issues_of_open_milestones] = v
114
+ end
112
115
  opts.on("--[no-]author", "Add author of pull request at the end. Default is true.") do |author|
113
116
  options[:author] = author
114
117
  end
@@ -157,6 +160,9 @@ module GitHubChangelogGenerator
157
160
  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|
158
161
  options[:issue_line_labels] = list
159
162
  end
163
+ opts.on("--include-tags-regex [REGEX]", "Apply a regular expression on tag names so that they can be included, for example: --include-tags-regex \".*\+\d{1,}\".") do |last|
164
+ options[:include_tags_regex] = last
165
+ end
160
166
  opts.on("--exclude-tags x,y,z", Array, "Changelog will exclude specified tags") do |list|
161
167
  options[:exclude_tags] = list
162
168
  end
@@ -169,6 +175,9 @@ module GitHubChangelogGenerator
169
175
  opts.on("--due-tag x", "Changelog will end before specified tag.") do |v|
170
176
  options[:due_tag] = v
171
177
  end
178
+ opts.on("--since-commit x", "Fetch only commits after this time. eg. \"2017-01-01 10:00:00\"") do |v|
179
+ options[:since_commit] = v
180
+ end
172
181
  opts.on("--max-issues [NUMBER]", Integer, "Maximum number of issues to fetch from GitHub. Default is unlimited.") do |max|
173
182
  options[:max_issues] = max
174
183
  end
@@ -230,6 +239,7 @@ module GitHubChangelogGenerator
230
239
  add_pr_wo_labels: true,
231
240
  pulls: true,
232
241
  filter_issues_by_milestone: true,
242
+ issues_of_open_milestones: true,
233
243
  author: true,
234
244
  unreleased: true,
235
245
  unreleased_label: "Unreleased",
@@ -56,7 +56,7 @@ module GitHubChangelogGenerator
56
56
 
57
57
  # Returns true if the line starts with a pound sign or a semi-colon.
58
58
  def non_configuration_line?(line)
59
- line =~ /^[\#;]/ || line =~ /^[\s]+$/
59
+ line =~ /^[\#;]/ || line =~ /^\s+$/
60
60
  end
61
61
 
62
62
  # Returns a the option name as a symbol and its string value sans newlines.
@@ -29,8 +29,8 @@ module GitHubChangelogGenerator
29
29
  defaults = {
30
30
  heading_level: "##",
31
31
  heading_structures: [
32
- /^## \[(?<version>.+?)\]\((?<url>.+?)\)( \((?<date>.+?)\))?$/,
33
- /^## (?<version>.+?)( \((?<date>.+?)\))?$/
32
+ /^## \[(?<version>.+?)\]\((?<url>.+?)\)( \((?<date>.+?)\))?$/, # rubocop:disable Lint/MixedRegexpCaptureTypes
33
+ /^## (?<version>.+?)( \((?<date>.+?)\))?$/ # rubocop:disable Lint/MixedRegexpCaptureTypes
34
34
  ]
35
35
  }
36
36
 
@@ -15,11 +15,11 @@ module GitHubChangelogGenerator
15
15
  pulls filter_issues_by_milestone author
16
16
  unreleased_only unreleased unreleased_label
17
17
  compare_link include_labels exclude_labels
18
- bug_labels enhancement_labels
18
+ bug_labels enhancement_labels include_tags_regex
19
19
  between_tags exclude_tags exclude_tags_regex since_tag max_issues
20
20
  github_site github_endpoint simple_list
21
21
  future_release release_branch verbose release_url
22
- base configure_sections add_sections]
22
+ base configure_sections add_sections http_cache]
23
23
 
24
24
  OPTIONS.each do |o|
25
25
  attr_accessor o.to_sym
@@ -31,6 +31,7 @@ module GitHubChangelogGenerator
31
31
  #
32
32
  # GitHubChangelogGenerator::RakeTask.new
33
33
  def initialize(*args, &task_block)
34
+ super
34
35
  @name = args.shift || :changelog
35
36
 
36
37
  define(args, &task_block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitHubChangelogGenerator
4
- VERSION = "1.15.2"
4
+ VERSION = "1.16.0"
5
5
  end
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GIT\-GENERATE\-CHANGELOG" "1" "May 2018" "" ""
4
+ .TH "GIT\-GENERATE\-CHANGELOG" "1" "May 2020" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgit\-generate\-changelog\fR \- Generate changelog from GitHub
@@ -157,6 +157,12 @@ Include pull\-requests in changelog\. Default is true\.
157
157
  Use milestone to detect when issue was resolved\. Default is true\.
158
158
  .
159
159
  .P
160
+ \-\-[no\-]issues\-of\-open\-milestones
161
+ .
162
+ .P
163
+ Include issues of open milestones\. Default is true\.
164
+ .
165
+ .P
160
166
  \-\-[no\-]author
161
167
  .
162
168
  .P
@@ -277,6 +283,12 @@ Changelog will start after specified tag\.
277
283
  Changelog will end before specified tag\.
278
284
  .
279
285
  .P
286
+ \-\-since\-commit x
287
+ .
288
+ .P
289
+ Fetch only commits after this time\. eg\. "2017\-01\-01 10:00:00"
290
+ .
291
+ .P
280
292
  \-\-max\-issues [NUMBER]
281
293
  .
282
294
  .P
@@ -375,7 +387,7 @@ GitHub pull requests that have been merged whose merge commit SHA has been modif
375
387
  Written by Petr Korolev sky4winder@gmail\.com
376
388
  .
377
389
  .SH "REPORTING BUGS"
378
- <\fIhttps://github\.com/github-changelog-generator/github\-changelog\-generator/issues\fR>
390
+ <\fIhttps://github\.com/github\-changelog\-generator/github\-changelog\-generator/issues\fR>
379
391
  .
380
392
  .SH "SEE ALSO"
381
- <\fIhttps://github\.com/github-changelog-generator/github\-changelog\-generator/\fR>
393
+ <\fIhttps://github\.com/github\-changelog\-generator/github\-changelog\-generator/\fR>
@@ -181,6 +181,10 @@
181
181
 
182
182
  <p> Use milestone to detect when issue was resolved. Default is true.</p>
183
183
 
184
+ <p> --[no-]issues-of-open-milestones</p>
185
+
186
+ <p> Include issues of open milestones. Default is true.</p>
187
+
184
188
  <p> --[no-]author</p>
185
189
 
186
190
  <p> Add author of pull request at the end. Default is true.</p>
@@ -261,6 +265,10 @@
261
265
 
262
266
  <p> Changelog will end before specified tag.</p>
263
267
 
268
+ <p> --since-commit x</p>
269
+
270
+ <p> Fetch only commits after this time. eg. "2017-01-01 10:00:00"</p>
271
+
264
272
  <p> --max-issues [NUMBER]</p>
265
273
 
266
274
  <p> Maximum number of issues to fetch from GitHub. Default is unlimited.</p>
@@ -342,7 +350,7 @@
342
350
 
343
351
  <ol class='man-decor man-foot man foot'>
344
352
  <li class='tl'></li>
345
- <li class='tc'>May 2018</li>
353
+ <li class='tc'>May 2020</li>
346
354
  <li class='tr'>git-generate-changelog(1)</li>
347
355
  </ol>
348
356
 
@@ -107,6 +107,10 @@ Automatically generate changelog from your tags, issues, labels and pull request
107
107
 
108
108
  Use milestone to detect when issue was resolved. Default is true.
109
109
 
110
+ --[no-]issues-of-open-milestones
111
+
112
+ Include issues of open milestones. Default is true.
113
+
110
114
  --[no-]author
111
115
 
112
116
  Add author of pull request at the end. Default is true.
@@ -187,6 +191,10 @@ Automatically generate changelog from your tags, issues, labels and pull request
187
191
 
188
192
  Changelog will end before specified tag.
189
193
 
194
+ --since-commit x
195
+
196
+ Fetch only commits after this time. eg. "2017-01-01 10:00:00"
197
+
190
198
  --max-issues [NUMBER]
191
199
 
192
200
  Maximum number of issues to fetch from GitHub. Default is unlimited.
data/spec/spec_helper.rb CHANGED
@@ -44,7 +44,7 @@ VCR.configure do |c|
44
44
  decode_compressed_response: true
45
45
  }
46
46
  c.filter_sensitive_data("<GITHUB_TOKEN>") do
47
- "token #{ENV.fetch('CHANGELOG_GITHUB_TOKEN') { 'frobnitz' }}"
47
+ "token #{ENV.fetch('CHANGELOG_GITHUB_TOKEN', 'frobnitz')}"
48
48
  end
49
49
 
50
50
  c.configure_rspec_metadata!
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Metrics/ModuleLength
4
3
  module GitHubChangelogGenerator
5
4
  RSpec.describe Entry do
6
5
  def label(name)
@@ -58,9 +57,6 @@ module GitHubChangelogGenerator
58
57
  let(:issues) { [] }
59
58
  let(:pull_requests) { [] }
60
59
  let(:tags) { [] }
61
- let(:compare_shas) do
62
- { "aaaaa1...master" => ["aaaaa1"] }
63
- end
64
60
 
65
61
  # Default to standard options minus verbose to avoid output during testing.
66
62
  let(:options) do
@@ -76,15 +72,14 @@ module GitHubChangelogGenerator
76
72
  fetch_closed_issues_and_pr: [issues, pull_requests],
77
73
  fetch_closed_pull_requests: [],
78
74
  fetch_events_async: issues + pull_requests,
79
- fetch_tag_shas_async: nil,
75
+ fetch_tag_shas: nil,
80
76
  fetch_comments_async: nil,
81
77
  default_branch: "master",
82
78
  oldest_commit: { "sha" => "aaaaa1" },
83
79
  fetch_commit: { "commit" => { "author" => { "date" => Time.now.utc } } }
84
80
  )
85
- allow(fake_fetcher).to receive(:fetch_compare) do |old, new|
86
- # Comparisons has a "commits" key of an array of commit hashes each with a "sha" key.
87
- { "commits" => compare_shas["#{old}...#{new}"].collect { |sha| { "sha" => sha } } }
81
+ allow(fake_fetcher).to receive(:commits_in_branch) do
82
+ ["aaaaa1"]
88
83
  end
89
84
  allow(GitHubChangelogGenerator::OctoFetcher).to receive(:new).and_return(fake_fetcher)
90
85
  generator = GitHubChangelogGenerator::Generator.new(options)
@@ -426,6 +421,18 @@ module GitHubChangelogGenerator
426
421
  sections_json.shift
427
422
  end
428
423
  end
424
+ context "parse also body_only" do
425
+ let(:sections_string) { "{ \"foo\": { \"prefix\": \"foofix\", \"labels\": [\"test1\", \"test2\"]}, \"bar\": { \"prefix\": \"barfix\", \"labels\": [\"test3\", \"test4\"], \"body_only\": true}}" }
426
+
427
+ it "returns correctly constructed sections" do
428
+ require "json"
429
+
430
+ parsed_sections = subject.send(:parse_sections, sections_string)
431
+
432
+ expect(parsed_sections[0].body_only).to eq false
433
+ expect(parsed_sections[1].body_only).to eq true
434
+ end
435
+ end
429
436
  end
430
437
  context "hash" do
431
438
  let(:sections_hash) do
@@ -548,14 +555,14 @@ module GitHubChangelogGenerator
548
555
  end
549
556
 
550
557
  it "assigns issues to the correct sections" do
551
- breaking_section = entry_sections.select { |section| section.name == "breaking" }[0]
552
- enhancement_section = entry_sections.select { |section| section.name == "enhancements" }[0]
553
- bug_section = entry_sections.select { |section| section.name == "bugs" }[0]
554
- deprecated_section = entry_sections.select { |section| section.name == "deprecated" }[0]
555
- removed_section = entry_sections.select { |section| section.name == "removed" }[0]
556
- security_section = entry_sections.select { |section| section.name == "security" }[0]
557
- issue_section = entry_sections.select { |section| section.name == "issues" }[0]
558
- merged_section = entry_sections.select { |section| section.name == "merged" }[0]
558
+ breaking_section = entry_sections.find { |section| section.name == "breaking" }
559
+ enhancement_section = entry_sections.find { |section| section.name == "enhancements" }
560
+ bug_section = entry_sections.find { |section| section.name == "bugs" }
561
+ deprecated_section = entry_sections.find { |section| section.name == "deprecated" }
562
+ removed_section = entry_sections.find { |section| section.name == "removed" }
563
+ security_section = entry_sections.find { |section| section.name == "security" }
564
+ issue_section = entry_sections.find { |section| section.name == "issues" }
565
+ merged_section = entry_sections.find { |section| section.name == "merged" }
559
566
 
560
567
  expect(titles_for(breaking_section.issues)).to eq(["issue breaking", "issue all the labels", "pr breaking", "pr all the labels"])
561
568
  expect(titles_for(enhancement_section.issues)).to eq(["issue enhancement", "pr enhancement"])
@@ -612,10 +619,10 @@ module GitHubChangelogGenerator
612
619
  end
613
620
 
614
621
  it "assigns issues to the correct sections" do
615
- foo_section = entry_sections.select { |section| section.name == "foo" }[0]
616
- bar_section = entry_sections.select { |section| section.name == "bar" }[0]
617
- issue_section = entry_sections.select { |section| section.name == "issues" }[0]
618
- merged_section = entry_sections.select { |section| section.name == "merged" }[0]
622
+ foo_section = entry_sections.find { |section| section.name == "foo" }
623
+ bar_section = entry_sections.find { |section| section.name == "bar" }
624
+ issue_section = entry_sections.find { |section| section.name == "issues" }
625
+ merged_section = entry_sections.find { |section| section.name == "merged" }
619
626
 
620
627
  aggregate_failures "checks all sections" do
621
628
  expect(titles_for(foo_section.issues)).to eq(["issue test1", "issue all the labels", "issue some included labels", "pr test1", "pr all the labels", "pr some included labels"])
@@ -670,10 +677,10 @@ module GitHubChangelogGenerator
670
677
  end
671
678
 
672
679
  it "assigns issues to the correct sections" do
673
- foo_section = entry_sections.select { |section| section.name == "foo" }[0]
674
- bar_section = entry_sections.select { |section| section.name == "bar" }[0]
675
- issue_section = entry_sections.select { |section| section.name == "issues" }[0]
676
- merged_section = entry_sections.select { |section| section.name == "merged" }[0]
680
+ foo_section = entry_sections.find { |section| section.name == "foo" }
681
+ bar_section = entry_sections.find { |section| section.name == "bar" }
682
+ issue_section = entry_sections.find { |section| section.name == "issues" }
683
+ merged_section = entry_sections.find { |section| section.name == "merged" }
677
684
 
678
685
  aggregate_failures "checks all sections" do
679
686
  expect(titles_for(foo_section.issues)).to eq(["issue test1", "issue all the labels", "pr test1", "pr all the labels"])
@@ -737,12 +744,12 @@ module GitHubChangelogGenerator
737
744
  end
738
745
 
739
746
  it "assigns issues to the correct sections" do
740
- foo_section = entry_sections.select { |section| section.name == "foo" }[0]
741
- breaking_section = entry_sections.select { |section| section.name == "breaking" }[0]
742
- enhancement_section = entry_sections.select { |section| section.name == "enhancements" }[0]
743
- bug_section = entry_sections.select { |section| section.name == "bugs" }[0]
744
- issue_section = entry_sections.select { |section| section.name == "issues" }[0]
745
- merged_section = entry_sections.select { |section| section.name == "merged" }[0]
747
+ foo_section = entry_sections.find { |section| section.name == "foo" }
748
+ breaking_section = entry_sections.find { |section| section.name == "breaking" }
749
+ enhancement_section = entry_sections.find { |section| section.name == "enhancements" }
750
+ bug_section = entry_sections.find { |section| section.name == "bugs" }
751
+ issue_section = entry_sections.find { |section| section.name == "issues" }
752
+ merged_section = entry_sections.find { |section| section.name == "merged" }
746
753
 
747
754
  aggregate_failures "checks all sections" do
748
755
  expect(titles_for(breaking_section.issues)).to eq(["issue all the labels", "pr all the labels"])
@@ -757,4 +764,3 @@ module GitHubChangelogGenerator
757
764
  end
758
765
  end
759
766
  end
760
- # rubocop:enable Metrics/ModuleLength
@@ -5,82 +5,137 @@ module GitHubChangelogGenerator
5
5
  let(:default_options) { GitHubChangelogGenerator::Parser.default_options.merge(verbose: false) }
6
6
  let(:options) { {} }
7
7
  let(:generator) { described_class.new(default_options.merge(options)) }
8
-
9
8
  let(:bad_label) { { "name" => "BAD" } }
10
- let(:bad_issue) { { "labels" => [bad_label] } }
11
9
  let(:good_label) { { "name" => "GOOD" } }
12
- let(:good_issue) { { "labels" => [good_label] } }
13
- let(:unlabeled_issue) { { "labels" => [] } }
14
- let(:issues) { [bad_issue, good_issue, unlabeled_issue] }
15
10
 
16
- describe "#exclude_issues_by_labels" do
17
- subject do
18
- generator.exclude_issues_by_labels(issues)
19
- end
11
+ describe "pull requests" do
12
+ let(:bad_pull_request) { { "pull_request" => {}, "labels" => [bad_label] } }
13
+ let(:good_pull_request) { { "pull_request" => {}, "labels" => [good_label] } }
14
+ let(:unlabeled_pull_request) { { "pull_request" => {}, "labels" => [] } }
15
+ let(:pull_requests) { [bad_pull_request, good_pull_request, unlabeled_pull_request] }
20
16
 
21
- let(:expected_issues) { issues }
17
+ describe "#filter_wo_labels" do
18
+ subject do
19
+ generator.filter_wo_labels(pull_requests)
20
+ end
22
21
 
23
- it { is_expected.to eq(expected_issues) }
22
+ let(:expected_pull_requests) { pull_requests }
24
23
 
25
- context "when 'exclude_lables' is provided" do
26
- let(:options) { { exclude_labels: %w[BAD BOO] } }
27
- let(:expected_issues) { [good_issue, unlabeled_issue] }
24
+ it { is_expected.to eq(expected_pull_requests) }
28
25
 
29
- it { is_expected.to eq(expected_issues) }
30
- end
26
+ context "when 'add_pr_wo_labels' is false" do
27
+ let(:options) { { add_pr_wo_labels: false } }
28
+ let(:expected_pull_requests) { [bad_pull_request, good_pull_request] }
31
29
 
32
- context "with no option given" do
33
- subject(:generator) { described_class.new }
34
- it "passes everything through when no option given" do
35
- result = generator.exclude_issues_by_labels(issues)
30
+ it { is_expected.to eq(expected_pull_requests) }
31
+ end
32
+
33
+ context "when 'add_pr_wo_labels' is true" do
34
+ let(:options) { { add_pr_wo_labels: true } }
36
35
 
37
- expect(result).to eq(issues)
36
+ it { is_expected.to eq(expected_pull_requests) }
38
37
  end
39
38
  end
40
39
  end
41
40
 
42
- describe "#get_filtered_issues" do
43
- subject do
44
- generator.get_filtered_issues(issues)
45
- end
41
+ describe "issues" do
42
+ let(:bad_issue) { { "labels" => [bad_label] } }
43
+ let(:good_issue) { { "labels" => [good_label] } }
44
+ let(:unlabeled_issue) { { "labels" => [] } }
45
+ let(:issues) { [bad_issue, good_issue, unlabeled_issue] }
46
46
 
47
- let(:expected_issues) { issues }
48
-
49
- it { is_expected.to eq(expected_issues) }
47
+ describe "#filter_wo_labels" do
48
+ subject do
49
+ generator.filter_wo_labels(issues)
50
+ end
50
51
 
51
- context "when 'exclude_labels' is provided" do
52
- let(:options) { { exclude_labels: %w[BAD BOO] } }
53
- let(:expected_issues) { [good_issue, unlabeled_issue] }
52
+ let(:expected_issues) { issues }
54
53
 
55
54
  it { is_expected.to eq(expected_issues) }
55
+
56
+ context "when 'add_issues_wo_labels' is false" do
57
+ let(:options) { { add_issues_wo_labels: false } }
58
+ let(:expected_issues) { [bad_issue, good_issue] }
59
+
60
+ it { is_expected.to eq(expected_issues) }
61
+ end
62
+
63
+ context "when 'add_issues_wo_labels' is true" do
64
+ let(:options) { { add_issues_wo_labels: true } }
65
+
66
+ it { is_expected.to eq(expected_issues) }
67
+ end
56
68
  end
57
69
 
58
- context "when 'add_issues_wo_labels' is false" do
59
- let(:options) { { add_issues_wo_labels: false } }
60
- let(:expected_issues) { [bad_issue, good_issue] }
70
+ describe "#exclude_issues_by_labels" do
71
+ subject do
72
+ generator.exclude_issues_by_labels(issues)
73
+ end
74
+
75
+ let(:expected_issues) { issues }
61
76
 
62
77
  it { is_expected.to eq(expected_issues) }
63
78
 
64
- context "with 'exclude_labels'" do
65
- let(:options) { { add_issues_wo_labels: false, exclude_labels: %w[GOOD] } }
66
- let(:expected_issues) { [bad_issue] }
79
+ context "when 'exclude_labels' is provided" do
80
+ let(:options) { { exclude_labels: %w[BAD BOO] } }
81
+ let(:expected_issues) { [good_issue, unlabeled_issue] }
67
82
 
68
83
  it { is_expected.to eq(expected_issues) }
69
84
  end
70
85
 
71
- context "with 'include_labels'" do
72
- let(:options) { { add_issues_wo_labels: false, include_labels: %w[GOOD] } }
73
- let(:expected_issues) { [good_issue] }
86
+ context "with no option given" do
87
+ subject(:generator) { described_class.new }
88
+ it "passes everything through when no option given" do
89
+ result = generator.exclude_issues_by_labels(issues)
74
90
 
75
- it { is_expected.to eq(expected_issues) }
91
+ expect(result).to eq(issues)
92
+ end
76
93
  end
77
94
  end
78
95
 
79
- context "when 'include_labels' is specified" do
80
- let(:options) { { include_labels: %w[GOOD] } }
81
- let(:expected_issues) { [good_issue, unlabeled_issue] }
96
+ describe "#get_filtered_issues" do
97
+ subject do
98
+ generator.get_filtered_issues(issues)
99
+ end
100
+
101
+ let(:expected_issues) { issues }
82
102
 
83
103
  it { is_expected.to eq(expected_issues) }
104
+
105
+ context "when 'exclude_labels' is provided" do
106
+ let(:options) { { exclude_labels: %w[BAD BOO] } }
107
+ let(:expected_issues) { [good_issue, unlabeled_issue] }
108
+
109
+ it { is_expected.to eq(expected_issues) }
110
+ end
111
+
112
+ context "when 'add_issues_wo_labels' is false" do
113
+ let(:options) { { add_issues_wo_labels: false } }
114
+ let(:expected_issues) { [bad_issue, good_issue] }
115
+
116
+ it { is_expected.to eq(expected_issues) }
117
+
118
+ context "with 'exclude_labels'" do
119
+ let(:options) { { add_issues_wo_labels: false, exclude_labels: %w[GOOD] } }
120
+ let(:expected_issues) { [bad_issue] }
121
+
122
+ it { is_expected.to eq(expected_issues) }
123
+ end
124
+
125
+ context "with 'include_labels'" do
126
+ let(:options) { { add_issues_wo_labels: false, include_labels: %w[GOOD] } }
127
+ let(:expected_issues) { [good_issue] }
128
+
129
+ it { is_expected.to eq(expected_issues) }
130
+ end
131
+ end
132
+
133
+ context "when 'include_labels' is specified" do
134
+ let(:options) { { include_labels: %w[GOOD] } }
135
+ let(:expected_issues) { [good_issue, unlabeled_issue] }
136
+
137
+ it { is_expected.to eq(expected_issues) }
138
+ end
84
139
  end
85
140
  end
86
141
  end