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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 164d299ce926e786c956f3722c6540b5432cfe518660dba8c990158099a50af6
4
+ data.tar.gz: 0d59370aced26cfd77d3d4f44f8735c54b5c32e1e30da99dadb18c2b253b5e2e
5
+ SHA512:
6
+ metadata.gz: 59d16a38808c170c5ac3b25ee01dc70d2ef541165c70de751836e96daa2719ccdc799dedcdb7b32c39759622e2d8b75e84bb06783adda8d9ca554e2bc0b2dc21
7
+ data.tar.gz: 8cd9cccdc60dc8dd7235f6811969b1e42e296d21307d1426417fbd419f5823d3d46c3ccc5828a265c62eb1bcf1da3d4fb4e45d20c72c3dc3ebd2ad250826aef0
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2016-2019 Petr Korolev
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
+
data/README.md ADDED
@@ -0,0 +1,357 @@
1
+ [![Gem Version](https://badge.fury.io/rb/github_changelog_generator.svg)](http://badge.fury.io/rb/github_changelog_generator)
2
+ [![CircleCI](https://circleci.com/gh/github-changelog-generator/github-changelog-generator.svg?style=svg)](https://circleci.com/gh/github-changelog-generator/github-changelog-generator)
3
+ [![Inline docs](http://inch-ci.org/github/github-changelog-generator/github-changelog-generator.svg)](http://inch-ci.org/github/github-changelog-generator/github-changelog-generator)
4
+ [![Join the chat at https://gitter.im/github-changelog-generator/chat](https://badges.gitter.im/github-changelog-generator/chat.svg)](https://gitter.im/github-changelog-generator/chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
+
6
+ # github-changelog-generator ![GitHub Logo](../master/images/logo.jpg)
7
+
8
+ <!--
9
+ To update TOC, please run:
10
+ > doctoc ./README.md --github
11
+ -->
12
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
13
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
14
+
15
+ - [Changelog generation has never been so easy](#changelog-generation-has-never-been-so-easy)
16
+ - [*What’s the point of a changelog?*](#whats-the-point-of-a-changelog)
17
+ - [*Why should I care?*](#why-should-i-care)
18
+ - [Installation](#installation)
19
+ - [Usage](#usage)
20
+ - [Running with CLI:](#running-with-cli)
21
+ - [Running with Docker](#running-with-docker)
22
+ - [Output example](#output-example)
23
+ - [Params](#params)
24
+ - [Params File](#params-file)
25
+ - [GitHub token](#github-token)
26
+ - [Migrating from a manual changelog](#migrating-from-a-manual-changelog)
27
+ - [Rake task](#rake-task)
28
+ - [Features and advantages of this project](#features-and-advantages-of-this-project)
29
+ - [Using the summary section feature](#using-the-summary-section-feature)
30
+ - [Alternatives](#alternatives)
31
+ - [Projects using this library](#projects-using-this-library)
32
+ - [Practical Use Cases](#practical-use-cases)
33
+ - [Creating GitHub Release Notes](#creating-github-release-notes)
34
+ - [Am I missing some essential feature?](#am-i-missing-some-essential-feature)
35
+ - [FAQ](#faq)
36
+ - [Contributing](#contributing)
37
+ - [Contact us](#contact-us)
38
+ - [License](#license)
39
+
40
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
41
+
42
+
43
+ ### Changelog generation has never been so easy
44
+
45
+ **Fully automated changelog generation** - This gem generates a changelog file based on **tags**, **issues** and merged **pull requests** (and splits them into separate lists according to labels) from :octocat: GitHub.
46
+
47
+ Since you don't have to fill your `CHANGELOG.md` manually now: just run the script, relax and take a cup of :coffee: before your next release! :tada:
48
+
49
+ ### *What’s the point of a changelog?*
50
+
51
+ To make it easier for users and contributors to see precisely what notable changes have been made between each release (or version) of the project.
52
+
53
+ ### *Why should I care?*
54
+
55
+ Because software tools are for _people_. "Changelogs make it easier for users and
56
+ contributors to see precisely what notable changes have been made between each
57
+ release (or version) of the project."
58
+
59
+ :arrow_right: *[https://keepachangelog.com](https://keepachangelog.com)*
60
+
61
+ ## Installation
62
+
63
+ GitHub Changelog Generator is a [Ruby](https://www.ruby-lang.org/)
64
+ program, distributed as a RubyGem. The Ruby language homepage has an [Installation page](https://www.ruby-lang.org/en/documentation/installation/).
65
+
66
+ Install the gem like:
67
+
68
+ $ gem install github_changelog_generator
69
+
70
+ Depending on your system, you _may_ need to run the shell as an Administrator (Windows),
71
+ or use `sudo gem install github_changelog_generator` (Linux).
72
+
73
+
74
+ ## Usage
75
+
76
+
77
+ ### Running with CLI:
78
+
79
+ github_changelog_generator -u github_project_namespace -p github_project
80
+
81
+ (where the project namespace is _likely_ your username if it's a project you own, but it could also be the namespace of the project)
82
+
83
+
84
+ ### Running with Docker
85
+
86
+ Using [Docker](https://www.docker.com/products/docker-desktop) is an alternative to installing Ruby and the gem.
87
+
88
+ Example invocation:
89
+
90
+ $ docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator
91
+
92
+
93
+
94
+ - For GitHub Enterprise repos, specify *both* `--github-site` and `--github-api` options:
95
+
96
+ $ github_changelog_generator --github-site="https://github.yoursite.com" \
97
+ --github-api="https://github.yoursite.com/api/v3/"
98
+
99
+
100
+ This generates a `CHANGELOG.md`, with pretty Markdown formatting.
101
+
102
+
103
+ ## Output example
104
+
105
+ - Look at **[CHANGELOG.md](https://github.com/github-changelog-generator/github-changelog-generator/blob/master/CHANGELOG.md)** for this project
106
+ - [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/develop/CHANGELOG.md) was generated by command:
107
+
108
+ $ github_changelog_generator -u github-changelog-generator -p ActionSheetPicker-3.0
109
+
110
+ - In general, it looks like this:
111
+
112
+ > ## [1.2.5](https://github.com/github-changelog-generator/github-changelog-generator/tree/1.2.5) (2015-01-15)
113
+ >
114
+ > [Full Changelog](https://github.com/github-changelog-generator/github-changelog-generator/compare/1.2.4...1.2.5)
115
+ >
116
+ > **Implemented enhancements:**
117
+ >
118
+ > - Use milestone to specify in which version bug was fixed [\#22](https://github.com/github-changelog-generator/github-changelog-generator/issues/22)
119
+ >
120
+ > **Fixed bugs:**
121
+ >
122
+ > - Error when trying to generate log for repo without tags [\#32](https://github.com/github-changelog-generator/github-changelog-generator/issues/32)
123
+ >
124
+ > **Merged pull requests:**
125
+ >
126
+ > - PrettyPrint class is included using lowercase 'pp' [\#43](https://github.com/github-changelog-generator/github-changelog-generator/pull/43) ([schwing](https://github.com/schwing))
127
+ >
128
+ > - support enterprise github via command line options [\#42](https://github.com/github-changelog-generator/github-changelog-generator/pull/42) ([glenlovett](https://github.com/glenlovett))
129
+
130
+ ### Params
131
+
132
+ Print help for all command-line options to learn more details:
133
+
134
+ $ github_changelog_generator --help
135
+
136
+ For more details about params, read the Wiki page: [**Advanced changelog generation examples**](https://github.com/github-changelog-generator/github-changelog-generator/wiki/Advanced-change-log-generation-examples)
137
+
138
+ ### Params File
139
+
140
+ In your project root, you can put a params file named `.github_changelog_generator` to override default params:
141
+
142
+ Example:
143
+
144
+ ```
145
+ unreleased=false
146
+ future-release=5.0.0
147
+ since-tag=1.0.0
148
+ ```
149
+
150
+ ### GitHub token
151
+
152
+ GitHub only allows **50 unauthenticated requests per hour**.
153
+
154
+ Therefore, it's recommended to run this script with authentication by using a **token**.
155
+
156
+ Here's how:
157
+
158
+ - [Generate a token here](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token) - you only need "repo" scope for private repositories
159
+ - Either:
160
+ - Run the script with `--token <your-40-digit-token>`; **OR**
161
+ - Set the `CHANGELOG_GITHUB_TOKEN` environment variable to your 40 digit token
162
+
163
+ You can set an environment variable by running the following command at the prompt, or by adding it to your shell profile (e.g., `.env`, `~/.bash_profile`, `~/.zshrc`, etc):
164
+
165
+ export CHANGELOG_GITHUB_TOKEN="«your-40-digit-github-token»"
166
+
167
+ So, if you get a message like this:
168
+
169
+ ``` markdown
170
+ API rate limit exceeded for github_username.
171
+ See: https://developer.github.com/v3/#rate-limiting
172
+ ```
173
+
174
+ It's time to create this token! (Or, wait an hour for GitHub to reset your unauthenticated request limit.)
175
+
176
+ ## Migrating from a manual changelog
177
+
178
+ Knowing how dedicated you are to your project, you probably haven't been waiting for `github-changelog-generator` to keep a changelog.
179
+ But you probably don't want your project's open issues and PRs for all past features listed in your historic changelog, either.
180
+
181
+ That's where `--base <your-manual-changelog.md>` comes in handy!
182
+ This option lets append your old manual changelog to the end of the generated entries.
183
+
184
+ If you have a `HISTORY.md` file in your project, it will automatically be picked as the static historical changelog and appended.
185
+
186
+ ### Rake task
187
+
188
+ You love `rake`? We do, too! So, we've made it even easier for you:
189
+ we've provided a `rake` task library for your changelog generation.
190
+
191
+ Configure the task in your `Rakefile`:
192
+
193
+ ```ruby
194
+ require 'github_changelog_generator/task'
195
+
196
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
197
+ config.user = 'username'
198
+ config.project = 'project-name'
199
+ config.since_tag = '0.1.14'
200
+ config.future_release = '0.2.0'
201
+ end
202
+ ```
203
+
204
+ All command-line options can be passed to the `rake` task as `config`
205
+ parameters. And since you're naming the `rake` task yourself, you can create
206
+ as many as you want.
207
+
208
+ You can look for params names from the [parser source code (#setup_parser)](https://github.com/github-changelog-generator/github-changelog-generator/blob/master/lib/github_changelog_generator/parser.rb). For example, to translate the bugs label to Portuguese, instead of setting `config.bugs_label`, you have to set `config.bug_prefix`, and so on.
209
+
210
+ ## Features and advantages of this project
211
+
212
+ - Generate canonical, neat changelog file, with default sections that follow [basic changelog guidelines](http://keepachangelog.com) :gem:
213
+ - Optionally generate **Unreleased** changes (closed issues that have not released yet) :dizzy:
214
+ - **GitHub Enterprise support** via command line options! :factory:
215
+ - Flexible format **customization**:
216
+ - **Customize** issues that **should be added** to changelog :eight_spoked_asterisk:
217
+ - **Custom date formats** supported (but keep [ISO 8601](http://xkcd.com/1179/) in mind!) :date:
218
+ - Manually specify the version that fixed an issue (for cases when the issue's Closed date doesn't match) by giving the issue's `milestone` the same name as the tag of version :pushpin:
219
+ - Automatically **exclude specific issues** that are irrelevant to your changelog (by default, any issue labeled `question`, `duplicate`, `invalid`, or `wontfix`) :scissors:
220
+ - **Distinguish** issues **by labels**. :mag_right:
221
+ - Merged pull requests (all merged pull-requests) :twisted_rightwards_arrows:
222
+ - Bug fixes (issues labeled `bug`) :beetle:
223
+ - Enhancements (issues labeled `enhancement`) :star2:
224
+ - Issues (closed issues with no labels) :non-potable_water:
225
+
226
+ - Manually include or exclude issues by labels :wrench:
227
+ - Customize lots more! Tweak the changelog to fit your preferences :tophat:
228
+ (*See `github_changelog_generator --help` for details)*
229
+
230
+ ### Using the summary section feature
231
+
232
+ For each version, you can add a _release summary_ with text, images, gif animations,
233
+ etc, and show new features and notes clearly to the user. This is done using GitHub metadata.
234
+
235
+ **Example**: adding the release summary for v1.0.0:
236
+
237
+ 1. Create a new GitHub Issue
238
+ 2. In the Issue's _Description_ field, add your release summary content
239
+ ```
240
+ ![image](https://user-images.githubusercontent.com/12690315/45935880-006a8200-bfeb-11e8-958e-ff742ae66b96.png)
241
+
242
+ Hello, World! :tada:
243
+ ```
244
+ 3. Set the Issue Label `release-summary` and add it to the GitHub Milestone `v1.0.0`
245
+ 4. Close the Issue and execute `github-changelog-generator`
246
+ 5. The result looks like this:
247
+ > ## [v1.0.0](https://github.com/github-changelog-generator/github-changelog-generator/tree/1.0.0) (2014-11-07)
248
+ > [Full Changelog](https://github.com/github-changelog-generator/github-changelog-generator/compare/0.1.0...1.0.0)
249
+ >
250
+ > ![image](https://user-images.githubusercontent.com/12690315/45935880-006a8200-bfeb-11e8-958e-ff742ae66b96.png)
251
+ >
252
+ > Hello, World! :tada:
253
+ >
254
+ > **Implemented enhancements:**
255
+ > - Add some features
256
+
257
+ ### Alternatives
258
+
259
+ Here is a [wikipage list of alternatives](https://github.com/github-changelog-generator/github-changelog-generator/wiki/Alternatives) that I found. But none satisfied my requirements.
260
+
261
+ *If you know other projects, feel free to edit this Wiki page!*
262
+
263
+
264
+ ### Projects using this library
265
+
266
+ Here's a [wikipage list of projects](https://github.com/github-changelog-generator/github-changelog-generator/wiki/Projects-using-GitHub-Changelog-Generator).
267
+
268
+ If you've used this project in a live app, please let me know! Nothing makes me happier than seeing someone else take my work and go wild with it.
269
+
270
+ *If you are using `github_changelog_generator` to generate your project's changelog, or know of other projects using it, please [add it to this list](https://github.com/github-changelog-generator/github-changelog-generator/wiki/Projects-using-GitHub-Changelog-Generator).*
271
+
272
+ ## Practical Use Cases
273
+
274
+ ### Creating GitHub Release Notes
275
+
276
+ `github_changelog_generator` can be used in combination with the [github cli](https://cli.github.com/) to create release notes. Use the `--since-tag` and `--output` options of `github_changelog_generator` to create a changelog for the current release and store the results in a file. In the
277
+ example below, version `2.0.0` is the current release and version `1.0.0` is the previous release.
278
+
279
+ ```
280
+ mkdir -p build
281
+ github_changelog_generator \
282
+ --since-tag 1.0.0 \
283
+ --output build/changelog.md
284
+ ```
285
+
286
+ Then use the [release create](https://cli.github.com/manual/gh_release_create) feature of the github cli to create a new github release
287
+
288
+ ```
289
+ gh release create 2.0.0 \
290
+ --notes-file build/changelog.md \
291
+ --title 2.0.0
292
+ ```
293
+
294
+ ## Am I missing some essential feature?
295
+
296
+ - **Nothing is impossible!**
297
+
298
+ - Open an [issue](https://github.com/github-changelog-generator/github-changelog-generator/issues/new/choose) and let's make the generator better together!
299
+
300
+ - *Bug reports, feature requests, patches, and well-wishes are always welcome.* :heavy_exclamation_mark:
301
+
302
+ ## FAQ
303
+
304
+ - ***I already use GitHub Releases. Why do I need this?***
305
+
306
+ GitHub Releases is a very good thing. And it's very good practice to maintain it. (Not a lot of people are using it yet!) :congratulations:
307
+
308
+ *BTW: I would like to support GitHub Releases in [next releases](https://github.com/github-changelog-generator/github-changelog-generator/issues/56) ;)*
309
+
310
+ I'm not trying to compare the quality of handwritten and auto-generated logs. That said....
311
+
312
+ An auto-generated changelog really helps, even if you manually fill in the release notes!
313
+
314
+
315
+ - ***My Ruby version is very old, can I use this?***
316
+
317
+ When your Ruby is old, and you don't want to upgrade, and you want to
318
+ control which libraries you use, you can use Bundler.
319
+
320
+ In a Gemfile, perhaps in a non-deployed `:development` group, add this
321
+ gem:
322
+
323
+ ```ruby
324
+ group :development do
325
+ gem 'github_changelog_generator', require: false
326
+ end
327
+ ```
328
+
329
+ Then you can keep back dependencies like rack, which currently is only
330
+ compatible with Ruby >= 2.2.2. So, use an older version for your app by
331
+ adding a line like this to the Gemfile:
332
+
333
+ ```
334
+ gem 'rack', '~> 1.6'
335
+ ```
336
+
337
+ This way, you can keep on using github_changelog_generator, even if you
338
+ can't get the latest version of Ruby installed.
339
+
340
+ - ***Windows: 1.14.x wants to create a file on an invalid path. Why?***
341
+
342
+ Windows: [v1.14.0 introduced a bug where it attempts to create /tmp/github_changelog-logger.log... which isn't a valid path on Windows and thus fails](https://github.com/github-changelog-generator/github-changelog-generator/issues/458)
343
+
344
+ Workaround: Create a `C:\tmp`.
345
+
346
+ ## Contributing
347
+
348
+ Would you like to contribute to this project? [CONTRIBUTING.md] has all the details on how to do that.
349
+
350
+ [CONTRIBUTING.md]: CONTRIBUTING.md
351
+
352
+ ## Contact us
353
+ [Join the chat at gitter : github-changelog-generator](https://gitter.im/github-changelog-generator/chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
354
+
355
+ ## License
356
+
357
+ GitHub Changelog Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler"
4
+ require "bundler/gem_tasks"
5
+ require "rubocop/rake_task"
6
+ require "rspec/core/rake_task"
7
+ require "pathname"
8
+ require "fileutils"
9
+ require "overcommit"
10
+
11
+ RuboCop::RakeTask.new
12
+ RSpec::Core::RakeTask.new
13
+
14
+ desc "When releasing the gem, re-fetch latest cacert.pem from curl.haxx.se. Developer task."
15
+ task :update_ssl_ca_file do
16
+ `pushd lib/github_changelog_generator/ssl_certs && curl --remote-name --time-cond cacert.pem https://curl.se/ca/cacert.pem && popd`
17
+ end
18
+
19
+ task default: %i[rubocop spec]
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/github_changelog_generator"
5
+ GitHubChangelogGenerator::ChangelogGenerator.new.run
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/github_changelog_generator"
5
+ GitHubChangelogGenerator::ChangelogGenerator.new.run
@@ -0,0 +1,225 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+ require "github_changelog_generator/version"
5
+
6
+ module GitHubChangelogGenerator
7
+ class ArgvParser
8
+ attr_reader :options
9
+
10
+ def initialize(options = {})
11
+ @options = options
12
+ end
13
+
14
+ def parse!(argv)
15
+ parser.parse(argv)
16
+ rescue OptionParser::ParseError => e
17
+ warn [e, parser].join("\n")
18
+ Kernel.abort
19
+ end
20
+
21
+ def parser
22
+ @parser ||= OptionParser.new do |opts| # rubocop:disable Metrics/BlockLength
23
+ opts.banner = "Usage: github_changelog_generator --user USER --project PROJECT [options]"
24
+ opts.on("-u", "--user USER", "Username of the owner of the target GitHub repo OR the namespace of target GitHub repo if owned by an organization.") do |last|
25
+ options[:user] = last
26
+ end
27
+ opts.on("-p", "--project PROJECT", "Name of project on GitHub.") do |last|
28
+ options[:project] = last
29
+ end
30
+ opts.on("-t", "--token TOKEN", "To make more than 50 requests per hour your GitHub token is required. You can generate it at: https://github.com/settings/tokens/new") do |last|
31
+ options[:token] = last
32
+ end
33
+ opts.on("-f", "--date-format FORMAT", "Date format. Default is %Y-%m-%d.") do |last|
34
+ options[:date_format] = last
35
+ end
36
+ opts.on("-o", "--output NAME", "Output file. To print to STDOUT instead, use blank as path. Default is CHANGELOG.md") do |last|
37
+ options[:output] = last
38
+ end
39
+ opts.on("-b", "--base NAME", "Optional base file to append generated changes to. Default is HISTORY.md") do |last|
40
+ options[:base] = last
41
+ end
42
+ opts.on("--summary-label LABEL", "Set up custom label for the release summary section. Default is \"\".") do |v|
43
+ options[:summary_prefix] = v
44
+ end
45
+ opts.on("--breaking-label LABEL", "Set up custom label for the breaking changes section. Default is \"**Breaking changes:**\".") do |v|
46
+ options[:breaking_prefix] = v
47
+ end
48
+ opts.on("--enhancement-label LABEL", "Set up custom label for enhancements section. Default is \"**Implemented enhancements:**\".") do |v|
49
+ options[:enhancement_prefix] = v
50
+ end
51
+ opts.on("--bugs-label LABEL", "Set up custom label for bug-fixes section. Default is \"**Fixed bugs:**\".") do |v|
52
+ options[:bug_prefix] = v
53
+ end
54
+ opts.on("--deprecated-label LABEL", "Set up custom label for the deprecated changes section. Default is \"**Deprecated:**\".") do |v|
55
+ options[:deprecated_prefix] = v
56
+ end
57
+ opts.on("--removed-label LABEL", "Set up custom label for the removed changes section. Default is \"**Removed:**\".") do |v|
58
+ options[:removed_prefix] = v
59
+ end
60
+ opts.on("--security-label LABEL", "Set up custom label for the security changes section. Default is \"**Security fixes:**\".") do |v|
61
+ options[:security_prefix] = v
62
+ end
63
+ opts.on("--issues-label LABEL", "Set up custom label for closed-issues section. Default is \"**Closed issues:**\".") do |v|
64
+ options[:issue_prefix] = v
65
+ end
66
+ opts.on("--header-label LABEL", "Set up custom header label. Default is \"# Changelog\".") do |v|
67
+ options[:header] = v
68
+ end
69
+ opts.on("--configure-sections HASH, STRING", "Define your own set of sections which overrides all default sections.") do |v|
70
+ options[:configure_sections] = v
71
+ end
72
+ opts.on("--add-sections HASH, STRING", "Add new sections but keep the default sections.") do |v|
73
+ options[:add_sections] = v
74
+ end
75
+ opts.on("--front-matter JSON", "Add YAML front matter. Formatted as JSON because it's easier to add on the command line.") do |v|
76
+ require "yaml"
77
+ options[:frontmatter] = "#{JSON.parse(v).to_yaml}---\n"
78
+ end
79
+ opts.on("--pr-label LABEL", "Set up custom label for pull requests section. Default is \"**Merged pull requests:**\".") do |v|
80
+ options[:merge_prefix] = v
81
+ end
82
+ opts.on("--[no-]issues", "Include closed issues in changelog. Default is true.") do |v|
83
+ options[:issues] = v
84
+ end
85
+ opts.on("--[no-]issues-wo-labels", "Include closed issues without labels in changelog. Default is true.") do |v|
86
+ options[:add_issues_wo_labels] = v
87
+ end
88
+ opts.on("--[no-]pr-wo-labels", "Include pull requests without labels in changelog. Default is true.") do |v|
89
+ options[:add_pr_wo_labels] = v
90
+ end
91
+ opts.on("--[no-]pull-requests", "Include pull-requests in changelog. Default is true.") do |v|
92
+ options[:pulls] = v
93
+ end
94
+ opts.on("--[no-]filter-by-milestone", "Use milestone to detect when issue was resolved. Default is true.") do |last|
95
+ options[:filter_issues_by_milestone] = last
96
+ end
97
+ opts.on("--[no-]issues-of-open-milestones", "Include issues of open milestones. Default is true.") do |v|
98
+ options[:issues_of_open_milestones] = v
99
+ end
100
+ opts.on("--[no-]author", "Add author of pull request at the end. Default is true.") do |author|
101
+ options[:author] = author
102
+ end
103
+ opts.on("--usernames-as-github-logins", "Use GitHub tags instead of Markdown links for the author of an issue or pull-request.") do |v|
104
+ options[:usernames_as_github_logins] = v
105
+ end
106
+ opts.on("--unreleased-only", "Generate log from unreleased closed issues only.") do |v|
107
+ options[:unreleased_only] = v
108
+ end
109
+ opts.on("--[no-]unreleased", "Add to log unreleased closed issues. Default is true.") do |v|
110
+ options[:unreleased] = v
111
+ end
112
+ opts.on("--unreleased-label LABEL", "Set up custom label for unreleased closed issues section. Default is \"**Unreleased:**\".") do |v|
113
+ options[:unreleased_label] = v
114
+ end
115
+ opts.on("--[no-]compare-link", "Include compare link (Full Changelog) between older version and newer version. Default is true.") do |v|
116
+ options[:compare_link] = v
117
+ end
118
+ opts.on("--include-labels x,y,z", Array, "Of the labeled issues, only include the ones with the specified labels.") do |list|
119
+ options[:include_labels] = list
120
+ end
121
+ opts.on("--exclude-labels x,y,z", Array, "Issues with the specified labels will be excluded from changelog. Default is 'duplicate,question,invalid,wontfix'.") do |list|
122
+ options[:exclude_labels] = list
123
+ end
124
+ opts.on("--summary-labels x,y,z", Array, '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,summary\'.') do |list|
125
+ options[:summary_labels] = list
126
+ end
127
+ opts.on("--breaking-labels x,y,z", Array, 'Issues with these labels will be added to a new section, called "Breaking changes". Default is \'backwards-incompatible,breaking\'.') do |list|
128
+ options[:breaking_labels] = list
129
+ end
130
+ opts.on("--enhancement-labels x,y,z", Array, 'Issues with the specified labels will be added to "Implemented enhancements" section. Default is \'enhancement,Enhancement\'.') do |list|
131
+ options[:enhancement_labels] = list
132
+ end
133
+ opts.on("--bug-labels x,y,z", Array, 'Issues with the specified labels will be added to "Fixed bugs" section. Default is \'bug,Bug\'.') do |list|
134
+ options[:bug_labels] = list
135
+ end
136
+ opts.on("--deprecated-labels x,y,z", Array, 'Issues with the specified labels will be added to a section called "Deprecated". Default is \'deprecated,Deprecated\'.') do |list|
137
+ options[:deprecated_labels] = list
138
+ end
139
+ opts.on("--removed-labels x,y,z", Array, 'Issues with the specified labels will be added to a section called "Removed". Default is \'removed,Removed\'.') do |list|
140
+ options[:removed_labels] = list
141
+ end
142
+ opts.on("--security-labels x,y,z", Array, 'Issues with the specified labels will be added to a section called "Security fixes". Default is \'security,Security\'.') do |list|
143
+ options[:security_labels] = list
144
+ end
145
+ opts.on("--issue-line-labels x,y,z", Array, 'The specified labels will be shown in brackets next to each matching issue. Use "ALL" to show all labels. Default is [].') do |list|
146
+ options[:issue_line_labels] = list
147
+ end
148
+ opts.on("--include-tags-regex REGEX", "Apply a regular expression on tag names so that they can be included, for example: --include-tags-regex \".*\+\d{1,}\".") do |last|
149
+ options[:include_tags_regex] = last
150
+ end
151
+ opts.on("--exclude-tags x,y,z", Array, "Changelog will exclude specified tags") do |list|
152
+ options[:exclude_tags] = list
153
+ end
154
+ opts.on("--exclude-tags-regex REGEX", "Apply a regular expression on tag names so that they can be excluded, for example: --exclude-tags-regex \".*\+\d{1,}\".") do |last|
155
+ options[:exclude_tags_regex] = last
156
+ end
157
+ opts.on("--since-tag x", "Changelog will start after specified tag.") do |v|
158
+ options[:since_tag] = v
159
+ end
160
+ opts.on("--due-tag x", "Changelog will end before specified tag.") do |v|
161
+ options[:due_tag] = v
162
+ end
163
+ opts.on("--since-commit x", "Fetch only commits after this time. eg. \"2017-01-01 10:00:00\"") do |v|
164
+ options[:since_commit] = v
165
+ end
166
+ opts.on("--max-issues NUMBER", Integer, "Maximum number of issues to fetch from GitHub. Default is unlimited.") do |max|
167
+ options[:max_issues] = max
168
+ end
169
+ opts.on("--release-url URL", "The URL to point to for release links, in printf format (with the tag as variable).") do |url|
170
+ options[:release_url] = url
171
+ end
172
+ opts.on("--github-site URL", "The Enterprise GitHub site where your project is hosted.") do |last|
173
+ options[:github_site] = last
174
+ end
175
+ opts.on("--github-api URL", "The enterprise endpoint to use for your GitHub API.") do |last|
176
+ options[:github_endpoint] = last
177
+ end
178
+ opts.on("--simple-list", "Create a simple list from issues and pull requests. Default is false.") do |v|
179
+ options[:simple_list] = v
180
+ end
181
+ opts.on("--future-release RELEASE-VERSION", "Put the unreleased changes in the specified release number.") do |future_release|
182
+ options[:future_release] = future_release
183
+ end
184
+ opts.on("--release-branch RELEASE-BRANCH", "Limit pull requests to the release branch, such as master or release.") do |release_branch|
185
+ options[:release_branch] = release_branch
186
+ end
187
+ opts.on("--[no-]http-cache", "Use HTTP Cache to cache GitHub API requests (useful for large repos). Default is true.") do |http_cache|
188
+ options[:http_cache] = http_cache
189
+ end
190
+ opts.on("--cache-file CACHE-FILE", "Filename to use for cache. Default is github-changelog-http-cache in a temporary directory.") do |cache_file|
191
+ options[:cache_file] = cache_file
192
+ end
193
+ opts.on("--cache-log CACHE-LOG", "Filename to use for cache log. Default is github-changelog-logger.log in a temporary directory.") do |cache_log|
194
+ options[:cache_log] = cache_log
195
+ end
196
+ opts.on("--config-file CONFIG-FILE", "Path to configuration file. Default is .github_changelog_generator.") do |config_file|
197
+ options[:config_file] = config_file
198
+ end
199
+ opts.on("--ssl-ca-file PATH", "Path to cacert.pem file. Default is a bundled lib/github_changelog_generator/ssl_certs/cacert.pem. Respects SSL_CA_PATH.") do |ssl_ca_file|
200
+ options[:ssl_ca_file] = ssl_ca_file
201
+ end
202
+ opts.on("--require x,y,z", Array, "Path to Ruby file(s) to require before generating changelog.") do |paths|
203
+ options[:require] = paths
204
+ end
205
+ opts.on("--[no-]verbose", "Run verbosely. Default is true.") do |v|
206
+ options[:verbose] = v
207
+ end
208
+ opts.on("-v", "--version", "Print version number.") do |_v|
209
+ puts "Version: #{GitHubChangelogGenerator::VERSION}"
210
+ exit
211
+ end
212
+ opts.on("-h", "--help", "Displays Help.") do
213
+ puts opts
214
+ exit
215
+ end
216
+ end
217
+ end
218
+
219
+ class << self
220
+ def banner
221
+ new.parser.banner
222
+ end
223
+ end
224
+ end
225
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+
5
+ module GitHubChangelogGenerator
6
+ class FileParserChooser
7
+ def initialize(options)
8
+ @options = options
9
+ @config_file = Pathname.new(options[:config_file])
10
+ end
11
+
12
+ def parse!(_argv)
13
+ return nil unless (path = resolve_path)
14
+
15
+ ParserFile.new(@options, File.open(path)).parse!
16
+ end
17
+
18
+ def resolve_path
19
+ return @config_file if @config_file.exist?
20
+
21
+ path = @config_file.expand_path
22
+ return path if File.exist?(path)
23
+
24
+ nil
25
+ end
26
+ end
27
+ end