github_changelog_generator 1.15.0.pre.rc → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +1 -1
  3. data/README.md +126 -51
  4. data/bin/git-generate-changelog +1 -1
  5. data/lib/github_changelog_generator.rb +10 -6
  6. data/lib/github_changelog_generator/generator/entry.rb +218 -0
  7. data/lib/github_changelog_generator/generator/generator.rb +96 -119
  8. data/lib/github_changelog_generator/generator/generator_fetcher.rb +140 -21
  9. data/lib/github_changelog_generator/generator/generator_processor.rb +40 -10
  10. data/lib/github_changelog_generator/generator/generator_tags.rb +10 -12
  11. data/lib/github_changelog_generator/generator/section.rb +104 -0
  12. data/lib/github_changelog_generator/octo_fetcher.rb +113 -23
  13. data/lib/github_changelog_generator/options.rb +35 -4
  14. data/lib/github_changelog_generator/parser.rb +88 -49
  15. data/lib/github_changelog_generator/parser_file.rb +6 -2
  16. data/lib/github_changelog_generator/task.rb +2 -3
  17. data/lib/github_changelog_generator/version.rb +1 -1
  18. data/man/git-generate-changelog.1 +125 -51
  19. data/man/git-generate-changelog.1.html +145 -89
  20. data/man/git-generate-changelog.html +19 -7
  21. data/man/git-generate-changelog.md +141 -86
  22. data/spec/files/github-changelog-generator.md +114 -114
  23. data/spec/{install-gem-in-bundler.gemfile → install_gem_in_bundler.gemfile} +2 -0
  24. data/spec/spec_helper.rb +1 -5
  25. data/spec/unit/generator/entry_spec.rb +760 -0
  26. data/spec/unit/generator/generator_processor_spec.rb +9 -2
  27. data/spec/unit/generator/generator_tags_spec.rb +5 -21
  28. data/spec/unit/octo_fetcher_spec.rb +204 -197
  29. data/spec/unit/options_spec.rb +24 -0
  30. data/spec/unit/parse_file_spec.rb +2 -2
  31. data/spec/unit/reader_spec.rb +4 -4
  32. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_commits/when_API_is_valid/returns_commits.json +1 -0
  33. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_commits_before/when_API_is_valid/returns_commits.json +1 -1
  34. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid.json +1 -1
  35. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issue_with_proper_key/values.json +1 -1
  36. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issues.json +1 -1
  37. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issues_with_labels.json +1 -1
  38. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_pull_request_with_proper_key/values.json +1 -1
  39. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_pull_requests_with_labels.json +1 -1
  40. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid.json +1 -1
  41. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid/returns_correct_pull_request_keys.json +1 -1
  42. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid/returns_pull_requests.json +1 -1
  43. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_commit/when_API_call_is_valid.json +1 -1
  44. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_commit/when_API_call_is_valid/returns_commit.json +1 -1
  45. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_date_of_tag/when_API_call_is_valid.json +1 -1
  46. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_date_of_tag/when_API_call_is_valid/returns_date.json +1 -1
  47. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_events_async/when_API_call_is_valid.json +1 -1
  48. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_events_async/when_API_call_is_valid/populates_issues.json +1 -1
  49. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid.json +1 -1
  50. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid/should_return_tags.json +1 -1
  51. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid/should_return_tags_count.json +1 -1
  52. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_wrong_token_provided.json +1 -1
  53. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_wrong_token_provided/should_raise_Unauthorized_error.json +1 -1
  54. metadata +17 -17
  55. data/bin/ghclgen +0 -5
  56. data/lib/github_changelog_generator/generator/generator_generation.rb +0 -181
  57. data/spec/unit/generator/generator_generation_spec.rb +0 -73
@@ -1,305 +1,305 @@
1
- # Change Log
1
+ # Changelog
2
2
 
3
- ## [1.3.10](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.10) (2015-03-18)
3
+ ## [1.3.10](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.10) (2015-03-18)
4
4
 
5
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.9...1.3.10)
5
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.3.9...1.3.10)
6
6
 
7
7
  **Fixed bugs:**
8
8
 
9
- - Exclude closed PR's from changelog. [\#69](https://github.com/skywinder/Github-Changelog-Generator/issues/69)
9
+ - Exclude closed PR's from changelog. [\#69](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/69)
10
10
 
11
11
  **Merged pull requests:**
12
12
 
13
- - Fix termination in case of empty unreleased section with `--unreleased-only` option. [\#70](https://github.com/skywinder/Github-Changelog-Generator/pull/70) ([skywinder](https://github.com/skywinder))
13
+ - Fix termination in case of empty unreleased section with `--unreleased-only` option. [\#70](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/70) ([github-changelog-generator](https://github.com/github-changelog-generator))
14
14
 
15
- ## [1.3.9](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.9) (2015-03-06)
15
+ ## [1.3.9](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.9) (2015-03-06)
16
16
 
17
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.8...1.3.9)
17
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.3.8...1.3.9)
18
18
 
19
19
  **Implemented enhancements:**
20
20
 
21
- - Improve method of detecting owner and repository [\#63](https://github.com/skywinder/Github-Changelog-Generator/issues/63)
21
+ - Improve method of detecting owner and repository [\#63](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/63)
22
22
 
23
23
  **Merged pull requests:**
24
24
 
25
- - Resolved concurrency problem in case of issues \> 2048 [\#65](https://github.com/skywinder/Github-Changelog-Generator/pull/65) ([skywinder](https://github.com/skywinder))
25
+ - Resolved concurrency problem in case of issues \> 2048 [\#65](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/65) ([github-changelog-generator](https://github.com/github-changelog-generator))
26
26
 
27
- ## [1.3.8](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.8) (2015-03-05)
27
+ ## [1.3.8](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.8) (2015-03-05)
28
28
 
29
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.6...1.3.8)
29
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.3.6...1.3.8)
30
30
 
31
31
  **Merged pull requests:**
32
32
 
33
- - Fix `git remote` parsing in case, when script running without parameters inside destination directory [\#61](https://github.com/skywinder/Github-Changelog-Generator/pull/61) ([skywinder](https://github.com/skywinder))
33
+ - Fix `git remote` parsing in case, when script running without parameters inside destination directory [\#61](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/61) ([github-changelog-generator](https://github.com/github-changelog-generator))
34
34
 
35
- ## [1.3.6](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.6) (2015-03-05)
35
+ ## [1.3.6](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.6) (2015-03-05)
36
36
 
37
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.5...1.3.6)
37
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.3.5...1.3.6)
38
38
 
39
- ## [1.3.5](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.5) (2015-03-04)
39
+ ## [1.3.5](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.5) (2015-03-04)
40
40
 
41
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.4...1.3.5)
41
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.3.4...1.3.5)
42
42
 
43
43
  **Fixed bugs:**
44
44
 
45
- - Pull Requests in Wrong Tag [\#60](https://github.com/skywinder/Github-Changelog-Generator/issues/60)
45
+ - Pull Requests in Wrong Tag [\#60](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/60)
46
46
 
47
- ## [1.3.4](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.4) (2015-03-03)
47
+ ## [1.3.4](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.4) (2015-03-03)
48
48
 
49
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.3...1.3.4)
49
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.3.3...1.3.4)
50
50
 
51
51
  **Fixed bugs:**
52
52
 
53
- - --no-issues appears to break PRs [\#59](https://github.com/skywinder/Github-Changelog-Generator/issues/59)
53
+ - --no-issues appears to break PRs [\#59](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/59)
54
54
 
55
- ## [1.3.3](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.3) (2015-03-03)
55
+ ## [1.3.3](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.3) (2015-03-03)
56
56
 
57
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.2...1.3.3)
57
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.3.2...1.3.3)
58
58
 
59
59
  **Closed issues:**
60
60
 
61
- - Add \# character to encapsulate list. [\#58](https://github.com/skywinder/Github-Changelog-Generator/issues/58)
61
+ - Add \# character to encapsulate list. [\#58](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/58)
62
62
 
63
- ## [1.3.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.2) (2015-03-03)
63
+ ## [1.3.2](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.2) (2015-03-03)
64
64
 
65
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.1...1.3.2)
65
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.3.1...1.3.2)
66
66
 
67
67
  **Fixed bugs:**
68
68
 
69
- - generation failed if github commit api return `404 Not Found` [\#57](https://github.com/skywinder/Github-Changelog-Generator/issues/57)
69
+ - generation failed if github commit api return `404 Not Found` [\#57](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/57)
70
70
 
71
- ## [1.3.1](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.1) (2015-02-27)
71
+ ## [1.3.1](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.1) (2015-02-27)
72
72
 
73
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.0...1.3.1)
73
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.3.0...1.3.1)
74
74
 
75
- ## [1.3.0](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.0) (2015-02-26)
75
+ ## [1.3.0](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.0) (2015-02-26)
76
76
 
77
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.8...1.3.0)
77
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.2.8...1.3.0)
78
78
 
79
79
  **Implemented enhancements:**
80
80
 
81
- - Do not show `Unreleased` section, when it's empty. [\#55](https://github.com/skywinder/Github-Changelog-Generator/issues/55)
81
+ - Do not show `Unreleased` section, when it's empty. [\#55](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/55)
82
82
 
83
- - Separate list exclude and include labels [\#52](https://github.com/skywinder/Github-Changelog-Generator/issues/52)
83
+ - Separate list exclude and include labels [\#52](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/52)
84
84
 
85
- - Unreleased issues in separate section [\#47](https://github.com/skywinder/Github-Changelog-Generator/issues/47)
85
+ - Unreleased issues in separate section [\#47](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/47)
86
86
 
87
- - Separate by lists: Enhancements, Bugs, Pull requests. [\#31](https://github.com/skywinder/Github-Changelog-Generator/issues/31)
87
+ - Separate by lists: Enhancements, Bugs, Pull requests. [\#31](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/31)
88
88
 
89
89
  **Fixed bugs:**
90
90
 
91
- - Test pull request with invalid label \(\#26\) in changelog appeared. [\#44](https://github.com/skywinder/Github-Changelog-Generator/issues/44)
91
+ - Test pull request with invalid label \(\#26\) in changelog appeared. [\#44](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/44)
92
92
 
93
93
  **Merged pull requests:**
94
94
 
95
- - Implement filtering of Pull Requests by milestones [\#50](https://github.com/skywinder/Github-Changelog-Generator/pull/50) ([skywinder](https://github.com/skywinder))
95
+ - Implement filtering of Pull Requests by milestones [\#50](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/50) ([github-changelog-generator](https://github.com/github-changelog-generator))
96
96
 
97
- ## [1.2.8](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.8) (2015-02-17)
97
+ ## [1.2.8](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.2.8) (2015-02-17)
98
98
 
99
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.7...1.2.8)
99
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.2.7...1.2.8)
100
100
 
101
101
  **Closed issues:**
102
102
 
103
- - Bugs, that closed simultaneously with push not appeared in correct version. [\#37](https://github.com/skywinder/Github-Changelog-Generator/issues/37)
103
+ - Bugs, that closed simultaneously with push not appeared in correct version. [\#37](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/37)
104
104
 
105
105
  **Merged pull requests:**
106
106
 
107
- - Feature/fix 37 [\#49](https://github.com/skywinder/Github-Changelog-Generator/pull/49) ([skywinder](https://github.com/skywinder))
107
+ - Feature/fix 37 [\#49](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/49) ([github-changelog-generator](https://github.com/github-changelog-generator))
108
108
 
109
- - Prettify output [\#48](https://github.com/skywinder/Github-Changelog-Generator/pull/48) ([skywinder](https://github.com/skywinder))
109
+ - Prettify output [\#48](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/48) ([github-changelog-generator](https://github.com/github-changelog-generator))
110
110
 
111
- ## [1.2.7](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.7) (2015-01-26)
111
+ ## [1.2.7](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.2.7) (2015-01-26)
112
112
 
113
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.6...1.2.7)
113
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.2.6...1.2.7)
114
114
 
115
115
  **Merged pull requests:**
116
116
 
117
- - Add compare link between older version and newer version [\#46](https://github.com/skywinder/Github-Changelog-Generator/pull/46) ([sue445](https://github.com/sue445))
117
+ - Add compare link between older version and newer version [\#46](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/46) ([sue445](https://github.com/sue445))
118
118
 
119
- ## [1.2.6](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.6) (2015-01-21)
119
+ ## [1.2.6](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.2.6) (2015-01-21)
120
120
 
121
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.5...1.2.6)
121
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.2.5...1.2.6)
122
122
 
123
123
  **Merged pull requests:**
124
124
 
125
- - fix link tag format [\#45](https://github.com/skywinder/Github-Changelog-Generator/pull/45) ([sugamasao](https://github.com/sugamasao))
125
+ - fix link tag format [\#45](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/45) ([sugamasao](https://github.com/sugamasao))
126
126
 
127
- ## [1.2.5](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.5) (2015-01-15)
127
+ ## [1.2.5](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.2.5) (2015-01-15)
128
128
 
129
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.4...1.2.5)
129
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.2.4...1.2.5)
130
130
 
131
131
  **Implemented enhancements:**
132
132
 
133
- - Use milestone to specify in which version bug was fixed [\#22](https://github.com/skywinder/Github-Changelog-Generator/issues/22)
133
+ - Use milestone to specify in which version bug was fixed [\#22](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/22)
134
134
 
135
135
  **Fixed bugs:**
136
136
 
137
- - Error when trying to generate log for repo without tags [\#32](https://github.com/skywinder/Github-Changelog-Generator/issues/32)
137
+ - Error when trying to generate log for repo without tags [\#32](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/32)
138
138
 
139
139
  **Merged pull requests:**
140
140
 
141
- - PrettyPrint class is included using lowercase 'pp' [\#43](https://github.com/skywinder/Github-Changelog-Generator/pull/43) ([schwing](https://github.com/schwing))
141
+ - PrettyPrint class is included using lowercase 'pp' [\#43](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/43) ([schwing](https://github.com/schwing))
142
142
 
143
- - support enterprise github via command line options [\#42](https://github.com/skywinder/Github-Changelog-Generator/pull/42) ([glenlovett](https://github.com/glenlovett))
143
+ - support enterprise github via command line options [\#42](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/42) ([glenlovett](https://github.com/glenlovett))
144
144
 
145
- ## [1.2.4](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.4) (2014-12-16)
145
+ ## [1.2.4](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.2.4) (2014-12-16)
146
146
 
147
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.3...1.2.4)
147
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.2.3...1.2.4)
148
148
 
149
149
  **Fixed bugs:**
150
150
 
151
- - Sometimes user is NULL during merges [\#41](https://github.com/skywinder/Github-Changelog-Generator/issues/41)
151
+ - Sometimes user is NULL during merges [\#41](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/41)
152
152
 
153
- - Crash when try generate log for rails [\#35](https://github.com/skywinder/Github-Changelog-Generator/issues/35)
153
+ - Crash when try generate log for rails [\#35](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/35)
154
154
 
155
- ## [1.2.3](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.3) (2014-12-16)
155
+ ## [1.2.3](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.2.3) (2014-12-16)
156
156
 
157
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.2...1.2.3)
157
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.2.2...1.2.3)
158
158
 
159
159
  **Implemented enhancements:**
160
160
 
161
- - Add ability to run with one parameter instead -u -p [\#38](https://github.com/skywinder/Github-Changelog-Generator/issues/38)
161
+ - Add ability to run with one parameter instead -u -p [\#38](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/38)
162
162
 
163
- - Detailed output [\#33](https://github.com/skywinder/Github-Changelog-Generator/issues/33)
163
+ - Detailed output [\#33](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/33)
164
164
 
165
165
  **Fixed bugs:**
166
166
 
167
- - Docs lacking or basic behavior not as advertised [\#30](https://github.com/skywinder/Github-Changelog-Generator/issues/30)
167
+ - Docs lacking or basic behavior not as advertised [\#30](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/30)
168
168
 
169
169
  **Merged pull requests:**
170
170
 
171
- - Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
171
+ - Implement async fetching [\#39](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/39) ([github-changelog-generator](https://github.com/github-changelog-generator))
172
172
 
173
- - Fix crash when user is NULL [\#40](https://github.com/skywinder/Github-Changelog-Generator/pull/40) ([skywinder](https://github.com/skywinder))
173
+ - Fix crash when user is NULL [\#40](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/40) ([github-changelog-generator](https://github.com/github-changelog-generator))
174
174
 
175
- ## [1.2.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2) (2014-12-10)
175
+ ## [1.2.2](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.2.2) (2014-12-10)
176
176
 
177
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.1...1.2.2)
177
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.2.1...1.2.2)
178
178
 
179
179
  **Fixed bugs:**
180
180
 
181
- - Encapsulate \[ \> \* \_ \ \] signs in issues names [\#34](https://github.com/skywinder/Github-Changelog-Generator/issues/34)
181
+ - Encapsulate \[ \> \* \_ \ \] signs in issues names [\#34](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/34)
182
182
 
183
183
  **Merged pull requests:**
184
184
 
185
- - Add a Bitdeli Badge to README [\#36](https://github.com/skywinder/Github-Changelog-Generator/pull/36) ([bitdeli-chef](https://github.com/bitdeli-chef))
185
+ - Add a Bitdeli Badge to README [\#36](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/36) ([bitdeli-chef](https://github.com/bitdeli-chef))
186
186
 
187
- ## [1.2.1](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.1) (2014-11-22)
187
+ ## [1.2.1](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.2.1) (2014-11-22)
188
188
 
189
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.0...1.2.1)
189
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.2.0...1.2.1)
190
190
 
191
191
  **Fixed bugs:**
192
192
 
193
- - Script fills changelog only for first 30 tags. [\#20](https://github.com/skywinder/Github-Changelog-Generator/issues/20)
193
+ - Script fills changelog only for first 30 tags. [\#20](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/20)
194
194
 
195
195
  **Merged pull requests:**
196
196
 
197
- - Issues for last tag not in list [\#29](https://github.com/skywinder/Github-Changelog-Generator/pull/29) ([skywinder](https://github.com/skywinder))
197
+ - Issues for last tag not in list [\#29](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/29) ([github-changelog-generator](https://github.com/github-changelog-generator))
198
198
 
199
- - Disable default --filter-pull-requests option. [\#28](https://github.com/skywinder/Github-Changelog-Generator/pull/28) ([skywinder](https://github.com/skywinder))
199
+ - Disable default --filter-pull-requests option. [\#28](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/28) ([github-changelog-generator](https://github.com/github-changelog-generator))
200
200
 
201
- ## [1.2.0](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.0) (2014-11-19)
201
+ ## [1.2.0](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.2.0) (2014-11-19)
202
202
 
203
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.1.4...1.2.0)
203
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.1.4...1.2.0)
204
204
 
205
205
  **Merged pull requests:**
206
206
 
207
- - Add filter for pull-requests labels. \(option --filter-pull-requests\) [\#27](https://github.com/skywinder/Github-Changelog-Generator/pull/27) ([skywinder](https://github.com/skywinder))
207
+ - Add filter for pull-requests labels. \(option --filter-pull-requests\) [\#27](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/27) ([github-changelog-generator](https://github.com/github-changelog-generator))
208
208
 
209
- - Add ability to insert authors of pull-requests \(--\[no-\]author option\) [\#25](https://github.com/skywinder/Github-Changelog-Generator/pull/25) ([skywinder](https://github.com/skywinder))
209
+ - Add ability to insert authors of pull-requests \(--\[no-\]author option\) [\#25](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/25) ([github-changelog-generator](https://github.com/github-changelog-generator))
210
210
 
211
- - Don't receive issues in case of --no-isses flag specied [\#24](https://github.com/skywinder/Github-Changelog-Generator/pull/24) ([skywinder](https://github.com/skywinder))
211
+ - Don't receive issues in case of --no-isses flag specied [\#24](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/24) ([github-changelog-generator](https://github.com/github-changelog-generator))
212
212
 
213
- ## [1.1.4](https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.4) (2014-11-18)
213
+ ## [1.1.4](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.1.4) (2014-11-18)
214
214
 
215
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.1.2...1.1.4)
215
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.1.2...1.1.4)
216
216
 
217
217
  **Implemented enhancements:**
218
218
 
219
- - Implement ability to retrieve GitHub token from ENV variable \(to not put it to script directly\) [\#19](https://github.com/skywinder/Github-Changelog-Generator/issues/19)
219
+ - Implement ability to retrieve GitHub token from ENV variable \(to not put it to script directly\) [\#19](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/19)
220
220
 
221
221
  **Merged pull requests:**
222
222
 
223
- - Sort tags by date [\#23](https://github.com/skywinder/Github-Changelog-Generator/pull/23) ([skywinder](https://github.com/skywinder))
223
+ - Sort tags by date [\#23](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/23) ([github-changelog-generator](https://github.com/github-changelog-generator))
224
224
 
225
- ## [1.1.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.2) (2014-11-12)
225
+ ## [1.1.2](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.1.2) (2014-11-12)
226
226
 
227
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.1.1...1.1.2)
227
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.1.1...1.1.2)
228
228
 
229
229
  **Merged pull requests:**
230
230
 
231
- - Fix bug with dot signs in project name [\#18](https://github.com/skywinder/Github-Changelog-Generator/pull/18) ([skywinder](https://github.com/skywinder))
231
+ - Fix bug with dot signs in project name [\#18](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/18) ([github-changelog-generator](https://github.com/github-changelog-generator))
232
232
 
233
- - Fix bug with dot signs in user name [\#17](https://github.com/skywinder/Github-Changelog-Generator/pull/17) ([skywinder](https://github.com/skywinder))
233
+ - Fix bug with dot signs in user name [\#17](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/17) ([github-changelog-generator](https://github.com/github-changelog-generator))
234
234
 
235
- ## [1.1.1](https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.1) (2014-11-10)
235
+ ## [1.1.1](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.1.1) (2014-11-10)
236
236
 
237
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.1.0...1.1.1)
237
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.1.0...1.1.1)
238
238
 
239
239
  **Merged pull requests:**
240
240
 
241
- - Remove duplicates of issues and pull-requests with same number [\#15](https://github.com/skywinder/Github-Changelog-Generator/pull/15) ([skywinder](https://github.com/skywinder))
241
+ - Remove duplicates of issues and pull-requests with same number [\#15](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/15) ([github-changelog-generator](https://github.com/github-changelog-generator))
242
242
 
243
- - Sort issues by tags [\#14](https://github.com/skywinder/Github-Changelog-Generator/pull/14) ([skywinder](https://github.com/skywinder))
243
+ - Sort issues by tags [\#14](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/14) ([github-changelog-generator](https://github.com/github-changelog-generator))
244
244
 
245
- - Add ability to add or exclude issues without any labels [\#13](https://github.com/skywinder/Github-Changelog-Generator/pull/13) ([skywinder](https://github.com/skywinder))
245
+ - Add ability to add or exclude issues without any labels [\#13](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/13) ([github-changelog-generator](https://github.com/github-changelog-generator))
246
246
 
247
- ## [1.1.0](https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.0) (2014-11-10)
247
+ ## [1.1.0](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.1.0) (2014-11-10)
248
248
 
249
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.0.1...1.1.0)
249
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.0.1...1.1.0)
250
250
 
251
251
  **Implemented enhancements:**
252
252
 
253
- - Detect username and project form origin [\#11](https://github.com/skywinder/Github-Changelog-Generator/issues/11)
253
+ - Detect username and project form origin [\#11](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/11)
254
254
 
255
255
  **Fixed bugs:**
256
256
 
257
- - Bug with wrong credentials in 1.0.1 [\#12](https://github.com/skywinder/Github-Changelog-Generator/issues/12)
257
+ - Bug with wrong credentials in 1.0.1 [\#12](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/12)
258
258
 
259
- - Markdown formating in the last line wrong [\#9](https://github.com/skywinder/Github-Changelog-Generator/issues/9)
259
+ - Markdown formating in the last line wrong [\#9](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/9)
260
260
 
261
- ## [1.0.1](https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.1) (2014-11-10)
261
+ ## [1.0.1](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.0.1) (2014-11-10)
262
262
 
263
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.0.0...1.0.1)
263
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/1.0.0...1.0.1)
264
264
 
265
- ## [1.0.0](https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.0) (2014-11-07)
265
+ ## [1.0.0](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.0.0) (2014-11-07)
266
266
 
267
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.1.0...1.0.0)
267
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/0.1.0...1.0.0)
268
268
 
269
269
  **Implemented enhancements:**
270
270
 
271
- - Add support for fixed issues and implemented enchanments. [\#6](https://github.com/skywinder/Github-Changelog-Generator/issues/6)
271
+ - Add support for fixed issues and implemented enchanments. [\#6](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/6)
272
272
 
273
- - Implement option to specify output filename [\#4](https://github.com/skywinder/Github-Changelog-Generator/issues/4)
273
+ - Implement option to specify output filename [\#4](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/4)
274
274
 
275
275
  **Fixed bugs:**
276
276
 
277
- - Last tag not appeared in changelog [\#5](https://github.com/skywinder/Github-Changelog-Generator/issues/5)
277
+ - Last tag not appeared in changelog [\#5](https://github.com/github-changelog-generator/Github-Changelog-Generator/issues/5)
278
278
 
279
279
  **Merged pull requests:**
280
280
 
281
- - Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8) ([skywinder](https://github.com/skywinder))
281
+ - Implement support of different tags. [\#8](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/8) ([github-changelog-generator](https://github.com/github-changelog-generator))
282
282
 
283
- - Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7) ([skywinder](https://github.com/skywinder))
283
+ - Add support for issues in CHANGELOG [\#7](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/7) ([github-changelog-generator](https://github.com/github-changelog-generator))
284
284
 
285
- ## [0.1.0](https://github.com/skywinder/Github-Changelog-Generator/tree/0.1.0) (2014-11-07)
285
+ ## [0.1.0](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/0.1.0) (2014-11-07)
286
286
 
287
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.0.2...0.1.0)
287
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/0.0.2...0.1.0)
288
288
 
289
289
  **Merged pull requests:**
290
290
 
291
- - Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3) ([skywinder](https://github.com/skywinder))
291
+ - Fix parsing date of pull request [\#3](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/3) ([github-changelog-generator](https://github.com/github-changelog-generator))
292
292
 
293
- - Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2) ([skywinder](https://github.com/skywinder))
293
+ - Add changelog generation for last tag [\#2](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/2) ([github-changelog-generator](https://github.com/github-changelog-generator))
294
294
 
295
- - Add option \(-o --output\) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1) ([skywinder](https://github.com/skywinder))
295
+ - Add option \(-o --output\) to specify name of the output file. [\#1](https://github.com/github-changelog-generator/Github-Changelog-Generator/pull/1) ([github-changelog-generator](https://github.com/github-changelog-generator))
296
296
 
297
- ## [0.0.2](https://github.com/skywinder/Github-Changelog-Generator/tree/0.0.2) (2014-11-06)
297
+ ## [0.0.2](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/0.0.2) (2014-11-06)
298
298
 
299
- [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.0.1...0.0.2)
299
+ [Full Changelog](https://github.com/github-changelog-generator/Github-Changelog-Generator/compare/0.0.1...0.0.2)
300
300
 
301
- ## [0.0.1](https://github.com/skywinder/Github-Changelog-Generator/tree/0.0.1) (2014-11-06)
301
+ ## [0.0.1](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/0.0.1) (2014-11-06)
302
302
 
303
303
 
304
304
 
305
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
305
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/Github-Changelog-Generator)*
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gem "github_changelog_generator", path: Dir.glob("../pkg/github_changelog_generator-*.gem")[0]
@@ -18,7 +18,6 @@
18
18
  # limitations under the License.
19
19
  #
20
20
  require "simplecov"
21
- require "coveralls"
22
21
  require "vcr"
23
22
  require "webmock/rspec"
24
23
 
@@ -26,10 +25,7 @@ require "webmock/rspec"
26
25
  module SpecHelper
27
26
  end
28
27
 
29
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
30
- Coveralls::SimpleCov::Formatter,
31
- SimpleCov::Formatter::HTMLFormatter
32
- ])
28
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
33
29
  SimpleCov.start do
34
30
  add_filter "gemfiles/"
35
31
  end
@@ -0,0 +1,760 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/ModuleLength
4
+ module GitHubChangelogGenerator
5
+ RSpec.describe Entry do
6
+ def label(name)
7
+ { "name" => name }
8
+ end
9
+
10
+ def issue(title, labels, body = "", number = "1", user = { "login" => "user" })
11
+ {
12
+ "title" => "issue #{title}",
13
+ "labels" => labels.map { |l| label(l) },
14
+ "number" => number,
15
+ "html_url" => "https://github.com/owner/repo/issue/#{number}",
16
+ "user" => user,
17
+ "body" => body,
18
+ "events" => [{
19
+ "event" => "closed"
20
+ }]
21
+ }
22
+ end
23
+
24
+ def pr(title, labels, body = "", number = "1", user = { "login" => "user" })
25
+ {
26
+ "pull_request" => true,
27
+ "title" => "pr #{title}",
28
+ "labels" => labels.map { |l| label(l) },
29
+ "number" => number,
30
+ "html_url" => "https://github.com/owner/repo/pull/#{number}",
31
+ "user" => user.merge("html_url" => "https://github.com/#{user['login']}"),
32
+ "body" => body,
33
+ "merged_at" => Time.now.utc,
34
+ "events" => [{
35
+ "event" => "merged",
36
+ "commit_id" => "aaaaa#{number}"
37
+ }]
38
+ }
39
+ end
40
+
41
+ def tag(name, sha, shas_in_tag)
42
+ {
43
+ "name" => name,
44
+ "commit" => { "sha" => sha },
45
+ "shas_in_tag" => shas_in_tag
46
+ }
47
+ end
48
+
49
+ def titles_for(issues)
50
+ issues.map { |issue| issue["title"] }
51
+ end
52
+
53
+ def default_sections
54
+ %w[breaking enhancements bugs deprecated removed security issues]
55
+ end
56
+
57
+ # Default to no issues, PRs, or tags.
58
+ let(:issues) { [] }
59
+ let(:pull_requests) { [] }
60
+ let(:tags) { [] }
61
+ let(:compare_shas) do
62
+ { "aaaaa1...master" => ["aaaaa1"] }
63
+ end
64
+
65
+ # Default to standard options minus verbose to avoid output during testing.
66
+ let(:options) do
67
+ Parser.default_options.merge(verbose: false)
68
+ end
69
+
70
+ # Mock out fake github fetching for the issues/pull_requests lets and then
71
+ # expose filtering from the GitHubChangelogGenerator::Generator class
72
+ # instance for end-to-end entry testing.
73
+ let(:generator) do
74
+ fake_fetcher = instance_double(
75
+ "fetcher",
76
+ fetch_closed_issues_and_pr: [issues, pull_requests],
77
+ fetch_closed_pull_requests: [],
78
+ fetch_events_async: issues + pull_requests,
79
+ fetch_tag_shas_async: nil,
80
+ fetch_comments_async: nil,
81
+ default_branch: "master",
82
+ oldest_commit: { "sha" => "aaaaa1" },
83
+ fetch_commit: { "commit" => { "author" => { "date" => Time.now.utc } } }
84
+ )
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 } } }
88
+ end
89
+ allow(GitHubChangelogGenerator::OctoFetcher).to receive(:new).and_return(fake_fetcher)
90
+ generator = GitHubChangelogGenerator::Generator.new(options)
91
+ generator.instance_variable_set :@sorted_tags, tags
92
+ generator.send(:fetch_issues_and_pr)
93
+ generator
94
+ end
95
+ let(:filtered_issues) do
96
+ generator.instance_variable_get :@issues
97
+ end
98
+ let(:filtered_pull_requests) do
99
+ generator.instance_variable_get :@pull_requests
100
+ end
101
+ let(:entry_sections) do
102
+ subject.send(:create_sections)
103
+ # In normal usage, the entry generation would have received filtered
104
+ # issues and pull requests so replicate that here for ease of testing.
105
+ subject.send(:sort_into_sections, filtered_pull_requests, filtered_issues)
106
+ subject.instance_variable_get :@sections
107
+ end
108
+
109
+ describe "#generate_entry_for_tag" do
110
+ let(:issues) do
111
+ [
112
+ issue("no labels", [], "", "5", "login" => "user1"),
113
+ issue("breaking", ["breaking"], "", "8", "login" => "user5"),
114
+ issue("enhancement", ["enhancement"], "", "6", "login" => "user2"),
115
+ issue("bug", ["bug"], "", "7", "login" => "user1"),
116
+ issue("deprecated", ["deprecated"], "", "13", "login" => "user5"),
117
+ issue("removed", ["removed"], "", "14", "login" => "user2"),
118
+ issue("security", ["security"], "", "15", "login" => "user5"),
119
+ issue("all the labels", %w[breaking enhancement bug deprecated removed security], "", "9", "login" => "user9"),
120
+ issue("all the labels different order", %w[bug breaking enhancement security removed deprecated], "", "10", "login" => "user5"),
121
+ issue("some unmapped labels", %w[tests-fail bug], "", "11", "login" => "user5"),
122
+ issue("no mapped labels", %w[docs maintenance], "", "12", "login" => "user5")
123
+ ]
124
+ end
125
+
126
+ let(:pull_requests) do
127
+ [
128
+ pr("no labels", [], "", "20", "login" => "user1"),
129
+ pr("breaking", ["breaking"], "", "23", "login" => "user5"),
130
+ pr("enhancement", ["enhancement"], "", "21", "login" => "user5"),
131
+ pr("bug", ["bug"], "", "22", "login" => "user5"),
132
+ pr("deprecated", ["deprecated"], "", "28", "login" => "user5"),
133
+ pr("removed", ["removed"], "", "29", "login" => "user2"),
134
+ pr("security", ["security"], "", "30", "login" => "user5"),
135
+ pr("all the labels", %w[breaking enhancement bug deprecated removed security], "", "24", "login" => "user5"),
136
+ pr("all the labels different order", %w[bug breaking enhancement security remove deprecated], "", "25", "login" => "user5"),
137
+ pr("some unmapped labels", %w[tests-fail bug], "", "26", "login" => "user5"),
138
+ pr("no mapped labels", %w[docs maintenance], "", "27", "login" => "user5")
139
+ ]
140
+ end
141
+
142
+ let(:tags) do
143
+ [tag("1.0.0", "aaaaa30", (1..30).collect { |i| "aaaaa#{i}" })]
144
+ end
145
+
146
+ subject { described_class.new(options) }
147
+ describe "include issues without labels" do
148
+ let(:options) do
149
+ Parser.default_options.merge(
150
+ user: "owner",
151
+ project: "repo",
152
+ breaking_labels: ["breaking"],
153
+ enhancement_labels: ["enhancement"],
154
+ bug_labels: ["bug"],
155
+ deprecated_labels: ["deprecated"],
156
+ removed_labels: ["removed"],
157
+ security_labels: ["security"],
158
+ verbose: false
159
+ )
160
+ end
161
+
162
+ it "generates a header and body" do
163
+ changelog = <<-CHANGELOG.gsub(/^ {10}/, "")
164
+ ## [1.0.1](https://github.com/owner/repo/tree/1.0.1) (2017-12-04)
165
+
166
+ [Full Changelog](https://github.com/owner/repo/compare/1.0.0...1.0.1)
167
+
168
+ **Breaking changes:**
169
+
170
+ - issue breaking [\\#8](https://github.com/owner/repo/issue/8)
171
+ - issue all the labels [\\#9](https://github.com/owner/repo/issue/9)
172
+ - issue all the labels different order [\\#10](https://github.com/owner/repo/issue/10)
173
+ - pr breaking [\\#23](https://github.com/owner/repo/pull/23) ([user5](https://github.com/user5))
174
+ - pr all the labels [\\#24](https://github.com/owner/repo/pull/24) ([user5](https://github.com/user5))
175
+ - pr all the labels different order [\\#25](https://github.com/owner/repo/pull/25) ([user5](https://github.com/user5))
176
+
177
+ **Implemented enhancements:**
178
+
179
+ - issue enhancement [\\#6](https://github.com/owner/repo/issue/6)
180
+ - pr enhancement [\\#21](https://github.com/owner/repo/pull/21) ([user5](https://github.com/user5))
181
+
182
+ **Fixed bugs:**
183
+
184
+ - issue bug [\\#7](https://github.com/owner/repo/issue/7)
185
+ - issue some unmapped labels [\\#11](https://github.com/owner/repo/issue/11)
186
+ - pr bug [\\#22](https://github.com/owner/repo/pull/22) ([user5](https://github.com/user5))
187
+ - pr some unmapped labels [\\#26](https://github.com/owner/repo/pull/26) ([user5](https://github.com/user5))
188
+
189
+ **Deprecated:**
190
+
191
+ - issue deprecated [\\#13](https://github.com/owner/repo/issue/13)
192
+ - pr deprecated [\\#28](https://github.com/owner/repo/pull/28) ([user5](https://github.com/user5))
193
+
194
+ **Removed:**
195
+
196
+ - issue removed [\\#14](https://github.com/owner/repo/issue/14)
197
+ - pr removed [\\#29](https://github.com/owner/repo/pull/29) ([user2](https://github.com/user2))
198
+
199
+ **Security fixes:**
200
+
201
+ - issue security [\\#15](https://github.com/owner/repo/issue/15)
202
+ - pr security [\\#30](https://github.com/owner/repo/pull/30) ([user5](https://github.com/user5))
203
+
204
+ **Closed issues:**
205
+
206
+ - issue no labels [\\#5](https://github.com/owner/repo/issue/5)
207
+ - issue no mapped labels [\\#12](https://github.com/owner/repo/issue/12)
208
+
209
+ **Merged pull requests:**
210
+
211
+ - pr no labels [\\#20](https://github.com/owner/repo/pull/20) ([user1](https://github.com/user1))
212
+ - pr no mapped labels [\\#27](https://github.com/owner/repo/pull/27) ([user5](https://github.com/user5))
213
+
214
+ CHANGELOG
215
+
216
+ expect(subject.generate_entry_for_tag(pull_requests, issues, "1.0.1", "1.0.1", Time.new(2017, 12, 4, 12, 0, 0, "+00:00").utc, "1.0.0")).to eq(changelog)
217
+ end
218
+ end
219
+
220
+ describe "#create_entry_for_tag_with_body" do
221
+ let(:options) do
222
+ Parser.default_options.merge(
223
+ user: "owner",
224
+ project: "repo",
225
+ bug_labels: ["bug"],
226
+ enhancement_labels: ["enhancement"],
227
+ breaking_labels: ["breaking"],
228
+ issue_line_body: true
229
+ )
230
+ end
231
+
232
+ let(:issues_with_body) do
233
+ [
234
+ issue("no labels", [], "Issue body description", "5", "login" => "user1"),
235
+ issue("breaking", ["breaking"], "Issue body description very long: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.", "8", "login" => "user5"),
236
+ issue("enhancement", ["enhancement"], "Issue body description", "6", "login" => "user2"),
237
+ issue("bug", ["bug"], "Issue body description", "7", "login" => "user1"),
238
+ issue("deprecated", ["deprecated"], "Issue body description", "13", "login" => "user5"),
239
+ issue("removed", ["removed"], "Issue body description", "14", "login" => "user2"),
240
+ issue("security", ["security"], "Issue body description", "15", "login" => "user5"),
241
+ issue("all the labels", %w[breaking enhancement bug deprecated removed security], "Issue body description. \nThis part should not appear.", "9", "login" => "user9"),
242
+ issue("all the labels different order", %w[bug breaking enhancement security removed deprecated], "Issue body description", "10", "login" => "user5"),
243
+ issue("some unmapped labels", %w[tests-fail bug], "Issue body description", "11", "login" => "user5"),
244
+ issue("no mapped labels", %w[docs maintenance], "Issue body description", "12", "login" => "user5")
245
+ ]
246
+ end
247
+
248
+ let(:pull_requests_with_body) do
249
+ [
250
+ pr("no labels", [], "PR body description", "20", "login" => "user1"),
251
+ pr("breaking", ["breaking"], "PR body description very long: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.", "23", "login" => "user5"),
252
+ pr("enhancement", ["enhancement"], "PR body description", "21", "login" => "user5"),
253
+ pr("bug", ["bug"], "PR body description", "22", "login" => "user5"),
254
+ pr("deprecated", ["deprecated"], "PR body description", "28", "login" => "user5"),
255
+ pr("removed", ["removed"], "PR body description", "29", "login" => "user2"),
256
+ pr("security", ["security"], "PR body description", "30", "login" => "user5"),
257
+ pr("all the labels", %w[breaking enhancement bug deprecated removed security], "PR body description. \nThis part should not appear", "24", "login" => "user5"),
258
+ pr("all the labels different order", %w[bug breaking enhancement security remove deprecated], "PR body description", "25", "login" => "user5"),
259
+ pr("some unmapped labels", %w[tests-fail bug], "PR body description", "26", "login" => "user5"),
260
+ pr("no mapped labels", %w[docs maintenance], "PR body description", "27", "login" => "user5")
261
+ ]
262
+ end
263
+
264
+ subject { described_class.new(options) }
265
+ it "generates issues and pull requests with body" do
266
+ changelog = <<-CHANGELOG.gsub(/^ {10}/, "")
267
+ ## [1.0.1](https://github.com/owner/repo/tree/1.0.1) (2017-12-04)
268
+
269
+ [Full Changelog](https://github.com/owner/repo/compare/1.0.0...1.0.1)
270
+
271
+ **Breaking changes:**
272
+
273
+ - **issue breaking [\\#8](https://github.com/owner/repo/issue/8)** \nIssue body description very long: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.
274
+ - **issue all the labels [\\#9](https://github.com/owner/repo/issue/9)** \nIssue body description.
275
+ - **issue all the labels different order [\\#10](https://github.com/owner/repo/issue/10)** \nIssue body description
276
+ - **pr breaking [\\#23](https://github.com/owner/repo/pull/23) ([user5](https://github.com/user5))** \nPR body description very long: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.
277
+ - **pr all the labels [\\#24](https://github.com/owner/repo/pull/24) ([user5](https://github.com/user5))** \nPR body description.
278
+ - **pr all the labels different order [\\#25](https://github.com/owner/repo/pull/25) ([user5](https://github.com/user5))** \nPR body description
279
+
280
+ **Implemented enhancements:**
281
+
282
+ - **issue enhancement [\\#6](https://github.com/owner/repo/issue/6)** \nIssue body description
283
+ - **pr enhancement [\\#21](https://github.com/owner/repo/pull/21) ([user5](https://github.com/user5))** \nPR body description
284
+
285
+ **Fixed bugs:**
286
+
287
+ - **issue bug [\\#7](https://github.com/owner/repo/issue/7)** \nIssue body description
288
+ - **issue some unmapped labels [\\#11](https://github.com/owner/repo/issue/11)** \nIssue body description
289
+ - **pr bug [\\#22](https://github.com/owner/repo/pull/22) ([user5](https://github.com/user5))** \nPR body description
290
+ - **pr some unmapped labels [\\#26](https://github.com/owner/repo/pull/26) ([user5](https://github.com/user5))** \nPR body description
291
+
292
+ **Deprecated:**
293
+
294
+ - **issue deprecated [\\#13](https://github.com/owner/repo/issue/13)** \nIssue body description
295
+ - **pr deprecated [\\#28](https://github.com/owner/repo/pull/28) ([user5](https://github.com/user5))** \nPR body description
296
+
297
+ **Removed:**
298
+
299
+ - **issue removed [\\#14](https://github.com/owner/repo/issue/14)** \nIssue body description
300
+ - **pr removed [\\#29](https://github.com/owner/repo/pull/29) ([user2](https://github.com/user2))** \nPR body description
301
+
302
+ **Security fixes:**
303
+
304
+ - **issue security [\\#15](https://github.com/owner/repo/issue/15)** \nIssue body description
305
+ - **pr security [\\#30](https://github.com/owner/repo/pull/30) ([user5](https://github.com/user5))** \nPR body description
306
+
307
+ **Closed issues:**
308
+
309
+ - **issue no labels [\\#5](https://github.com/owner/repo/issue/5)** \nIssue body description
310
+ - **issue no mapped labels [\\#12](https://github.com/owner/repo/issue/12)** \nIssue body description
311
+
312
+ **Merged pull requests:**
313
+
314
+ - **pr no labels [\\#20](https://github.com/owner/repo/pull/20) ([user1](https://github.com/user1))** \nPR body description
315
+ - **pr no mapped labels [\\#27](https://github.com/owner/repo/pull/27) ([user5](https://github.com/user5))** \nPR body description
316
+
317
+ CHANGELOG
318
+ expect(subject.generate_entry_for_tag(pull_requests_with_body, issues_with_body, "1.0.1", "1.0.1", Time.new(2017, 12, 4, 12, 0, 0, "+00:00").utc, "1.0.0")).to eq(changelog)
319
+ end
320
+ end
321
+
322
+ describe "exclude issues without labels" do
323
+ let(:options) do
324
+ Parser.default_options.merge(
325
+ user: "owner",
326
+ project: "repo",
327
+ breaking_labels: ["breaking"],
328
+ enhancement_labels: ["enhancement"],
329
+ bug_labels: ["bug"],
330
+ deprecated_labels: ["deprecated"],
331
+ removed_labels: ["removed"],
332
+ security_labels: ["security"],
333
+ add_pr_wo_labels: false,
334
+ add_issues_wo_labels: false,
335
+ verbose: false
336
+ )
337
+ end
338
+
339
+ it "generates a header and body" do
340
+ changelog = <<-CHANGELOG.gsub(/^ {10}/, "")
341
+ ## [1.0.1](https://github.com/owner/repo/tree/1.0.1) (2017-12-04)
342
+
343
+ [Full Changelog](https://github.com/owner/repo/compare/1.0.0...1.0.1)
344
+
345
+ **Breaking changes:**
346
+
347
+ - issue breaking [\\#8](https://github.com/owner/repo/issue/8)
348
+ - issue all the labels [\\#9](https://github.com/owner/repo/issue/9)
349
+ - issue all the labels different order [\\#10](https://github.com/owner/repo/issue/10)
350
+ - pr breaking [\\#23](https://github.com/owner/repo/pull/23) ([user5](https://github.com/user5))
351
+ - pr all the labels [\\#24](https://github.com/owner/repo/pull/24) ([user5](https://github.com/user5))
352
+ - pr all the labels different order [\\#25](https://github.com/owner/repo/pull/25) ([user5](https://github.com/user5))
353
+
354
+ **Implemented enhancements:**
355
+
356
+ - issue enhancement [\\#6](https://github.com/owner/repo/issue/6)
357
+ - pr enhancement [\\#21](https://github.com/owner/repo/pull/21) ([user5](https://github.com/user5))
358
+
359
+ **Fixed bugs:**
360
+
361
+ - issue bug [\\#7](https://github.com/owner/repo/issue/7)
362
+ - issue some unmapped labels [\\#11](https://github.com/owner/repo/issue/11)
363
+ - pr bug [\\#22](https://github.com/owner/repo/pull/22) ([user5](https://github.com/user5))
364
+ - pr some unmapped labels [\\#26](https://github.com/owner/repo/pull/26) ([user5](https://github.com/user5))
365
+
366
+ **Deprecated:**
367
+
368
+ - issue deprecated [\\#13](https://github.com/owner/repo/issue/13)
369
+ - pr deprecated [\\#28](https://github.com/owner/repo/pull/28) ([user5](https://github.com/user5))
370
+
371
+ **Removed:**
372
+
373
+ - issue removed [\\#14](https://github.com/owner/repo/issue/14)
374
+ - pr removed [\\#29](https://github.com/owner/repo/pull/29) ([user2](https://github.com/user2))
375
+
376
+ **Security fixes:**
377
+
378
+ - issue security [\\#15](https://github.com/owner/repo/issue/15)
379
+ - pr security [\\#30](https://github.com/owner/repo/pull/30) ([user5](https://github.com/user5))
380
+
381
+ **Closed issues:**
382
+
383
+ - issue no mapped labels [\\#12](https://github.com/owner/repo/issue/12)
384
+
385
+ **Merged pull requests:**
386
+
387
+ - pr no mapped labels [\\#27](https://github.com/owner/repo/pull/27) ([user5](https://github.com/user5))
388
+
389
+ CHANGELOG
390
+
391
+ expect(subject.generate_entry_for_tag(pull_requests, issues, "1.0.1", "1.0.1", Time.new(2017, 12, 4, 12, 0, 0, "+00:00").utc, "1.0.0")).to eq(changelog)
392
+ end
393
+ end
394
+ end
395
+ describe "#parse_sections" do
396
+ before do
397
+ subject { described_class.new }
398
+ end
399
+ context "valid json" do
400
+ let(:sections_string) { "{ \"foo\": { \"prefix\": \"foofix\", \"labels\": [\"test1\", \"test2\"]}, \"bar\": { \"prefix\": \"barfix\", \"labels\": [\"test3\", \"test4\"]}}" }
401
+
402
+ let(:sections_array) do
403
+ [
404
+ Section.new(name: "foo", prefix: "foofix", labels: %w[test1 test2]),
405
+ Section.new(name: "bar", prefix: "barfix", labels: %w[test3 test4])
406
+ ]
407
+ end
408
+
409
+ it "returns an array with 2 objects" do
410
+ arr = subject.send(:parse_sections, sections_string)
411
+ expect(arr.size).to eq 2
412
+ arr.each { |section| expect(section).to be_an_instance_of Section }
413
+ end
414
+
415
+ it "returns correctly constructed sections" do
416
+ require "json"
417
+
418
+ sections_json = JSON.parse(sections_string)
419
+ sections_array.each_index do |i|
420
+ aggregate_failures "checks each component" do
421
+ expect(sections_array[i].name).to eq sections_json.first[0]
422
+ expect(sections_array[i].prefix).to eq sections_json.first[1]["prefix"]
423
+ expect(sections_array[i].labels).to eq sections_json.first[1]["labels"]
424
+ expect(sections_array[i].issues).to eq []
425
+ end
426
+ sections_json.shift
427
+ end
428
+ end
429
+ end
430
+ context "hash" do
431
+ let(:sections_hash) do
432
+ {
433
+ breaking: {
434
+ prefix: "**Breaking**",
435
+ labels: ["breaking"]
436
+ },
437
+ enhancements: {
438
+ prefix: "**Enhancements**",
439
+ labels: %w[feature enhancement]
440
+ },
441
+ bugs: {
442
+ prefix: "**Bugs**",
443
+ labels: ["bug"]
444
+ },
445
+ deprecated: {
446
+ prefix: "**Deprecated**",
447
+ labels: ["deprecated"]
448
+ },
449
+ removed: {
450
+ prefix: "**Removed**",
451
+ labels: ["removed"]
452
+ },
453
+ security: {
454
+ prefix: "**Security**",
455
+ labels: ["security"]
456
+ }
457
+ }
458
+ end
459
+
460
+ let(:sections_array) do
461
+ [
462
+ Section.new(name: "breaking", prefix: "**Breaking**", labels: ["breaking"]),
463
+ Section.new(name: "enhancements", prefix: "**Enhancements**", labels: %w[feature enhancement]),
464
+ Section.new(name: "bugs", prefix: "**Bugs**", labels: ["bug"]),
465
+ Section.new(name: "deprecated", prefix: "**Deprecated**", labels: ["deprecated"]),
466
+ Section.new(name: "removed", prefix: "**Removed**", labels: ["removed"]),
467
+ Section.new(name: "security", prefix: "**Security**", labels: ["security"])
468
+ ]
469
+ end
470
+
471
+ it "returns an array with 6 objects" do
472
+ arr = subject.send(:parse_sections, sections_hash)
473
+ expect(arr.size).to eq 6
474
+ arr.each { |section| expect(section).to be_an_instance_of Section }
475
+ end
476
+
477
+ it "returns correctly constructed sections" do
478
+ sections_array.each_index do |i|
479
+ aggregate_failures "checks each component" do
480
+ expect(sections_array[i].name).to eq sections_hash.first[0].to_s
481
+ expect(sections_array[i].prefix).to eq sections_hash.first[1][:prefix]
482
+ expect(sections_array[i].labels).to eq sections_hash.first[1][:labels]
483
+ expect(sections_array[i].issues).to eq []
484
+ end
485
+ sections_hash.shift
486
+ end
487
+ end
488
+ end
489
+ end
490
+
491
+ describe "#sort_into_sections" do
492
+ context "default sections" do
493
+ let(:options) do
494
+ Parser.default_options.merge(
495
+ breaking_labels: ["breaking"],
496
+ enhancement_labels: ["enhancement"],
497
+ bug_labels: ["bug"],
498
+ deprecated_labels: ["deprecated"],
499
+ removed_labels: ["removed"],
500
+ security_labels: ["security"],
501
+ verbose: false
502
+ )
503
+ end
504
+
505
+ let(:issues) do
506
+ [
507
+ issue("breaking", ["breaking"]),
508
+ issue("no labels", []),
509
+ issue("enhancement", ["enhancement"]),
510
+ issue("bug", ["bug"]),
511
+ issue("deprecated", ["deprecated"]),
512
+ issue("removed", ["removed"]),
513
+ issue("security", ["security"]),
514
+ issue("all the labels", %w[breaking enhancement bug deprecated removed security]),
515
+ issue("some unmapped labels", %w[tests-fail bug]),
516
+ issue("no mapped labels", %w[docs maintenance]),
517
+ issue("excluded label", %w[wontfix]),
518
+ issue("excluded and included label", %w[breaking wontfix])
519
+ ]
520
+ end
521
+
522
+ let(:pull_requests) do
523
+ [
524
+ pr("no labels", []),
525
+ pr("breaking", ["breaking"]),
526
+ pr("enhancement", ["enhancement"]),
527
+ pr("bug", ["bug"]),
528
+ pr("deprecated", ["deprecated"]),
529
+ pr("removed", ["removed"]),
530
+ pr("security", ["security"]),
531
+ pr("all the labels", %w[breaking enhancement bug deprecated removed security]),
532
+ pr("some unmapped labels", %w[tests-fail bug]),
533
+ pr("no mapped labels", %w[docs maintenance]),
534
+ pr("excluded label", %w[wontfix]),
535
+ pr("excluded and included label", %w[breaking wontfix])
536
+ ]
537
+ end
538
+
539
+ subject { described_class.new(options) }
540
+
541
+ it "returns 9 sections" do
542
+ entry_sections.each { |sec| pp(sec.name) }
543
+ expect(entry_sections.size).to eq 9
544
+ end
545
+
546
+ it "returns default sections" do
547
+ default_sections.each { |default_section| expect(entry_sections.count { |section| section.name == default_section }).to eq 1 }
548
+ end
549
+
550
+ 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]
559
+
560
+ expect(titles_for(breaking_section.issues)).to eq(["issue breaking", "issue all the labels", "pr breaking", "pr all the labels"])
561
+ expect(titles_for(enhancement_section.issues)).to eq(["issue enhancement", "pr enhancement"])
562
+ expect(titles_for(bug_section.issues)).to eq(["issue bug", "issue some unmapped labels", "pr bug", "pr some unmapped labels"])
563
+ expect(titles_for(deprecated_section.issues)).to eq(["issue deprecated", "pr deprecated"])
564
+ expect(titles_for(removed_section.issues)).to eq(["issue removed", "pr removed"])
565
+ expect(titles_for(security_section.issues)).to eq(["issue security", "pr security"])
566
+ expect(titles_for(issue_section.issues)).to eq(["issue no labels", "issue no mapped labels"])
567
+ expect(titles_for(merged_section.issues)).to eq(["pr no labels", "pr no mapped labels"])
568
+ end
569
+ end
570
+ context "configure sections and include labels" do
571
+ let(:options) do
572
+ Parser.default_options.merge(
573
+ configure_sections: "{ \"foo\": { \"prefix\": \"foofix\", \"labels\": [\"test1\", \"test2\"]}, \"bar\": { \"prefix\": \"barfix\", \"labels\": [\"test3\", \"test4\"]}}",
574
+ include_labels: %w[test1 test2 test3 test4],
575
+ verbose: false
576
+ )
577
+ end
578
+
579
+ let(:issues) do
580
+ [
581
+ issue("no labels", []),
582
+ issue("test1", ["test1"]),
583
+ issue("test3", ["test3"]),
584
+ issue("test4", ["test4"]),
585
+ issue("all the labels", %w[test4 test2 test3 test1]),
586
+ issue("some included labels", %w[unincluded test2]),
587
+ issue("no included labels", %w[unincluded again])
588
+ ]
589
+ end
590
+
591
+ let(:pull_requests) do
592
+ [
593
+ pr("no labels", []),
594
+ pr("test1", ["test1"]),
595
+ pr("test3", ["test3"]),
596
+ pr("test4", ["test4"]),
597
+ pr("all the labels", %w[test4 test2 test3 test1]),
598
+ pr("some included labels", %w[unincluded test2]),
599
+ pr("no included labels", %w[unincluded again])
600
+ ]
601
+ end
602
+
603
+ subject { described_class.new(options) }
604
+
605
+ it "returns 4 sections" do
606
+ expect(entry_sections.size).to eq 4
607
+ end
608
+
609
+ it "returns only configured sections" do
610
+ expect(entry_sections.count { |section| section.name == "foo" }).to eq 1
611
+ expect(entry_sections.count { |section| section.name == "bar" }).to eq 1
612
+ end
613
+
614
+ 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]
619
+
620
+ aggregate_failures "checks all sections" do
621
+ 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"])
622
+ expect(titles_for(bar_section.issues)).to eq(["issue test3", "issue test4", "pr test3", "pr test4"])
623
+ expect(titles_for(merged_section.issues)).to eq(["pr no labels"])
624
+ expect(titles_for(issue_section.issues)).to eq(["issue no labels"])
625
+ end
626
+ end
627
+ end
628
+ context "configure sections and exclude labels" do
629
+ let(:options) do
630
+ Parser.default_options.merge(
631
+ configure_sections: "{ \"foo\": { \"prefix\": \"foofix\", \"labels\": [\"test1\", \"test2\"]}, \"bar\": { \"prefix\": \"barfix\", \"labels\": [\"test3\", \"test4\"]}}",
632
+ exclude_labels: ["excluded"],
633
+ verbose: false
634
+ )
635
+ end
636
+
637
+ let(:issues) do
638
+ [
639
+ issue("no labels", []),
640
+ issue("test1", ["test1"]),
641
+ issue("test3", ["test3"]),
642
+ issue("test4", ["test4"]),
643
+ issue("all the labels", %w[test4 test2 test3 test1]),
644
+ issue("some excluded labels", %w[excluded test2]),
645
+ issue("excluded labels", %w[excluded again])
646
+ ]
647
+ end
648
+
649
+ let(:pull_requests) do
650
+ [
651
+ pr("no labels", []),
652
+ pr("test1", ["test1"]),
653
+ pr("test3", ["test3"]),
654
+ pr("test4", ["test4"]),
655
+ pr("all the labels", %w[test4 test2 test3 test1]),
656
+ pr("some excluded labels", %w[excluded test2]),
657
+ pr("excluded labels", %w[excluded again])
658
+ ]
659
+ end
660
+
661
+ subject { described_class.new(options) }
662
+
663
+ it "returns 4 sections" do
664
+ expect(entry_sections.size).to eq 4
665
+ end
666
+
667
+ it "returns only configured sections" do
668
+ expect(entry_sections.count { |section| section.name == "foo" }).to eq 1
669
+ expect(entry_sections.count { |section| section.name == "bar" }).to eq 1
670
+ end
671
+
672
+ 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]
677
+
678
+ aggregate_failures "checks all sections" do
679
+ expect(titles_for(foo_section.issues)).to eq(["issue test1", "issue all the labels", "pr test1", "pr all the labels"])
680
+ expect(titles_for(bar_section.issues)).to eq(["issue test3", "issue test4", "pr test3", "pr test4"])
681
+ expect(titles_for(merged_section.issues)).to eq(["pr no labels"])
682
+ expect(titles_for(issue_section.issues)).to eq(["issue no labels"])
683
+ end
684
+ end
685
+ end
686
+ context "add sections" do
687
+ let(:options) do
688
+ Parser.default_options.merge(
689
+ breaking_labels: ["breaking"],
690
+ enhancement_labels: ["enhancement"],
691
+ bug_labels: ["bug"],
692
+ deprecated_labels: ["deprecated"],
693
+ removed_labels: ["removed"],
694
+ security_labels: ["security"],
695
+ add_sections: "{ \"foo\": { \"prefix\": \"foofix\", \"labels\": [\"test1\", \"test2\"]}}",
696
+ verbose: false
697
+ )
698
+ end
699
+
700
+ let(:issues) do
701
+ [
702
+ issue("no labels", []),
703
+ issue("test1", ["test1"]),
704
+ issue("bugaboo", ["bug"]),
705
+ issue("all the labels", %w[test1 test2 breaking enhancement bug deprecated removed security]),
706
+ issue("default labels first", %w[enhancement bug test1 test2]),
707
+ issue("some excluded labels", %w[wontfix breaking]),
708
+ issue("excluded labels", %w[wontfix again])
709
+ ]
710
+ end
711
+
712
+ let(:pull_requests) do
713
+ [
714
+ pr("no labels", []),
715
+ pr("test1", ["test1"]),
716
+ pr("enhance", ["enhancement"]),
717
+ pr("all the labels", %w[test1 test2 breaking enhancement bug deprecated removed security]),
718
+ pr("default labels first", %w[enhancement bug test1 test2]),
719
+ pr("some excluded labels", %w[wontfix breaking]),
720
+ pr("excluded labels", %w[wontfix again])
721
+ ]
722
+ end
723
+
724
+ subject { described_class.new(options) }
725
+
726
+ it "returns 10 sections" do
727
+ entry_sections.each { |sec| pp(sec.name) }
728
+ expect(entry_sections.size).to eq 10
729
+ end
730
+
731
+ it "returns default sections" do
732
+ default_sections.each { |default_section| expect(entry_sections.count { |section| section.name == default_section }).to eq 1 }
733
+ end
734
+
735
+ it "returns added section" do
736
+ expect(entry_sections.count { |section| section.name == "foo" }).to eq 1
737
+ end
738
+
739
+ 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]
746
+
747
+ aggregate_failures "checks all sections" do
748
+ expect(titles_for(breaking_section.issues)).to eq(["issue all the labels", "pr all the labels"])
749
+ expect(titles_for(enhancement_section.issues)).to eq(["issue default labels first", "pr enhance", "pr default labels first"])
750
+ expect(titles_for(bug_section.issues)).to eq(["issue bugaboo"])
751
+ expect(titles_for(foo_section.issues)).to eq(["issue test1", "pr test1"])
752
+ expect(titles_for(issue_section.issues)).to eq(["issue no labels"])
753
+ expect(titles_for(merged_section.issues)).to eq(["pr no labels"])
754
+ end
755
+ end
756
+ end
757
+ end
758
+ end
759
+ end
760
+ # rubocop:enable Metrics/ModuleLength