px_github_changelog_generator 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +9 -0
  3. data/README.md +357 -0
  4. data/Rakefile +19 -0
  5. data/bin/git-generate-changelog +5 -0
  6. data/bin/github_changelog_generator +5 -0
  7. data/lib/github_changelog_generator/argv_parser.rb +225 -0
  8. data/lib/github_changelog_generator/file_parser_chooser.rb +27 -0
  9. data/lib/github_changelog_generator/generator/entry.rb +218 -0
  10. data/lib/github_changelog_generator/generator/generator.rb +177 -0
  11. data/lib/github_changelog_generator/generator/generator_fetcher.rb +202 -0
  12. data/lib/github_changelog_generator/generator/generator_processor.rb +237 -0
  13. data/lib/github_changelog_generator/generator/generator_tags.rb +210 -0
  14. data/lib/github_changelog_generator/generator/section.rb +129 -0
  15. data/lib/github_changelog_generator/helper.rb +37 -0
  16. data/lib/github_changelog_generator/octo_fetcher.rb +535 -0
  17. data/lib/github_changelog_generator/options.rb +159 -0
  18. data/lib/github_changelog_generator/parser.rb +89 -0
  19. data/lib/github_changelog_generator/parser_file.rb +101 -0
  20. data/lib/github_changelog_generator/reader.rb +88 -0
  21. data/lib/github_changelog_generator/ssl_certs/cacert.pem +3138 -0
  22. data/lib/github_changelog_generator/task.rb +68 -0
  23. data/lib/github_changelog_generator/version.rb +5 -0
  24. data/lib/github_changelog_generator.rb +49 -0
  25. data/man/git-generate-changelog.1 +393 -0
  26. data/man/git-generate-changelog.1.html +359 -0
  27. data/man/git-generate-changelog.html +270 -0
  28. data/man/git-generate-changelog.md +274 -0
  29. data/spec/files/angular.js.md +9395 -0
  30. data/spec/files/bundler.md +1911 -0
  31. data/spec/files/config_example +5 -0
  32. data/spec/files/github-changelog-generator.md +305 -0
  33. data/spec/github_changelog_generator_spec.rb +32 -0
  34. data/spec/install_gem_in_bundler.gemfile +5 -0
  35. data/spec/spec_helper.rb +74 -0
  36. data/spec/unit/generator/entry_spec.rb +766 -0
  37. data/spec/unit/generator/generator_processor_spec.rb +203 -0
  38. data/spec/unit/generator/generator_spec.rb +47 -0
  39. data/spec/unit/generator/generator_tags_spec.rb +337 -0
  40. data/spec/unit/generator/section_spec.rb +43 -0
  41. data/spec/unit/octo_fetcher_spec.rb +590 -0
  42. data/spec/unit/options_spec.rb +67 -0
  43. data/spec/unit/parser_file_spec.rb +94 -0
  44. data/spec/unit/parser_spec.rb +54 -0
  45. data/spec/unit/reader_spec.rb +120 -0
  46. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_commits/when_API_is_valid/returns_commits.json +1 -0
  47. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_commits_before/when_API_is_valid/returns_commits.json +1 -0
  48. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issue_with_proper_key/values.json +1 -0
  49. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issues.json +1 -0
  50. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issues_with_labels.json +1 -0
  51. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_pull_request_with_proper_key/values.json +1 -0
  52. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_pull_requests_with_labels.json +1 -0
  53. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid.json +1 -0
  54. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid/returns_correct_pull_request_keys.json +1 -0
  55. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid/returns_pull_requests.json +1 -0
  56. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid.json +1 -0
  57. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_commit/when_API_call_is_valid/returns_commit.json +1 -0
  58. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_commit/when_API_call_is_valid.json +1 -0
  59. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_date_of_tag/when_API_call_is_valid/returns_date.json +1 -0
  60. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_date_of_tag/when_API_call_is_valid.json +1 -0
  61. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_events_async/when_API_call_is_valid/populates_issues.json +1 -0
  62. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_events_async/when_API_call_is_valid.json +1 -0
  63. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid/should_return_tags.json +1 -0
  64. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid/should_return_tags_count.json +1 -0
  65. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid.json +1 -0
  66. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_wrong_token_provided/should_raise_Unauthorized_error.json +1 -0
  67. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_wrong_token_provided.json +1 -0
  68. metadata +250 -0
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake"
4
+ require "rake/tasklib"
5
+ require "github_changelog_generator"
6
+
7
+ module GitHubChangelogGenerator
8
+ class RakeTask < ::Rake::TaskLib
9
+ include ::Rake::DSL if defined?(::Rake::DSL)
10
+
11
+ OPTIONS = %w[ user project token date_format output
12
+ bug_prefix enhancement_prefix issue_prefix
13
+ header merge_prefix issues
14
+ add_issues_wo_labels add_pr_wo_labels
15
+ pulls filter_issues_by_milestone author
16
+ unreleased_only unreleased unreleased_label
17
+ compare_link include_labels exclude_labels
18
+ bug_labels enhancement_labels include_tags_regex
19
+ between_tags exclude_tags exclude_tags_regex since_tag max_issues
20
+ github_site github_endpoint simple_list
21
+ future_release release_branch verbose release_url
22
+ base configure_sections add_sections http_cache]
23
+
24
+ OPTIONS.each do |o|
25
+ attr_accessor o.to_sym
26
+ end
27
+
28
+ # Public: Initialise a new GitHubChangelogGenerator::RakeTask.
29
+ #
30
+ # Example
31
+ #
32
+ # GitHubChangelogGenerator::RakeTask.new
33
+ def initialize(*args, &task_block)
34
+ super()
35
+ @name = args.shift || :changelog
36
+
37
+ define(args, &task_block)
38
+ end
39
+
40
+ def define(args, &task_block)
41
+ desc "Generate a Changelog from GitHub"
42
+
43
+ yield(*[self, args].slice(0, task_block.arity)) if task_block
44
+
45
+ # clear any (auto-)pre-existing task
46
+ Rake::Task[@name].clear if Rake::Task.task_defined?(@name)
47
+
48
+ task @name do
49
+ # mimick parse_options
50
+ options = Parser.default_options
51
+
52
+ OPTIONS.each do |o|
53
+ v = instance_variable_get("@#{o}")
54
+ options[o.to_sym] = v unless v.nil?
55
+ end
56
+ abort "user and project are required." unless options[:user] && options[:project]
57
+ generator = Generator.new options
58
+
59
+ log = generator.compound_changelog
60
+
61
+ output_filename = (options[:output]).to_s
62
+ File.open(output_filename, "w") { |file| file.write(log) }
63
+ puts "Done!"
64
+ puts "Generated log placed in #{File.absolute_path(output_filename)}"
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHubChangelogGenerator
4
+ VERSION = "1.16.4"
5
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "octokit"
4
+ require "faraday-http-cache"
5
+ require "logger"
6
+ require "active_support"
7
+ require "active_support/core_ext/object/blank"
8
+ require "json"
9
+ require "benchmark"
10
+
11
+ require "github_changelog_generator/helper"
12
+ require "github_changelog_generator/options"
13
+ require "github_changelog_generator/parser"
14
+ require "github_changelog_generator/parser_file"
15
+ require "github_changelog_generator/generator/generator"
16
+ require "github_changelog_generator/version"
17
+ require "github_changelog_generator/reader"
18
+
19
+ # The main module, where placed all classes (now, at least)
20
+ module GitHubChangelogGenerator
21
+ # Main class and entry point for this script.
22
+ class ChangelogGenerator
23
+ # Class, responsible for whole changelog generation cycle
24
+ # @return initialised instance of ChangelogGenerator
25
+ def initialize(params = ARGV)
26
+ @options = Parser.parse_options(params)
27
+ @generator = Generator.new(@options)
28
+ end
29
+
30
+ # The entry point of this script to generate changelog
31
+ # @raise (ChangelogGeneratorError) Is thrown when one of specified tags was not found in list of tags.
32
+ def run
33
+ log = generator.compound_changelog
34
+
35
+ if options.write_to_file?
36
+ output_filename = options[:output].to_s
37
+ File.open(output_filename, "wb") { |file| file.write(log) }
38
+ puts "Done!"
39
+ puts "Generated log placed in #{File.absolute_path(output_filename)}"
40
+ else
41
+ puts log
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ attr_reader :generator, :options
48
+ end
49
+ end
@@ -0,0 +1,393 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "GIT\-GENERATE\-CHANGELOG" "1" "May 2020" "" ""
5
+ .
6
+ .SH "NAME"
7
+ \fBgit\-generate\-changelog\fR \- Generate changelog from GitHub
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBgit generate\-changelog\fR [\-h|\-\-help] [\-u|\-\-user] [\-p|\-\-project]
11
+ .
12
+ .SH "DESCRIPTION"
13
+ Automatically generate changelog from your tags, issues, labels and pull requests on GitHub\.
14
+ .
15
+ .SH "OPTIONS"
16
+ \-u, \-\-user USER
17
+ .
18
+ .P
19
+ Username of the owner of target GitHub repo\.
20
+ .
21
+ .P
22
+ \-p, \-\-project PROJECT
23
+ .
24
+ .P
25
+ Name of project on GitHub\.
26
+ .
27
+ .P
28
+ \-t, \-\-token TOKEN
29
+ .
30
+ .P
31
+ To make more than 50 requests per hour your GitHub token is required\. You can generate it at: https://github\.com/settings/tokens/new
32
+ .
33
+ .P
34
+ \-f, \-\-date\-format FORMAT
35
+ .
36
+ .P
37
+ Date format\. Default is %Y\-%m\-%d\.
38
+ .
39
+ .P
40
+ \-o, \-\-output NAME
41
+ .
42
+ .P
43
+ Output file\. To print to STDOUT instead, use blank as path\. Default is CHANGELOG\.md\.
44
+ .
45
+ .P
46
+ \-b, \-\-base NAME
47
+ .
48
+ .P
49
+ Optional base file to append generated changes to\. Default is HISTORY\.md\.
50
+ .
51
+ .P
52
+ \-\-summary\-label LABEL
53
+ .
54
+ .P
55
+ Set up custom label for the release summary section\. Default is ""\.
56
+ .
57
+ .P
58
+ \-\-breaking\-label LABEL
59
+ .
60
+ .P
61
+ Set up custom label for breaking changes section\. Default is "\fBBreaking changes:\fR"\.
62
+ .
63
+ .P
64
+ \-\-enhancement\-label LABEL
65
+ .
66
+ .P
67
+ Set up custom label for enhancements section\. Default is "\fBImplemented enhancements:\fR"\.
68
+ .
69
+ .P
70
+ \-\-bugs\-label LABEL
71
+ .
72
+ .P
73
+ Set up custom label for bug\-fixes section\. Default is "\fBFixed bugs:\fR"\.
74
+ .
75
+ .P
76
+ \-\-deprecated\-label LABEL
77
+ .
78
+ .P
79
+ Set up custom label for deprecated section\. Default is "\fBDeprecated:\fR"\.
80
+ .
81
+ .P
82
+ \-\-removed\-label LABEL
83
+ .
84
+ .P
85
+ Set up custom label for removed section\. Default is "\fBRemoved:\fR"\.
86
+ .
87
+ .P
88
+ \-\-security\-label LABEL
89
+ .
90
+ .P
91
+ Set up custom label for security section\. Default is "\fBSecurity:\fR"\.
92
+ .
93
+ .P
94
+ \-\-issues\-label LABEL
95
+ .
96
+ .P
97
+ Set up custom label for closed\-issues section\. Default is "\fBClosed issues:\fR"\.
98
+ .
99
+ .P
100
+ \-\-header\-label LABEL
101
+ .
102
+ .P
103
+ Set up custom header label\. Default is "# Changelog"\.
104
+ .
105
+ .P
106
+ \-\-configure\-sections HASH, STRING
107
+ .
108
+ .P
109
+ Define your own set of sections which overrides all default sections\.
110
+ .
111
+ .P
112
+ \-\-add\-sections HASH, STRING
113
+ .
114
+ .P
115
+ Add new sections but keep the default sections\.
116
+ .
117
+ .P
118
+ \-\-front\-matter JSON
119
+ .
120
+ .P
121
+ Add YAML front matter\. Formatted as JSON because it\'s easier to add on the command line\.
122
+ .
123
+ .P
124
+ \-\-pr\-label LABEL
125
+ .
126
+ .P
127
+ Set up custom label for pull requests section\. Default is "\fBMerged pull requests:\fR"\.
128
+ .
129
+ .P
130
+ \-\-[no\-]issues
131
+ .
132
+ .P
133
+ Include closed issues in changelog\. Default is true\.
134
+ .
135
+ .P
136
+ \-\-[no\-]issues\-wo\-labels
137
+ .
138
+ .P
139
+ Include closed issues without labels in changelog\. Default is true\.
140
+ .
141
+ .P
142
+ \-\-[no\-]pr\-wo\-labels
143
+ .
144
+ .P
145
+ Include pull requests without labels in changelog\. Default is true\.
146
+ .
147
+ .P
148
+ \-\-[no\-]pull\-requests
149
+ .
150
+ .P
151
+ Include pull\-requests in changelog\. Default is true\.
152
+ .
153
+ .P
154
+ \-\-[no\-]filter\-by\-milestone
155
+ .
156
+ .P
157
+ Use milestone to detect when issue was resolved\. Default is true\.
158
+ .
159
+ .P
160
+ \-\-[no\-]issues\-of\-open\-milestones
161
+ .
162
+ .P
163
+ Include issues of open milestones\. Default is true\.
164
+ .
165
+ .P
166
+ \-\-[no\-]author
167
+ .
168
+ .P
169
+ Add author of pull request at the end\. Default is true\.
170
+ .
171
+ .P
172
+ \-\-usernames\-as\-github\-logins
173
+ .
174
+ .P
175
+ Use GitHub tags instead of Markdown links for the author of an issue or pull\-request\.
176
+ .
177
+ .P
178
+ \-\-unreleased\-only
179
+ .
180
+ .P
181
+ Generate log from unreleased closed issues only\.
182
+ .
183
+ .P
184
+ \-\-[no\-]unreleased
185
+ .
186
+ .P
187
+ Add to log unreleased closed issues\. Default is true\.
188
+ .
189
+ .P
190
+ \-\-unreleased\-label LABEL
191
+ .
192
+ .P
193
+ Set up custom label for unreleased closed issues section\. Default is "\fBUnreleased:\fR"\.
194
+ .
195
+ .P
196
+ \-\-[no\-]compare\-link
197
+ .
198
+ .P
199
+ Include compare link (Full Changelog) between older version and newer version\. Default is true\.
200
+ .
201
+ .P
202
+ \-\-include\-labels x,y,z
203
+ .
204
+ .P
205
+ Of the labeled issues, only include the ones with the specified labels\.
206
+ .
207
+ .P
208
+ \-\-exclude\-labels x,y,z
209
+ .
210
+ .P
211
+ Issues with the specified labels will be excluded from changelog\. Default is \'duplicate,question,invalid,wontfix\'\.
212
+ .
213
+ .P
214
+ \-\-summary\-labels x,y,z
215
+ .
216
+ .P
217
+ Issues with these labels will be added to a new section, called "Release Summary"\. The section display only body of issues\. Default is \'Release summary,release\-summary,Summary,summary\'\.
218
+ .
219
+ .P
220
+ \-\-breaking\-labels x,y,z
221
+ .
222
+ .P
223
+ Issues with these labels will be added to a new section, called "Breaking changes"\. Default is \'backwards\-incompatible,breaking\'\.
224
+ .
225
+ .P
226
+ \-\-enhancement\-labels x,y,z
227
+ .
228
+ .P
229
+ Issues with the specified labels will be added to "Implemented enhancements" section\. Default is \'enhancement,Enhancement\'\.
230
+ .
231
+ .P
232
+ \-\-bug\-labels x,y,z
233
+ .
234
+ .P
235
+ Issues with the specified labels will be added to "Fixed bugs" section\. Default is \'bug,Bug\'\.
236
+ .
237
+ .P
238
+ \-\-deprecated\-labels x,y,z
239
+ .
240
+ .P
241
+ Issues with the specified labels will be added to a section called "Deprecated"\. Default is \'deprecated,Deprecated\'\.
242
+ .
243
+ .P
244
+ \-\-removed\-labels x,y,z
245
+ .
246
+ .P
247
+ Issues with the specified labels will be added to a section called "Removed"\. Default is \'removed,Removed\'\.
248
+ .
249
+ .P
250
+ \-\-security\-labels x,y,z
251
+ .
252
+ .P
253
+ Issues with the specified labels will be added to a section called "Security fixes"\. Default is \'security,Security\'\.
254
+ .
255
+ .P
256
+ \-\-issue\-line\-labels x,y,z
257
+ .
258
+ .P
259
+ The specified labels will be shown in brackets next to each matching issue\. Use "ALL" to show all labels\. Default is []\.
260
+ .
261
+ .P
262
+ \-\-exclude\-tags x,y,z
263
+ .
264
+ .P
265
+ Changelog will exclude specified tags\.
266
+ .
267
+ .P
268
+ \-\-exclude\-tags\-regex REGEX
269
+ .
270
+ .P
271
+ Apply a regular expression on tag names so that they can be excluded, for example: \-\-exclude\-tags\-regex "\.*+\ed{1,}"\.
272
+ .
273
+ .P
274
+ \-\-since\-tag x
275
+ .
276
+ .P
277
+ Changelog will start after specified tag\.
278
+ .
279
+ .P
280
+ \-\-due\-tag x
281
+ .
282
+ .P
283
+ Changelog will end before specified tag\.
284
+ .
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
292
+ \-\-max\-issues NUMBER
293
+ .
294
+ .P
295
+ Maximum number of issues to fetch from GitHub\. Default is unlimited\.
296
+ .
297
+ .P
298
+ \-\-release\-url URL
299
+ .
300
+ .P
301
+ The URL to point to for release links, in printf format (with the tag as variable)\.
302
+ .
303
+ .P
304
+ \-\-github\-site URL
305
+ .
306
+ .P
307
+ The Enterprise GitHub site where your project is hosted\.
308
+ .
309
+ .P
310
+ \-\-github\-api URL
311
+ .
312
+ .P
313
+ The enterprise endpoint to use for your GitHub API\.
314
+ .
315
+ .P
316
+ \-\-simple\-list
317
+ .
318
+ .P
319
+ Create a simple list from issues and pull requests\. Default is false\.
320
+ .
321
+ .P
322
+ \-\-future\-release RELEASE\-VERSION
323
+ .
324
+ .P
325
+ Put the unreleased changes in the specified release number\.
326
+ .
327
+ .P
328
+ \-\-release\-branch RELEASE\-BRANCH
329
+ .
330
+ .P
331
+ Limit pull requests to the release branch, such as master or release\.
332
+ .
333
+ .P
334
+ \-\-http\-cache
335
+ .
336
+ .P
337
+ Use HTTP Cache to cache GitHub API requests (useful for large repos)\. Default is true\.
338
+ .
339
+ .P
340
+ \-\-[no\-]cache\-file CACHE\-FILE
341
+ .
342
+ .P
343
+ Filename to use for cache\. Default is github\-changelog\-http\-cache in a temporary directory\.
344
+ .
345
+ .P
346
+ \-\-cache\-log CACHE\-LOG
347
+ .
348
+ .P
349
+ Filename to use for cache log\. Default is github\-changelog\-logger\.log in a temporary directory\.
350
+ .
351
+ .P
352
+ \-\-ssl\-ca\-file PATH
353
+ .
354
+ .P
355
+ Path to cacert\.pem file\. Default is a bundled lib/github_changelog_generator/ssl_certs/cacert\.pem\. Respects SSL_CA_PATH\.
356
+ .
357
+ .P
358
+ \-\-require file1\.rb,file2\.rb
359
+ .
360
+ .P
361
+ Paths to Ruby file(s) to require before generating changelog\.
362
+ .
363
+ .P
364
+ \-\-[no\-]verbose
365
+ .
366
+ .P
367
+ Run verbosely\. Default is true\.
368
+ .
369
+ .P
370
+ \-v, \-\-version
371
+ .
372
+ .P
373
+ Print version number\.
374
+ .
375
+ .P
376
+ \-h, \-\-help
377
+ .
378
+ .P
379
+ Displays Help\.
380
+ .
381
+ .SH "REBASED COMMITS"
382
+ GitHub pull requests that have been merged whose merge commit SHA has been modified through rebasing, cherry picking, or some other method may be tracked via a special comment on GitHub\. Git commit SHAs found in comments on pull requests matching the regular expression \fB/rebased commit: ([0\-9a\-f]{40})/i\fR will be used in place of the original merge SHA when being added to the changelog\.
383
+ .
384
+ .SH "EXAMPLES"
385
+ .
386
+ .SH "AUTHOR"
387
+ Written by Petr Korolev sky4winder@gmail\.com
388
+ .
389
+ .SH "REPORTING BUGS"
390
+ <\fIhttps://github\.com/github\-changelog\-generator/github\-changelog\-generator/issues\fR>
391
+ .
392
+ .SH "SEE ALSO"
393
+ <\fIhttps://github\.com/github\-changelog\-generator/github\-changelog\-generator/\fR>