Compare commits
35 Commits
v1.15.0.pr
...
add-BlackD
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64acef9554 | ||
|
|
e87b267b0e | ||
|
|
72452a1315 | ||
|
|
9377fe600a | ||
|
|
11a7243de1 | ||
|
|
307994e11f | ||
|
|
4465adf943 | ||
|
|
5834fd3766 | ||
|
|
b486425af1 | ||
|
|
91ac00c1d3 | ||
|
|
4f640b74ac | ||
|
|
178ebfb1e7 | ||
|
|
eef787d74d | ||
|
|
faf2ddd552 | ||
|
|
14c36317f1 | ||
|
|
deb902ae13 | ||
|
|
10e6287866 | ||
|
|
5bb4d51b96 | ||
|
|
1fac4efe47 | ||
|
|
ad0d972ed9 | ||
|
|
79518161b8 | ||
|
|
db0e848208 | ||
|
|
d16bf4cfaa | ||
|
|
fe7c585ed1 | ||
|
|
3f8fb60af3 | ||
|
|
23b341f715 | ||
|
|
630b8cee88 | ||
|
|
74fdc2026a | ||
|
|
21ec2db39b | ||
|
|
d1e09f6964 | ||
|
|
b36d85eb53 | ||
|
|
1658b41dff | ||
|
|
64f4cd07c9 | ||
|
|
7cbe41555a | ||
|
|
dd956b7b95 |
2
.github_changelog_generator
Normal file
2
.github_changelog_generator
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
project=github-changelog-generator
|
||||||
|
user=skywinder
|
||||||
20
.travis.yml
20
.travis.yml
@@ -4,28 +4,23 @@ cache:
|
|||||||
before_install:
|
before_install:
|
||||||
- gem install bundler
|
- gem install bundler
|
||||||
matrix:
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- rvm: 2.2.8
|
- rvm: 2.2.7
|
||||||
install: true # This skips 'bundle install'
|
install: true # This skips 'bundle install'
|
||||||
script: gem build github_changelog_generator && gem install *.gem
|
script: gem build github_changelog_generator && gem install *.gem
|
||||||
- rvm: 2.2.8
|
after_success: true # This skips 'codeclimate-test-reporter'
|
||||||
|
- rvm: 2.2.7
|
||||||
install: true # This skips 'bundle install'
|
install: true # This skips 'bundle install'
|
||||||
script: gem build github_changelog_generator && bundle install
|
script: gem build github_changelog_generator && bundle install
|
||||||
gemfile: spec/install-gem-in-bundler.gemfile
|
gemfile: spec/install-gem-in-bundler.gemfile
|
||||||
- rvm: 2.3.5
|
after_success: true # This skips 'codeclimate-test-reporter'
|
||||||
- rvm: 2.4.2
|
- rvm: 2.3.4
|
||||||
|
- rvm: 2.4.1
|
||||||
- rvm: jruby-9.1.13.0
|
- rvm: jruby-9.1.13.0
|
||||||
jdk: oraclejdk8
|
jdk: oraclejdk8
|
||||||
env:
|
env:
|
||||||
- JRUBY_OPTS=--debug
|
- JRUBY_OPTS=--debug
|
||||||
- rvm: jruby-head
|
|
||||||
jdk: oraclejdk8
|
|
||||||
env:
|
|
||||||
- JRUBY_OPTS=--debug
|
|
||||||
- DEBUG=1
|
|
||||||
allow_failures:
|
|
||||||
- rvm: jruby-head
|
|
||||||
fast_finish: true
|
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
code_climate:
|
code_climate:
|
||||||
@@ -33,3 +28,4 @@ addons:
|
|||||||
secure: iMpV5IAvH+/EVGZrpWnt2BnmNFzSbsRcIumsr4ZyLC8N5nrCSXyjCSy0g48btL3Sj0bSgK9hcrJsmrFd2bkqFleyAcPAzNyUQzBuIRZx47O8yFmbZ+Pj+l3+KOlmcbzJNHfDfxkxuWTmTAcSDfsiyApin721T/ey3SUuwKpZNUc=
|
secure: iMpV5IAvH+/EVGZrpWnt2BnmNFzSbsRcIumsr4ZyLC8N5nrCSXyjCSy0g48btL3Sj0bSgK9hcrJsmrFd2bkqFleyAcPAzNyUQzBuIRZx47O8yFmbZ+Pj+l3+KOlmcbzJNHfDfxkxuWTmTAcSDfsiyApin721T/ey3SUuwKpZNUc=
|
||||||
after_success:
|
after_success:
|
||||||
- bundle exec codeclimate-test-reporter
|
- bundle exec codeclimate-test-reporter
|
||||||
|
- bash <(curl -s https://copilot.blackducksoftware.com/ci/travis/scripts/upload)
|
||||||
|
|||||||
110
CHANGELOG.md
110
CHANGELOG.md
@@ -1,5 +1,115 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## [v1.15.0-rc](https://github.com/skywinder/github-changelog-generator/tree/v1.15.0-rc) (2017-10-29)
|
||||||
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/v1.15.0.pre.beta...v1.15.0-rc)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Add option --require to load custom Ruby code before starting [\#574](https://github.com/skywinder/github-changelog-generator/pull/574) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- issue\_line\_labels and breaking\_labels fail as rake file config params [\#583](https://github.com/skywinder/github-changelog-generator/issues/583)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Add Rake options reported missing [\#584](https://github.com/skywinder/github-changelog-generator/pull/584) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Aborting on missing --user and --project prints all of usage [\#578](https://github.com/skywinder/github-changelog-generator/pull/578) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Options\#print\_options + API docs for Options, Parser [\#576](https://github.com/skywinder/github-changelog-generator/pull/576) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- \[docs\] Contributing file [\#575](https://github.com/skywinder/github-changelog-generator/pull/575) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
|
## [v1.15.0.pre.beta](https://github.com/skywinder/github-changelog-generator/tree/v1.15.0.pre.beta) (2017-10-13)
|
||||||
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/v1.15.0.pre.alpha...v1.15.0.pre.beta)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- add breaking-changes section to changelog [\#530](https://github.com/skywinder/github-changelog-generator/pull/530) ([bastelfreak](https://github.com/bastelfreak))
|
||||||
|
- Drop Project-and-Username-finding code [\#451](https://github.com/skywinder/github-changelog-generator/pull/451) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- since\_tag doesn't work when tag specified is the latest tag [\#555](https://github.com/skywinder/github-changelog-generator/issues/555)
|
||||||
|
- since\_tag seems to not be working [\#304](https://github.com/skywinder/github-changelog-generator/issues/304)
|
||||||
|
- filter tags correctly when `since\_tag` is set to most recent tag [\#566](https://github.com/skywinder/github-changelog-generator/pull/566) ([Crunch09](https://github.com/Crunch09))
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- SSL Cert issue on Windows [\#475](https://github.com/skywinder/github-changelog-generator/issues/475)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Fix regression w/ enhancements in issues\_to\_log [\#573](https://github.com/skywinder/github-changelog-generator/pull/573) ([ekohl](https://github.com/ekohl))
|
||||||
|
- OctoFetcher: Use defaults for request\_options [\#571](https://github.com/skywinder/github-changelog-generator/pull/571) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- OctoFetcher: extract methods [\#570](https://github.com/skywinder/github-changelog-generator/pull/570) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- OctoFetcher: extract method fail\_with\_message [\#569](https://github.com/skywinder/github-changelog-generator/pull/569) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- OctoFetcher: drop unused number\_of\_pages feature [\#568](https://github.com/skywinder/github-changelog-generator/pull/568) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Travis: Do not test on jruby-head [\#567](https://github.com/skywinder/github-changelog-generator/pull/567) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Drop unused Rake task [\#564](https://github.com/skywinder/github-changelog-generator/pull/564) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Update license date [\#553](https://github.com/skywinder/github-changelog-generator/pull/553) ([benhc123](https://github.com/benhc123))
|
||||||
|
|
||||||
|
## [v1.15.0.pre.alpha](https://github.com/skywinder/github-changelog-generator/tree/v1.15.0.pre.alpha) (2017-10-01)
|
||||||
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/v1.14.3...v1.15.0.pre.alpha)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Add newline after version name and Full Changelog link [\#548](https://github.com/skywinder/github-changelog-generator/pull/548) ([ianroberts131](https://github.com/ianroberts131))
|
||||||
|
- Update the token failure example to OctoKit 404 failure [\#525](https://github.com/skywinder/github-changelog-generator/pull/525) ([00xcoffee](https://github.com/00xcoffee))
|
||||||
|
- Rescue invalid commands and present the valid options list [\#498](https://github.com/skywinder/github-changelog-generator/pull/498) ([Lucashuang0802](https://github.com/Lucashuang0802))
|
||||||
|
- bundled cacert.pem with --ssl-ca-file PATH option [\#480](https://github.com/skywinder/github-changelog-generator/pull/480) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Option parsing: Remove tag1, tag2 cruft [\#479](https://github.com/skywinder/github-changelog-generator/pull/479) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- Credit line bug [\#541](https://github.com/skywinder/github-changelog-generator/issues/541)
|
||||||
|
- Bug: Credit line about this project added more than once [\#507](https://github.com/skywinder/github-changelog-generator/issues/507)
|
||||||
|
- v1.14.0 Fails with missing /tmp/ path on Windows [\#458](https://github.com/skywinder/github-changelog-generator/issues/458)
|
||||||
|
- failure when creating changelog from a repo in an orginazation: can't convert Github::ResponseWrapper to Array [\#253](https://github.com/skywinder/github-changelog-generator/issues/253)
|
||||||
|
- warn\_if\_nonmatching\_regex should display proper help message when used with exclude-tags-regex [\#551](https://github.com/skywinder/github-changelog-generator/pull/551) ([lacostej](https://github.com/lacostej))
|
||||||
|
- Bugfix: require ActiveSupport core\_ext/blank [\#520](https://github.com/skywinder/github-changelog-generator/pull/520) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Create temporary cache files in Dir.tmpdir [\#459](https://github.com/skywinder/github-changelog-generator/pull/459) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- error \(Windows: Command exited with code 1\) [\#536](https://github.com/skywinder/github-changelog-generator/issues/536)
|
||||||
|
- Error in generating changelog on Windows [\#521](https://github.com/skywinder/github-changelog-generator/issues/521)
|
||||||
|
- Crash on start [\#512](https://github.com/skywinder/github-changelog-generator/issues/512)
|
||||||
|
- Error On Running Generation Command [\#511](https://github.com/skywinder/github-changelog-generator/issues/511)
|
||||||
|
- Not working [\#510](https://github.com/skywinder/github-changelog-generator/issues/510)
|
||||||
|
- PR cited in the wrong TAG [\#503](https://github.com/skywinder/github-changelog-generator/issues/503)
|
||||||
|
- 404 Not Found Error [\#484](https://github.com/skywinder/github-changelog-generator/issues/484)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Travis: Configure cache: bundler: true [\#563](https://github.com/skywinder/github-changelog-generator/pull/563) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Travis: use JRuby 9.1.13.0; don't redo rvm's job [\#562](https://github.com/skywinder/github-changelog-generator/pull/562) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Travis: update CI matrix [\#561](https://github.com/skywinder/github-changelog-generator/pull/561) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Fix section mapping, hiding untagged PRs, and hiding untagged issues [\#550](https://github.com/skywinder/github-changelog-generator/pull/550) ([hunner](https://github.com/hunner))
|
||||||
|
- Update generator\_generation.rb [\#542](https://github.com/skywinder/github-changelog-generator/pull/542) ([Lucashuang0802](https://github.com/Lucashuang0802))
|
||||||
|
- AppVeyor: drop init build hook, add .gitattributes instead [\#539](https://github.com/skywinder/github-changelog-generator/pull/539) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- AppVeyor: Windows configuration to pass RuboCop [\#538](https://github.com/skywinder/github-changelog-generator/pull/538) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Fix the syntax ambiguity on credit-line-bug [\#537](https://github.com/skywinder/github-changelog-generator/pull/537) ([Lucashuang0802](https://github.com/Lucashuang0802))
|
||||||
|
- Credit line bug [\#535](https://github.com/skywinder/github-changelog-generator/pull/535) ([Lucashuang0802](https://github.com/Lucashuang0802))
|
||||||
|
- Update README.md [\#534](https://github.com/skywinder/github-changelog-generator/pull/534) ([Lucashuang0802](https://github.com/Lucashuang0802))
|
||||||
|
- Delete circle.yml [\#532](https://github.com/skywinder/github-changelog-generator/pull/532) ([Lucashuang0802](https://github.com/Lucashuang0802))
|
||||||
|
- Update README.md [\#531](https://github.com/skywinder/github-changelog-generator/pull/531) ([Lucashuang0802](https://github.com/Lucashuang0802))
|
||||||
|
- Remove all old credit lines in the output then add a new one [\#526](https://github.com/skywinder/github-changelog-generator/pull/526) ([Enether](https://github.com/Enether))
|
||||||
|
- Travis: jruby-9.1.10.0 [\#523](https://github.com/skywinder/github-changelog-generator/pull/523) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Travis CI: Drop 2.1 [\#517](https://github.com/skywinder/github-changelog-generator/pull/517) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Chore: Rubocop 0.49.0 [\#516](https://github.com/skywinder/github-changelog-generator/pull/516) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Travis: use jruby-9.1.9.0 [\#506](https://github.com/skywinder/github-changelog-generator/pull/506) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Use closed\_at and merged\_at when filtering issues/prs [\#504](https://github.com/skywinder/github-changelog-generator/pull/504) ([unicolet](https://github.com/unicolet))
|
||||||
|
- Remove --between-tags option [\#501](https://github.com/skywinder/github-changelog-generator/pull/501) ([Lucashuang0802](https://github.com/Lucashuang0802))
|
||||||
|
- Fixed headline in README.md [\#496](https://github.com/skywinder/github-changelog-generator/pull/496) ([Dreckiger-Dan](https://github.com/Dreckiger-Dan))
|
||||||
|
- Update README.md [\#490](https://github.com/skywinder/github-changelog-generator/pull/490) ([fatData](https://github.com/fatData))
|
||||||
|
- Travis: use latest rubies [\#488](https://github.com/skywinder/github-changelog-generator/pull/488) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Use ruby-2.4.1 in CI [\#487](https://github.com/skywinder/github-changelog-generator/pull/487) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Travis: jruby-9.1.8.0 [\#485](https://github.com/skywinder/github-changelog-generator/pull/485) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Update to latest CodeClimate [\#478](https://github.com/skywinder/github-changelog-generator/pull/478) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Gemspec: update retriable to 3.0 [\#477](https://github.com/skywinder/github-changelog-generator/pull/477) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Travis: new JRuby, develop on 2.4.0 [\#476](https://github.com/skywinder/github-changelog-generator/pull/476) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Fix readme typos [\#467](https://github.com/skywinder/github-changelog-generator/pull/467) ([dguo](https://github.com/dguo))
|
||||||
|
- Gemspec: demand rainbow 2.2.1+ [\#466](https://github.com/skywinder/github-changelog-generator/pull/466) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
## [v1.14.3](https://github.com/skywinder/github-changelog-generator/tree/v1.14.3) (2016-12-31)
|
## [v1.14.3](https://github.com/skywinder/github-changelog-generator/tree/v1.14.3) (2016-12-31)
|
||||||
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/v1.14.2...v1.14.3)
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/v1.14.2...v1.14.3)
|
||||||
|
|
||||||
|
|||||||
60
CONTRIBUTING.md
Normal file
60
CONTRIBUTING.md
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# How to contribute
|
||||||
|
|
||||||
|
Bug reports and pull requests from users is what keeps this project working.
|
||||||
|
|
||||||
|
## Basics
|
||||||
|
|
||||||
|
1. Create an issue and describe your idea
|
||||||
|
2. [Fork it](https://github.com/skywinder/github-changelog-generator/fork)
|
||||||
|
3. Create your feature branch (`git checkout -b my-new-feature`)
|
||||||
|
4. Commit your changes (`git commit -am 'Add some feature'`)
|
||||||
|
5. Publish the branch (`git push origin my-new-feature`)
|
||||||
|
6. Create a new Pull Request
|
||||||
|
|
||||||
|
## Checking your work
|
||||||
|
|
||||||
|
You can test your workflow with changelog generator with
|
||||||
|
[the skywinder/changelog_test repo].
|
||||||
|
|
||||||
|
You can run the test suite.
|
||||||
|
|
||||||
|
You can run [RuboCop] to check code style.
|
||||||
|
|
||||||
|
The default Rake task, runnable using `rake`, calls `rubocop`, then `spec`.
|
||||||
|
|
||||||
|
[the skywinder/changelog_test repo]: https://github.com/skywinder/changelog_test/
|
||||||
|
[RuboCop]: http://rubocop.readthedocs.io/en/latest/
|
||||||
|
|
||||||
|
## Write documentation
|
||||||
|
|
||||||
|
This project has documentation in a few places:
|
||||||
|
|
||||||
|
### Introduction and usage
|
||||||
|
|
||||||
|
A friendly `README.md` written for many audiences.
|
||||||
|
|
||||||
|
### Examples and advanced usage
|
||||||
|
|
||||||
|
The [wiki].
|
||||||
|
|
||||||
|
### API documentation
|
||||||
|
|
||||||
|
API documentation is written as [YARD] docblocks in the Ruby code.
|
||||||
|
|
||||||
|
This is rendered as Web pages on [Rubydoc.info][github-changelog-generator on Rubydoc.info].
|
||||||
|
|
||||||
|
The completeness of the API documentation is measured on [our page on the Inch CI Web site][github-changelog-generator on Inch CI]
|
||||||
|
|
||||||
|
### man page
|
||||||
|
|
||||||
|
`man/git-generate-changelog.md`
|
||||||
|
|
||||||
|
The man page is for the `git generate-changelog` Git sub-command, which is a wrapper for `github_changelog_generator`. That file is a Markdown file.
|
||||||
|
|
||||||
|
Use the [ronn] gem to generate `.1` and `.html` artifacts like this: `cd man; ronn git-generate-changelog.md`
|
||||||
|
|
||||||
|
[wiki]: https://github.com/skywinder/github-changelog-generator/wiki
|
||||||
|
[YARD]: https://yardoc.org/
|
||||||
|
[github-changelog-generator on Rubydoc.info]: http://www.rubydoc.info/gems/github_changelog_generator
|
||||||
|
[ronn]: https://github.com/rtomayko/ronn
|
||||||
|
[github-changelog-generator on Inch CI]: https://inch-ci.org/github/skywinder/github-changelog-generator
|
||||||
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
FROM ruby:2.4-alpine3.6
|
||||||
|
|
||||||
|
LABEL maintainer "ferrari.marco@gmail.com"
|
||||||
|
|
||||||
|
ENV GITHUB_CHANGELOG_GENERATOR_VERSION "1.14.3"
|
||||||
|
|
||||||
|
RUN gem install github_changelog_generator --version $GITHUB_CHANGELOG_GENERATOR_VERSION
|
||||||
|
|
||||||
|
ENV SRC_PATH /usr/local/src/your-app
|
||||||
|
RUN mkdir -p $SRC_PATH
|
||||||
|
|
||||||
|
VOLUME [ "$SRC_PATH" ]
|
||||||
|
WORKDIR $SRC_PATH
|
||||||
|
|
||||||
|
CMD ["--help"]
|
||||||
|
ENTRYPOINT ["github_changelog_generator"]
|
||||||
2
LICENSE
2
LICENSE
@@ -1,5 +1,5 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
Copyright (c) 2016 Petr Korolev
|
Copyright (c) 2016-2017 Petr Korolev
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
|
|||||||
558
README.md
558
README.md
@@ -1,275 +1,283 @@
|
|||||||
[](http://badge.fury.io/rb/github_changelog_generator)
|
[](http://badge.fury.io/rb/github_changelog_generator)
|
||||||
[](https://gemnasium.com/skywinder/github-changelog-generator)
|
[](https://gemnasium.com/skywinder/github-changelog-generator)
|
||||||
[](https://travis-ci.org/skywinder/github-changelog-generator)
|
[](https://travis-ci.org/skywinder/github-changelog-generator)
|
||||||
[](https://ci.appveyor.com/project/olleolleolle/github-changelog-generator)
|
[](https://ci.appveyor.com/project/olleolleolle/github-changelog-generator)
|
||||||
[](http://inch-ci.org/github/skywinder/github-changelog-generator)
|
[](http://inch-ci.org/github/skywinder/github-changelog-generator)
|
||||||
[](https://codeclimate.com/github/skywinder/github-changelog-generator)
|
[](https://codeclimate.com/github/skywinder/github-changelog-generator)
|
||||||
[](https://codeclimate.com/github/skywinder/github-changelog-generator)
|
[](https://codeclimate.com/github/skywinder/github-changelog-generator)
|
||||||
[](https://gitter.im/github-changelog-generator/chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://gitter.im/github-changelog-generator/chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
GitHub Changelog Generator 
|
GitHub Changelog Generator 
|
||||||
==================
|
==================
|
||||||
|
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Output example](#output-example)
|
- [Output example](#output-example)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [Params](#params)
|
- [Params](#params)
|
||||||
- [GitHub token](#github-token)
|
- [GitHub token](#github-token)
|
||||||
- [Features and advantages of this project](#features-and-advantages-of-this-project)
|
- [Features and advantages of this project](#features-and-advantages-of-this-project)
|
||||||
- [Alternatives](#alternatives)
|
- [Alternatives](#alternatives)
|
||||||
- [Projects using this library](#projects-using-this-library)
|
- [Projects using this library](#projects-using-this-library)
|
||||||
- [Am I missing some essential feature?](#am-i-missing-some-essential-feature)
|
- [Am I missing some essential feature?](#am-i-missing-some-essential-feature)
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
|
|
||||||
|
|
||||||
### Changelog generation has never been so easy
|
### Changelog generation has never been so easy
|
||||||
|
|
||||||
**Fully automated changelog generation** - This gem generates a change log file based on **tags**, **issues** and merged **pull requests** (and splits them into separate lists according to labels) from :octocat: GitHub Issue Tracker.
|
**Fully automated changelog generation** - This gem generates a change log file based on **tags**, **issues** and merged **pull requests** (and splits them into separate lists according to labels) from :octocat: GitHub Issue Tracker.
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
### *What’s the point of a change log?*
|
### *What’s the point of a change log?*
|
||||||
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.
|
|
||||||
### *Why should I care?*
|
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.
|
||||||
Because software tools are for people. If you don’t care, why are you contributing to open source? Surely, there must be a kernel (ha!) of care somewhere in that lovely little brain of yours.
|
|
||||||
|
### *Why should I care?*
|
||||||
:arrow_right: *[http://keepachangelog.com](http://keepachangelog.com)*
|
|
||||||
|
Because software tools are for _people_. "Changelogs make it easier for users and
|
||||||
## Installation
|
contributors to see precisely what notable changes have been made between each
|
||||||
|
release (or version) of the project."
|
||||||
gem install github_changelog_generator
|
|
||||||
|
:arrow_right: *[http://keepachangelog.com](http://keepachangelog.com)*
|
||||||
See also Troubleshooting.
|
|
||||||
|
## Installation
|
||||||
## Output example
|
|
||||||
|
gem install github_changelog_generator
|
||||||
- Look at **[CHANGELOG.md](https://github.com/skywinder/Github-Changelog-Generator/blob/master/CHANGELOG.md)** for this project
|
|
||||||
- [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md) was generated by command:
|
See also Troubleshooting.
|
||||||
|
|
||||||
github_changelog_generator -u skywinder -p ActionSheetPicker-3.0
|
## Running with Docker
|
||||||
|
|
||||||
- In general, it looks like this:
|
docker run -it --rm -v "$(pwd)":/usr/local/src/your-app skywinder/github-changelog-generator
|
||||||
|
|
||||||
> ## [1.2.5](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.5) (2015-01-15)
|
## Output example
|
||||||
>
|
|
||||||
> [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.4...1.2.5)
|
- Look at **[CHANGELOG.md](https://github.com/skywinder/Github-Changelog-Generator/blob/master/CHANGELOG.md)** for this project
|
||||||
>
|
- [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md) was generated by command:
|
||||||
> **Implemented enhancements:**
|
|
||||||
>
|
github_changelog_generator -u skywinder -p ActionSheetPicker-3.0
|
||||||
> - Use milestone to specify in which version bug was fixed [\#22](https://github.com/skywinder/Github-Changelog-Generator/issues/22)
|
|
||||||
>
|
- In general, it looks like this:
|
||||||
> **Fixed bugs:**
|
|
||||||
>
|
> ## [1.2.5](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.5) (2015-01-15)
|
||||||
> - Error when trying to generate log for repo without tags [\#32](https://github.com/skywinder/Github-Changelog-Generator/issues/32)
|
>
|
||||||
>
|
> [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.4...1.2.5)
|
||||||
> **Merged pull requests:**
|
>
|
||||||
>
|
> **Implemented enhancements:**
|
||||||
> - PrettyPrint class is included using lowercase 'pp' [\#43](https://github.com/skywinder/Github-Changelog-Generator/pull/43) ([schwing](https://github.com/schwing))
|
>
|
||||||
>
|
> - Use milestone to specify in which version bug was fixed [\#22](https://github.com/skywinder/Github-Changelog-Generator/issues/22)
|
||||||
> - support enterprise github via command line options [\#42](https://github.com/skywinder/Github-Changelog-Generator/pull/42) ([glenlovett](https://github.com/glenlovett))
|
>
|
||||||
|
> **Fixed bugs:**
|
||||||
|
>
|
||||||
## Usage
|
> - Error when trying to generate log for repo without tags [\#32](https://github.com/skywinder/Github-Changelog-Generator/issues/32)
|
||||||
**It's really simple!**
|
>
|
||||||
|
> **Merged pull requests:**
|
||||||
- If your **`git remote`** `origin` refers to your GitHub repo, just go to your project folder and run:
|
>
|
||||||
|
> - PrettyPrint class is included using lowercase 'pp' [\#43](https://github.com/skywinder/Github-Changelog-Generator/pull/43) ([schwing](https://github.com/schwing))
|
||||||
github_changelog_generator
|
>
|
||||||
|
> - support enterprise github via command line options [\#42](https://github.com/skywinder/Github-Changelog-Generator/pull/42) ([glenlovett](https://github.com/glenlovett))
|
||||||
- Or, run this from anywhere:
|
|
||||||
`github_changelog_generator -u github_username -p github_project`
|
|
||||||
`github_changelog_generator github_username/github_project`
|
## Usage
|
||||||
|
|
||||||
- If you are running it against a repository on a Github Enterprise install, you must specify *both* `--github-site` and `--github-api` command line options:
|
- Run this:
|
||||||
|
|
||||||
github_changelog_generator --github-site="https://github.yoursite.com" \
|
`github_changelog_generator -u github_username -p github_project`
|
||||||
--github-api="https://github.yoursite.com/api/v3/"
|
`github_changelog_generator github_username/github_project`
|
||||||
|
|
||||||
This generates a changelog to the `CHANGELOG.md` file, with pretty markdown formatting.
|
- For Github Enterprise repos, specify *both* `--github-site` and `--github-api` options:
|
||||||
|
|
||||||
### Params
|
github_changelog_generator --github-site="https://github.yoursite.com" \
|
||||||
Type `github_changelog_generator --help` for details.
|
--github-api="https://github.yoursite.com/api/v3/"
|
||||||
|
|
||||||
For more details about params, read the Wiki page: [**Advanced change log generation examples**](https://github.com/skywinder/github-changelog-generator/wiki/Advanced-change-log-generation-examples)
|
This generates a `CHANGELOG.md`, with pretty Markdown formatting.
|
||||||
|
|
||||||
### Params File
|
### Params
|
||||||
In your project root, you can put a params file named `.github_changelog_generator` to override default params:
|
|
||||||
|
Type `github_changelog_generator --help` for details.
|
||||||
Example:
|
|
||||||
```
|
For more details about params, read the Wiki page: [**Advanced change log generation examples**](https://github.com/skywinder/github-changelog-generator/wiki/Advanced-change-log-generation-examples)
|
||||||
unreleased=false
|
|
||||||
future-release=5.0.0
|
### Params File
|
||||||
since-tag=1.0.0
|
|
||||||
```
|
In your project root, you can put a params file named `.github_changelog_generator` to override default params:
|
||||||
|
|
||||||
### GitHub token
|
Example:
|
||||||
|
|
||||||
GitHub only allows 50 unauthenticated requests per hour.
|
```
|
||||||
Therefore, it's recommended to run this script with authentication by using a **token**.
|
unreleased=false
|
||||||
|
future-release=5.0.0
|
||||||
Here's how:
|
since-tag=1.0.0
|
||||||
|
```
|
||||||
- [Generate a token here](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token) - you only need "repo" scope for private repositories
|
|
||||||
- Either:
|
### GitHub token
|
||||||
- Run the script with `--token <your-40-digit-token>`; **OR**
|
|
||||||
- Set the `CHANGELOG_GITHUB_TOKEN` environment variable to your 40 digit token
|
GitHub only allows 50 unauthenticated requests per hour.
|
||||||
|
|
||||||
You can set an environment variable by running the following command at the prompt, or by adding it to your shell profile (e.g., `~/.bash_profile` or `~/.zshrc`):
|
Therefore, it's recommended to run this script with authentication by using a **token**.
|
||||||
|
|
||||||
export CHANGELOG_GITHUB_TOKEN="«your-40-digit-github-token»"
|
Here's how:
|
||||||
|
|
||||||
So, if you get a message like this:
|
- [Generate a token here](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token) - you only need "repo" scope for private repositories
|
||||||
|
- Either:
|
||||||
``` markdown
|
- Run the script with `--token <your-40-digit-token>`; **OR**
|
||||||
API rate limit exceeded for github_username.
|
- Set the `CHANGELOG_GITHUB_TOKEN` environment variable to your 40 digit token
|
||||||
See: https://developer.github.com/v3/#rate-limiting
|
|
||||||
```
|
You can set an environment variable by running the following command at the prompt, or by adding it to your shell profile (e.g., `~/.bash_profile` or `~/.zshrc`):
|
||||||
|
|
||||||
It's time to create this token! (Or, wait an hour for GitHub to reset your unauthenticated request limit.)
|
export CHANGELOG_GITHUB_TOKEN="«your-40-digit-github-token»"
|
||||||
|
|
||||||
## Migrating from a manual changelog
|
So, if you get a message like this:
|
||||||
|
|
||||||
Knowing how dedicated you are to your project, you probably haven't been waiting for `github-changelog-generator` to keep a changelog.
|
``` markdown
|
||||||
But you probably don't want your project's open issues and PRs for all past features listed in your historic changelog, either.
|
API rate limit exceeded for github_username.
|
||||||
|
See: https://developer.github.com/v3/#rate-limiting
|
||||||
That's where `--base <your-manual-changelog.md>` comes in handy!
|
```
|
||||||
This option lets append your old manual changelog to the end of the generated entries.
|
|
||||||
|
It's time to create this token! (Or, wait an hour for GitHub to reset your unauthenticated request limit.)
|
||||||
If you have a `HISTORY.md` file in your project, it will automatically be picked as the static historical changelog and appended.
|
|
||||||
|
## Migrating from a manual changelog
|
||||||
### Rake task
|
|
||||||
|
Knowing how dedicated you are to your project, you probably haven't been waiting for `github-changelog-generator` to keep a changelog.
|
||||||
You love `rake`? We do, too! So, we've made it even easier for you:
|
But you probably don't want your project's open issues and PRs for all past features listed in your historic changelog, either.
|
||||||
we've provided a `rake` task library for your changelog generation.
|
|
||||||
|
That's where `--base <your-manual-changelog.md>` comes in handy!
|
||||||
Just put something like this in your `Rakefile`:
|
This option lets append your old manual changelog to the end of the generated entries.
|
||||||
|
|
||||||
```ruby
|
If you have a `HISTORY.md` file in your project, it will automatically be picked as the static historical changelog and appended.
|
||||||
require 'github_changelog_generator/task'
|
|
||||||
|
### Rake task
|
||||||
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
|
||||||
config.since_tag = '0.1.14'
|
You love `rake`? We do, too! So, we've made it even easier for you:
|
||||||
config.future_release = '0.2.0'
|
we've provided a `rake` task library for your changelog generation.
|
||||||
end
|
|
||||||
```
|
Configure the task in your `Rakefile`:
|
||||||
|
|
||||||
All command line options can be passed to the `rake` task as `config` parameters. And since you're naming the `rake` task yourself, you can create as many as you want.
|
```ruby
|
||||||
|
require 'github_changelog_generator/task'
|
||||||
You can look for params names from the [parser source code (#setup_parser)](https://github.com/skywinder/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.
|
|
||||||
|
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
||||||
## Features and advantages of this project
|
config.since_tag = '0.1.14'
|
||||||
- Generate canonical, neat change log file, followed by [basic change log guidelines](http://keepachangelog.com) :gem:
|
config.future_release = '0.2.0'
|
||||||
- Optionally generate **Unreleased** changes (closed issues that have not released yet) :dizzy:
|
end
|
||||||
- **GitHub Enterprise support** via command line options! :factory:
|
```
|
||||||
- Flexible format **customization**:
|
|
||||||
- **Customize** issues that **should be added** to changelog :eight_spoked_asterisk:
|
All command-line options can be passed to the `rake` task as `config`
|
||||||
- **Custom date formats** supported (but keep [ISO 8601](http://xkcd.com/1179/) in mind!) :date:
|
parameters. And since you're naming the `rake` task yourself, you can create
|
||||||
- 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:
|
as many as you want.
|
||||||
- Automatically **exclude specific issues** that are irrelevant to your changelog (by default, any issue labeled `question`, `duplicate`, `invalid`, or `wontfix`) :scissors:
|
|
||||||
- **Distinguish** issues **by labels**. :mag_right:
|
You can look for params names from the [parser source code (#setup_parser)](https://github.com/skywinder/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.
|
||||||
- Merged pull requests (all merged pull-requests) :twisted_rightwards_arrows:
|
|
||||||
- Bug fixes (issues labeled `bug`) :beetle:
|
## Features and advantages of this project
|
||||||
- Enhancements (issues labeled `enhancement`) :star2:
|
|
||||||
- Issues (closed issues with no labels) :non-potable_water:
|
- Generate canonical, neat change log file, followed by [basic change log guidelines](http://keepachangelog.com) :gem:
|
||||||
|
- Optionally generate **Unreleased** changes (closed issues that have not released yet) :dizzy:
|
||||||
- Manually include or exclude issues by labels :wrench:
|
- **GitHub Enterprise support** via command line options! :factory:
|
||||||
- Customize lots more! Tweak the changelog to fit your preferences :tophat:
|
- Flexible format **customization**:
|
||||||
(*See `github_changelog_generator --help` for details)*
|
- **Customize** issues that **should be added** to changelog :eight_spoked_asterisk:
|
||||||
|
- **Custom date formats** supported (but keep [ISO 8601](http://xkcd.com/1179/) in mind!) :date:
|
||||||
|
- 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:
|
||||||
### Alternatives
|
- Automatically **exclude specific issues** that are irrelevant to your changelog (by default, any issue labeled `question`, `duplicate`, `invalid`, or `wontfix`) :scissors:
|
||||||
Here is a [wikipage list of alternatives](https://github.com/skywinder/Github-Changelog-Generator/wiki/Alternatives) that I found. But none satisfied my requirements.
|
- **Distinguish** issues **by labels**. :mag_right:
|
||||||
|
- Merged pull requests (all merged pull-requests) :twisted_rightwards_arrows:
|
||||||
*If you know other projects, feel free to edit this Wiki page!*
|
- Bug fixes (issues labeled `bug`) :beetle:
|
||||||
|
- Enhancements (issues labeled `enhancement`) :star2:
|
||||||
|
- Issues (closed issues with no labels) :non-potable_water:
|
||||||
### Projects using this library
|
|
||||||
Here's a [wikipage list of projects](https://github.com/skywinder/Github-Changelog-Generator/wiki/Projects-using-Github-Changelog-Generator).
|
- Manually include or exclude issues by labels :wrench:
|
||||||
|
- Customize lots more! Tweak the changelog to fit your preferences :tophat:
|
||||||
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.
|
(*See `github_changelog_generator --help` for details)*
|
||||||
|
|
||||||
*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/skywinder/Github-Changelog-Generator/wiki/Projects-using-Github-Changelog-Generator).*
|
|
||||||
|
### Alternatives
|
||||||
## Am I missing some essential feature?
|
|
||||||
|
Here is a [wikipage list of alternatives](https://github.com/skywinder/Github-Changelog-Generator/wiki/Alternatives) that I found. But none satisfied my requirements.
|
||||||
- **Nothing is impossible!**
|
|
||||||
|
*If you know other projects, feel free to edit this Wiki page!*
|
||||||
- Open an [issue](https://github.com/skywinder/Github-Changelog-Generator/issues/new) and let's make the generator better together!
|
|
||||||
|
|
||||||
- *Bug reports, feature requests, patches, and well-wishes are always welcome.* :heavy_exclamation_mark:
|
### Projects using this library
|
||||||
|
|
||||||
## FAQ
|
Here's a [wikipage list of projects](https://github.com/skywinder/Github-Changelog-Generator/wiki/Projects-using-Github-Changelog-Generator).
|
||||||
|
|
||||||
- ***I already use GitHub Releases. Why do I need this?***
|
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.
|
||||||
|
|
||||||
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:
|
*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/skywinder/github-changelog-generator/wiki/Projects-using-Github-Changelog-Generator).*
|
||||||
|
|
||||||
*BTW: I would like to support GitHub Releases in [next releases](https://github.com/skywinder/github-changelog-generator/issues/56) ;)*
|
## Am I missing some essential feature?
|
||||||
|
|
||||||
I'm not trying to compare the quality of handwritten and auto-generated logs. That said....
|
- **Nothing is impossible!**
|
||||||
|
|
||||||
An auto-generated changelog really helps, even if you manually fill in the release notes!
|
- Open an [issue](https://github.com/skywinder/Github-Changelog-Generator/issues/new) and let's make the generator better together!
|
||||||
|
|
||||||
For example:
|
- *Bug reports, feature requests, patches, and well-wishes are always welcome.* :heavy_exclamation_mark:
|
||||||
|
|
||||||
When you find a closed bug, it is very useful to know which release fixed it.
|
## FAQ
|
||||||
So that you can easily find the issue by \# in `CHANGELOG.md`.
|
|
||||||
|
- ***I already use GitHub Releases. Why do I need this?***
|
||||||
- it's not quite as easy to find this in handwritten releases notes
|
|
||||||
- a generated file saves you the trouble of remembering everything;
|
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:
|
||||||
sometimes people forget to add things to a handwritten file
|
|
||||||
|
*BTW: I would like to support GitHub Releases in [next releases](https://github.com/skywinder/github-changelog-generator/issues/56) ;)*
|
||||||
Ultimately, I think GitHub Releases are ideal for end-users.
|
|
||||||
Meanwhile, `CHANGELOG.md` lives right in the repository, with its detailed list of changes, which is handy for developers.
|
I'm not trying to compare the quality of handwritten and auto-generated logs. That said....
|
||||||
Finally, there's nothing wrong with using GitHub Releases alongside `CHANGELOG.md` in this combination.
|
|
||||||
|
An auto-generated changelog really helps, even if you manually fill in the release notes!
|
||||||
- ***I received a warning: "GitHub API rate limit exceed" What does this mean?***
|
|
||||||
|
For example:
|
||||||
GitHub [limits the number of API requests](https://developer.github.com/v3/#rate-limiting) you can make in an hour. You can make up to 5,000 requests per hour. For unauthenticated requests, the rate limit is only up to 60 requests per hour. Unauthenticated requests are associated with your IP address (not the user making requests).
|
|
||||||
|
When you find a closed bug, it is very useful to know which release fixed it.
|
||||||
If you're seeing this warning, please do the following:
|
So that you can easily find the issue by \# in `CHANGELOG.md`.
|
||||||
|
|
||||||
1. Make sure you're providing an OAuth token, so you're not making requests anonymously. Using an OAuth token increases your hourly request maximum from 60 to 5000.
|
- it's not quite as easy to find this in handwritten releases notes
|
||||||
2. If you have a large repo with lots of issues/PRs, you can use `--max-issues NUM` to limit the number of issues that are pulled back. For example: `--max-issues 1000`
|
- a generated file saves you the trouble of remembering everything;
|
||||||
|
sometimes people forget to add things to a handwritten file
|
||||||
- ***My Ruby version is very old, can I use this?***
|
|
||||||
|
Ultimately, I think GitHub Releases are ideal for end-users.
|
||||||
When your Ruby is old, and you don't want to upgrade, and you want to
|
Meanwhile, `CHANGELOG.md` lives right in the repository, with its detailed list of changes, which is handy for developers.
|
||||||
control which libraries you use, you can use Bundler.
|
Finally, there's nothing wrong with using GitHub Releases alongside `CHANGELOG.md` in this combination.
|
||||||
|
|
||||||
In a Gemfile, perhaps in a non-deployed `:development` group, add this
|
- ***I received a warning: "GitHub API rate limit exceed" What does this mean?***
|
||||||
gem:
|
|
||||||
|
GitHub [limits the number of API requests](https://developer.github.com/v3/#rate-limiting) you can make in an hour. You can make up to 5,000 requests per hour. For unauthenticated requests, the rate limit is only up to 60 requests per hour. Unauthenticated requests are associated with your IP address (not the user making requests).
|
||||||
```ruby
|
|
||||||
group :development do
|
If you're seeing this warning, please do the following:
|
||||||
gem 'github_changelog_generator', require: false
|
|
||||||
end
|
1. Make sure you're providing an OAuth token, so you're not making requests anonymously. Using an OAuth token increases your hourly request maximum from 60 to 5000.
|
||||||
```
|
2. If you have a large repo with lots of issues/PRs, you can use `--max-issues NUM` to limit the number of issues that are pulled back. For example: `--max-issues 1000`
|
||||||
|
|
||||||
Then you can keep back dependencies like rack, which currently is only
|
- ***My Ruby version is very old, can I use this?***
|
||||||
compatible with Ruby >= 2.2.2. So, use an older version for your app by
|
|
||||||
adding a line like this to the Gemfile:
|
When your Ruby is old, and you don't want to upgrade, and you want to
|
||||||
|
control which libraries you use, you can use Bundler.
|
||||||
```
|
|
||||||
gem 'rack', '~> 1.6'
|
In a Gemfile, perhaps in a non-deployed `:development` group, add this
|
||||||
```
|
gem:
|
||||||
|
|
||||||
This way, you can keep on using github_changelog_generator, even if you
|
```ruby
|
||||||
can't get the latest version of Ruby installed.
|
group :development do
|
||||||
|
gem 'github_changelog_generator', require: false
|
||||||
## Contributing
|
end
|
||||||
|
```
|
||||||
1. Create an issue and describe your idea
|
|
||||||
2. [Fork it](https://github.com/skywinder/github-changelog-generator/fork)
|
Then you can keep back dependencies like rack, which currently is only
|
||||||
3. Create your feature branch (`git checkout -b my-new-feature`)
|
compatible with Ruby >= 2.2.2. So, use an older version for your app by
|
||||||
4. Commit your changes (`git commit -am 'Add some feature'`)
|
adding a line like this to the Gemfile:
|
||||||
5. Publish the branch (`git push origin my-new-feature`)
|
|
||||||
6. Create a new Pull Request
|
```
|
||||||
7. Profit! :white_check_mark:
|
gem 'rack', '~> 1.6'
|
||||||
|
```
|
||||||
You can test your workflow with changelog generator with [the skywinder/changelog_test repo](https://github.com/skywinder/changelog_test/).
|
|
||||||
|
This way, you can keep on using github_changelog_generator, even if you
|
||||||
## License
|
can't get the latest version of Ruby installed.
|
||||||
|
|
||||||
Github Changelog Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
## Contributing
|
||||||
|
|
||||||
|
We have collected notes on how to contribute to this project in [CONTRIBUTING.md].
|
||||||
|
|
||||||
|
[CONTRIBUTING.md]: CONTRIBUTING.md
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Github Changelog Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
||||||
|
|||||||
5
Rakefile
5
Rakefile
@@ -9,12 +9,11 @@ require "fileutils"
|
|||||||
require "overcommit"
|
require "overcommit"
|
||||||
|
|
||||||
RuboCop::RakeTask.new
|
RuboCop::RakeTask.new
|
||||||
RSpec::Core::RakeTask.new(:rspec)
|
RSpec::Core::RakeTask.new
|
||||||
|
|
||||||
desc "When releasing the gem, re-fetch latest cacert.pem from curl.haxx.se. Developer task."
|
desc "When releasing the gem, re-fetch latest cacert.pem from curl.haxx.se. Developer task."
|
||||||
task :update_ssl_ca_file do
|
task :update_ssl_ca_file do
|
||||||
`pushd lib/github_changelog_generator/ssl_certs && curl --remote-name --time-cond cacert.pem https://curl.haxx.se/ca/cacert.pem && popd`
|
`pushd lib/github_changelog_generator/ssl_certs && curl --remote-name --time-cond cacert.pem https://curl.haxx.se/ca/cacert.pem && popd`
|
||||||
end
|
end
|
||||||
|
|
||||||
task checks: %i[rubocop rspec]
|
task default: %i[rubocop spec]
|
||||||
task default: %i[rubocop rspec]
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ install:
|
|||||||
build_script:
|
build_script:
|
||||||
# Install ruby dependencies
|
# Install ruby dependencies
|
||||||
- bundle install --retry 3
|
- bundle install --retry 3
|
||||||
- bundle exec rake checks
|
- bundle exec rake
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- gem build github_changelog_generator
|
- gem build github_changelog_generator
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ Gem::Specification.new do |spec|
|
|||||||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
||||||
spec.require_paths = ["lib"]
|
spec.require_paths = ["lib"]
|
||||||
|
|
||||||
spec.add_runtime_dependency "rake", ">= 10.0"
|
|
||||||
spec.add_runtime_dependency "rainbow", ">= 2.2.1"
|
|
||||||
spec.add_runtime_dependency("octokit", ["~> 4.6"])
|
|
||||||
spec.add_runtime_dependency("faraday-http-cache")
|
|
||||||
spec.add_runtime_dependency("activesupport")
|
spec.add_runtime_dependency("activesupport")
|
||||||
spec.add_runtime_dependency("retriable", ["~> 3.0"])
|
spec.add_runtime_dependency("faraday-http-cache")
|
||||||
spec.add_runtime_dependency("multi_json")
|
spec.add_runtime_dependency("multi_json")
|
||||||
|
spec.add_runtime_dependency("octokit", ["~> 4.6"])
|
||||||
|
spec.add_runtime_dependency "rainbow", ">= 2.2.1"
|
||||||
|
spec.add_runtime_dependency "rake", ">= 10.0"
|
||||||
|
spec.add_runtime_dependency("retriable", ["~> 3.0"])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative "../octo_fetcher"
|
require "github_changelog_generator/octo_fetcher"
|
||||||
require_relative "generator_generation"
|
require "github_changelog_generator/generator/generator_generation"
|
||||||
require_relative "generator_fetcher"
|
require "github_changelog_generator/generator/generator_fetcher"
|
||||||
require_relative "generator_processor"
|
require "github_changelog_generator/generator/generator_processor"
|
||||||
require_relative "generator_tags"
|
require "github_changelog_generator/generator/generator_tags"
|
||||||
|
|
||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
# Default error for ChangelogGenerator
|
# Default error for ChangelogGenerator
|
||||||
@@ -95,12 +95,13 @@ module GitHubChangelogGenerator
|
|||||||
# @param [Array] pull_requests
|
# @param [Array] pull_requests
|
||||||
# @return [String] generated log for issues
|
# @return [String] generated log for issues
|
||||||
def issues_to_log(issues, pull_requests)
|
def issues_to_log(issues, pull_requests)
|
||||||
log = ""
|
sections = parse_by_sections(issues, pull_requests)
|
||||||
bugs_a, enhancement_a, issues_a = parse_by_sections(issues, pull_requests)
|
|
||||||
|
|
||||||
log += generate_sub_section(enhancement_a, options[:enhancement_prefix])
|
log = ""
|
||||||
log += generate_sub_section(bugs_a, options[:bug_prefix])
|
log += generate_sub_section(sections[:breaking], options[:breaking_prefix])
|
||||||
log += generate_sub_section(issues_a, options[:issue_prefix])
|
log += generate_sub_section(sections[:enhancements], options[:enhancement_prefix])
|
||||||
|
log += generate_sub_section(sections[:bugs], options[:bug_prefix])
|
||||||
|
log += generate_sub_section(sections[:issues], options[:issue_prefix])
|
||||||
log
|
log
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -109,47 +110,69 @@ module GitHubChangelogGenerator
|
|||||||
#
|
#
|
||||||
# @param [Array] issues
|
# @param [Array] issues
|
||||||
# @param [Array] pull_requests
|
# @param [Array] pull_requests
|
||||||
# @return [Array] tuple of filtered arrays: (Bugs, Enhancements Issues)
|
# @return [Hash] Mapping of filtered arrays: (Bugs, Enhancements, Breaking stuff, Issues)
|
||||||
def parse_by_sections(issues, pull_requests)
|
def parse_by_sections(issues, pull_requests)
|
||||||
issues_a = []
|
sections = {
|
||||||
enhancement_a = []
|
issues: [],
|
||||||
bugs_a = []
|
enhancements: [],
|
||||||
|
bugs: [],
|
||||||
|
breaking: []
|
||||||
|
}
|
||||||
|
|
||||||
issues.each do |dict|
|
issues.each do |dict|
|
||||||
added = false
|
added = false
|
||||||
|
|
||||||
dict["labels"].each do |label|
|
dict["labels"].each do |label|
|
||||||
if options[:bug_labels].include?(label["name"])
|
if options[:bug_labels].include?(label["name"])
|
||||||
bugs_a.push(dict)
|
sections[:bugs] << dict
|
||||||
added = true
|
added = true
|
||||||
next
|
elsif options[:enhancement_labels].include?(label["name"])
|
||||||
end
|
sections[:enhancements] << dict
|
||||||
if options[:enhancement_labels].include?(label["name"])
|
added = true
|
||||||
enhancement_a.push(dict)
|
elsif options[:breaking_labels].include?(label["name"])
|
||||||
|
sections[:breaking] << dict
|
||||||
added = true
|
added = true
|
||||||
next
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
break if added
|
||||||
end
|
end
|
||||||
issues_a.push(dict) unless added
|
|
||||||
|
sections[:issues] << dict unless added
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sort_pull_requests(pull_requests, sections)
|
||||||
|
end
|
||||||
|
|
||||||
|
# This method iterates through PRs and sorts them into sections
|
||||||
|
#
|
||||||
|
# @param [Array] pull_requests
|
||||||
|
# @param [Hash] sections
|
||||||
|
# @return [Hash] sections
|
||||||
|
def sort_pull_requests(pull_requests, sections)
|
||||||
added_pull_requests = []
|
added_pull_requests = []
|
||||||
pull_requests.each do |pr|
|
pull_requests.each do |pr|
|
||||||
|
added = false
|
||||||
|
|
||||||
pr["labels"].each do |label|
|
pr["labels"].each do |label|
|
||||||
if options[:bug_labels].include?(label["name"])
|
if options[:bug_labels].include?(label["name"])
|
||||||
bugs_a.push(pr)
|
sections[:bugs] << pr
|
||||||
added_pull_requests.push(pr)
|
added_pull_requests << pr
|
||||||
next
|
added = true
|
||||||
end
|
elsif options[:enhancement_labels].include?(label["name"])
|
||||||
if options[:enhancement_labels].include?(label["name"])
|
sections[:enhancements] << pr
|
||||||
enhancement_a.push(pr)
|
added_pull_requests << pr
|
||||||
added_pull_requests.push(pr)
|
added = true
|
||||||
next
|
elsif options[:breaking_labels].include?(label["name"])
|
||||||
|
sections[:breaking] << pr
|
||||||
|
added_pull_requests << pr
|
||||||
|
added = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
break if added
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
added_pull_requests.each { |p| pull_requests.delete(p) }
|
added_pull_requests.each { |p| pull_requests.delete(p) }
|
||||||
|
sections
|
||||||
[bugs_a, enhancement_a, issues_a]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ module GitHubChangelogGenerator
|
|||||||
#
|
#
|
||||||
# @return [String] Generated change log file
|
# @return [String] Generated change log file
|
||||||
def compound_changelog
|
def compound_changelog
|
||||||
|
options.load_custom_ruby_files
|
||||||
fetch_and_filter_tags
|
fetch_and_filter_tags
|
||||||
fetch_issues_and_pr
|
fetch_issues_and_pr
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ module GitHubChangelogGenerator
|
|||||||
if tag
|
if tag
|
||||||
if all_tags.map { |t| t["name"] }.include? tag
|
if all_tags.map { |t| t["name"] }.include? tag
|
||||||
idx = all_tags.index { |t| t["name"] == tag }
|
idx = all_tags.index { |t| t["name"] == tag }
|
||||||
filtered_tags = if idx > 0
|
filtered_tags = if idx
|
||||||
all_tags[0..idx]
|
all_tags[0..idx]
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
|||||||
@@ -31,21 +31,27 @@ module GitHubChangelogGenerator
|
|||||||
@project = @options[:project]
|
@project = @options[:project]
|
||||||
@since = @options[:since]
|
@since = @options[:since]
|
||||||
@http_cache = @options[:http_cache]
|
@http_cache = @options[:http_cache]
|
||||||
if @http_cache
|
@cache_file = nil
|
||||||
@cache_file = @options.fetch(:cache_file) { File.join(Dir.tmpdir, "github-changelog-http-cache") }
|
@cache_log = nil
|
||||||
@cache_log = @options.fetch(:cache_log) { File.join(Dir.tmpdir, "github-changelog-logger.log") }
|
prepare_cache
|
||||||
init_cache
|
|
||||||
end
|
|
||||||
@github_token = fetch_github_token
|
|
||||||
|
|
||||||
@request_options = { per_page: PER_PAGE_NUMBER }
|
|
||||||
@github_options = {}
|
|
||||||
@github_options[:access_token] = @github_token unless @github_token.nil?
|
|
||||||
@github_options[:api_endpoint] = @options[:github_endpoint] unless @options[:github_endpoint].nil?
|
|
||||||
|
|
||||||
configure_octokit_ssl
|
configure_octokit_ssl
|
||||||
|
@client = Octokit::Client.new(github_options)
|
||||||
|
end
|
||||||
|
|
||||||
@client = Octokit::Client.new(@github_options)
|
def prepare_cache
|
||||||
|
return unless @http_cache
|
||||||
|
@cache_file = @options.fetch(:cache_file) { File.join(Dir.tmpdir, "github-changelog-http-cache") }
|
||||||
|
@cache_log = @options.fetch(:cache_log) { File.join(Dir.tmpdir, "github-changelog-logger.log") }
|
||||||
|
init_cache
|
||||||
|
end
|
||||||
|
|
||||||
|
def github_options
|
||||||
|
result = {}
|
||||||
|
github_token = fetch_github_token
|
||||||
|
result[:access_token] = github_token if github_token
|
||||||
|
endpoint = @options[:github_endpoint]
|
||||||
|
result[:api_endpoint] = endpoint if endpoint
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_octokit_ssl
|
def configure_octokit_ssl
|
||||||
@@ -54,21 +60,19 @@ module GitHubChangelogGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def init_cache
|
def init_cache
|
||||||
middleware_opts = {
|
Octokit.middleware = Faraday::RackBuilder.new do |builder|
|
||||||
serializer: Marshal,
|
builder.use(Faraday::HttpCache, serializer: Marshal,
|
||||||
store: ActiveSupport::Cache::FileStore.new(@cache_file),
|
store: ActiveSupport::Cache::FileStore.new(@cache_file),
|
||||||
logger: Logger.new(@cache_log),
|
logger: Logger.new(@cache_log),
|
||||||
shared_cache: false
|
shared_cache: false)
|
||||||
}
|
|
||||||
stack = Faraday::RackBuilder.new do |builder|
|
|
||||||
builder.use Faraday::HttpCache, middleware_opts
|
|
||||||
builder.use Octokit::Response::RaiseError
|
builder.use Octokit::Response::RaiseError
|
||||||
builder.adapter Faraday.default_adapter
|
builder.adapter Faraday.default_adapter
|
||||||
# builder.response :logger
|
# builder.response :logger
|
||||||
end
|
end
|
||||||
Octokit.middleware = stack
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
DEFAULT_REQUEST_OPTIONS = { per_page: PER_PAGE_NUMBER }
|
||||||
|
|
||||||
# Fetch all tags from repo
|
# Fetch all tags from repo
|
||||||
#
|
#
|
||||||
# @return [Array <Hash>] array of tags
|
# @return [Array <Hash>] array of tags
|
||||||
@@ -84,7 +88,7 @@ module GitHubChangelogGenerator
|
|||||||
def calculate_pages(client, method, request_options)
|
def calculate_pages(client, method, request_options)
|
||||||
# Makes the first API call so that we can call last_response
|
# Makes the first API call so that we can call last_response
|
||||||
check_github_response do
|
check_github_response do
|
||||||
client.send(method, user_project, @request_options.merge(request_options))
|
client.send(method, user_project, DEFAULT_REQUEST_OPTIONS.merge(request_options))
|
||||||
end
|
end
|
||||||
|
|
||||||
last_response = client.last_response
|
last_response = client.last_response
|
||||||
@@ -104,7 +108,7 @@ module GitHubChangelogGenerator
|
|||||||
page_i = 0
|
page_i = 0
|
||||||
count_pages = calculate_pages(@client, "tags", {})
|
count_pages = calculate_pages(@client, "tags", {})
|
||||||
|
|
||||||
iterate_pages(@client, "tags", {}) do |new_tags|
|
iterate_pages(@client, "tags") do |new_tags|
|
||||||
page_i += PER_PAGE_NUMBER
|
page_i += PER_PAGE_NUMBER
|
||||||
print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
|
print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
|
||||||
tags.concat(new_tags)
|
tags.concat(new_tags)
|
||||||
@@ -118,8 +122,13 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|||||||
Helper.log.info "Found #{tags.count} tags"
|
Helper.log.info "Found #{tags.count} tags"
|
||||||
end
|
end
|
||||||
# tags are a Sawyer::Resource. Convert to hash
|
# tags are a Sawyer::Resource. Convert to hash
|
||||||
tags = tags.map { |h| stringify_keys_deep(h.to_hash) }
|
tags.map { |resource| stringify_keys_deep(resource.to_hash) }
|
||||||
tags
|
end
|
||||||
|
|
||||||
|
def closed_pr_options
|
||||||
|
@closed_pr_options ||= {
|
||||||
|
filter: "all", labels: nil, state: "closed"
|
||||||
|
}.tap { |options| options[:since] = @since if @since }
|
||||||
end
|
end
|
||||||
|
|
||||||
# This method fetch all closed issues and separate them to pull requests and pure issues
|
# This method fetch all closed issues and separate them to pull requests and pure issues
|
||||||
@@ -129,17 +138,10 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|||||||
def fetch_closed_issues_and_pr
|
def fetch_closed_issues_and_pr
|
||||||
print "Fetching closed issues...\r" if @options[:verbose]
|
print "Fetching closed issues...\r" if @options[:verbose]
|
||||||
issues = []
|
issues = []
|
||||||
options = {
|
|
||||||
state: "closed",
|
|
||||||
filter: "all",
|
|
||||||
labels: nil
|
|
||||||
}
|
|
||||||
options[:since] = @since unless @since.nil?
|
|
||||||
|
|
||||||
page_i = 0
|
page_i = 0
|
||||||
count_pages = calculate_pages(@client, "issues", options)
|
count_pages = calculate_pages(@client, "issues", closed_pr_options)
|
||||||
|
|
||||||
iterate_pages(@client, "issues", options) do |new_issues|
|
iterate_pages(@client, "issues", closed_pr_options) do |new_issues|
|
||||||
page_i += PER_PAGE_NUMBER
|
page_i += PER_PAGE_NUMBER
|
||||||
print_in_same_line("Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
|
print_in_same_line("Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
|
||||||
issues.concat(new_issues)
|
issues.concat(new_issues)
|
||||||
@@ -148,12 +150,9 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|||||||
print_empty_line
|
print_empty_line
|
||||||
Helper.log.info "Received issues: #{issues.count}"
|
Helper.log.info "Received issues: #{issues.count}"
|
||||||
|
|
||||||
issues = issues.map { |h| stringify_keys_deep(h.to_hash) }
|
|
||||||
|
|
||||||
# separate arrays of issues and pull requests:
|
# separate arrays of issues and pull requests:
|
||||||
issues.partition do |x|
|
issues.map { |issue| stringify_keys_deep(issue.to_hash) }
|
||||||
x["pull_request"].nil?
|
.partition { |issue_or_pr| issue_or_pr["pull_request"].nil? }
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Fetch all pull requests. We need them to detect :merged_at parameter
|
# Fetch all pull requests. We need them to detect :merged_at parameter
|
||||||
@@ -179,8 +178,7 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|||||||
print_empty_line
|
print_empty_line
|
||||||
|
|
||||||
Helper.log.info "Pull Request count: #{pull_requests.count}"
|
Helper.log.info "Pull Request count: #{pull_requests.count}"
|
||||||
pull_requests = pull_requests.map { |h| stringify_keys_deep(h.to_hash) }
|
pull_requests.map { |pull_request| stringify_keys_deep(pull_request.to_hash) }
|
||||||
pull_requests
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Fetch event for all issues and add them to 'events'
|
# Fetch event for all issues and add them to 'events'
|
||||||
@@ -195,10 +193,10 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|||||||
issues_slice.each do |issue|
|
issues_slice.each do |issue|
|
||||||
threads << Thread.new do
|
threads << Thread.new do
|
||||||
issue["events"] = []
|
issue["events"] = []
|
||||||
iterate_pages(@client, "issue_events", issue["number"], {}) do |new_event|
|
iterate_pages(@client, "issue_events", issue["number"]) do |new_event|
|
||||||
issue["events"].concat(new_event)
|
issue["events"].concat(new_event)
|
||||||
end
|
end
|
||||||
issue["events"] = issue["events"].map { |h| stringify_keys_deep(h.to_hash) }
|
issue["events"] = issue["events"].map { |event| stringify_keys_deep(event.to_hash) }
|
||||||
print_in_same_line("Fetching events for issues and PR: #{i + 1}/#{issues.count}")
|
print_in_same_line("Fetching events for issues and PR: #{i + 1}/#{issues.count}")
|
||||||
i += 1
|
i += 1
|
||||||
end
|
end
|
||||||
@@ -256,14 +254,15 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|||||||
stringify_keys_deep(value)
|
stringify_keys_deep(value)
|
||||||
end
|
end
|
||||||
when Hash
|
when Hash
|
||||||
indata.each_with_object({}) do |(k, v), output|
|
indata.each_with_object({}) do |(key, value), output|
|
||||||
output[k.to_s] = stringify_keys_deep(v)
|
output[key.to_s] = stringify_keys_deep(value)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
indata
|
indata
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Exception raised to warn about moved repositories.
|
||||||
MovedPermanentlyError = Class.new(RuntimeError)
|
MovedPermanentlyError = Class.new(RuntimeError)
|
||||||
|
|
||||||
# Iterates through all pages until there are no more :next pages to follow
|
# Iterates through all pages until there are no more :next pages to follow
|
||||||
@@ -274,29 +273,21 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|||||||
#
|
#
|
||||||
# @yield [Sawyer::Resource] An OctoKit-provided response (which can be empty)
|
# @yield [Sawyer::Resource] An OctoKit-provided response (which can be empty)
|
||||||
#
|
#
|
||||||
# @return [Integer] total number of pages
|
# @return [void]
|
||||||
def iterate_pages(client, method, *args)
|
def iterate_pages(client, method, *args)
|
||||||
request_opts = extract_request_args(args)
|
args << DEFAULT_REQUEST_OPTIONS.merge(extract_request_args(args))
|
||||||
args.push(@request_options.merge(request_opts))
|
|
||||||
|
|
||||||
number_of_pages = 1
|
|
||||||
|
|
||||||
check_github_response { client.send(method, user_project, *args) }
|
check_github_response { client.send(method, user_project, *args) }
|
||||||
last_response = client.last_response
|
last_response = client.last_response.tap do |response|
|
||||||
if last_response.status == 301
|
raise(MovedPermanentlyError, response.data[:url]) if response.status == 301
|
||||||
raise MovedPermanentlyError, last_response.data[:url]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
yield(last_response.data)
|
yield(last_response.data)
|
||||||
|
|
||||||
until (next_one = last_response.rels[:next]).nil?
|
until (next_one = last_response.rels[:next]).nil?
|
||||||
number_of_pages += 1
|
|
||||||
|
|
||||||
last_response = check_github_response { next_one.get }
|
last_response = check_github_response { next_one.get }
|
||||||
yield(last_response.data)
|
yield(last_response.data)
|
||||||
end
|
end
|
||||||
|
|
||||||
number_of_pages
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_request_args(args)
|
def extract_request_args(args)
|
||||||
@@ -317,14 +308,17 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
rescue MovedPermanentlyError => e
|
rescue MovedPermanentlyError => e
|
||||||
Helper.log.error("#{e.class}: #{e.message}")
|
fail_with_message(e, "The repository has moved, update your configuration")
|
||||||
sys_abort("The repository has moved, please update your configuration")
|
|
||||||
rescue Octokit::Forbidden => e
|
rescue Octokit::Forbidden => e
|
||||||
Helper.log.error("#{e.class}: #{e.message}")
|
fail_with_message(e, "Exceeded retry limit")
|
||||||
sys_abort("Exceeded retry limit")
|
|
||||||
rescue Octokit::Unauthorized => e
|
rescue Octokit::Unauthorized => e
|
||||||
|
fail_with_message(e, "Error: wrong GitHub token")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Presents the exception, and the aborts with the message.
|
||||||
|
def fail_with_message(e, message)
|
||||||
Helper.log.error("#{e.class}: #{e.message}")
|
Helper.log.error("#{e.class}: #{e.message}")
|
||||||
sys_abort("Error: wrong GitHub token")
|
sys_abort(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Exponential backoff
|
# Exponential backoff
|
||||||
@@ -373,7 +367,7 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def fetch_github_token
|
def fetch_github_token
|
||||||
env_var = @options[:token] ? @options[:token] : (ENV.fetch CHANGELOG_GITHUB_TOKEN, nil)
|
env_var = @options[:token].presence || ENV["CHANGELOG_GITHUB_TOKEN"]
|
||||||
|
|
||||||
Helper.log.warn NO_TOKEN_PROVIDED unless env_var
|
Helper.log.warn NO_TOKEN_PROVIDED unless env_var
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "delegate"
|
require "delegate"
|
||||||
|
require "github_changelog_generator/helper"
|
||||||
|
|
||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
|
# This class wraps Options, and knows a list of known options. Others options
|
||||||
|
# will raise exceptions.
|
||||||
class Options < SimpleDelegator
|
class Options < SimpleDelegator
|
||||||
|
# Raised on intializing with unknown keys in the values hash,
|
||||||
|
# and when trying to store a value on an unknown key.
|
||||||
UnsupportedOptionError = Class.new(ArgumentError)
|
UnsupportedOptionError = Class.new(ArgumentError)
|
||||||
|
|
||||||
|
# List of valid option names
|
||||||
KNOWN_OPTIONS = %i[
|
KNOWN_OPTIONS = %i[
|
||||||
add_issues_wo_labels
|
add_issues_wo_labels
|
||||||
add_pr_wo_labels
|
add_pr_wo_labels
|
||||||
@@ -20,13 +27,14 @@ module GitHubChangelogGenerator
|
|||||||
due_tag
|
due_tag
|
||||||
enhancement_labels
|
enhancement_labels
|
||||||
enhancement_prefix
|
enhancement_prefix
|
||||||
|
breaking_labels
|
||||||
|
breaking_prefix
|
||||||
exclude_labels
|
exclude_labels
|
||||||
exclude_tags
|
exclude_tags
|
||||||
exclude_tags_regex
|
exclude_tags_regex
|
||||||
filter_issues_by_milestone
|
filter_issues_by_milestone
|
||||||
frontmatter
|
frontmatter
|
||||||
future_release
|
future_release
|
||||||
git_remote
|
|
||||||
github_endpoint
|
github_endpoint
|
||||||
github_site
|
github_site
|
||||||
header
|
header
|
||||||
@@ -42,6 +50,7 @@ module GitHubChangelogGenerator
|
|||||||
pulls
|
pulls
|
||||||
release_branch
|
release_branch
|
||||||
release_url
|
release_url
|
||||||
|
require
|
||||||
simple_list
|
simple_list
|
||||||
since_tag
|
since_tag
|
||||||
ssl_ca_file
|
ssl_ca_file
|
||||||
@@ -54,26 +63,56 @@ module GitHubChangelogGenerator
|
|||||||
verbose
|
verbose
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# @param values [Hash]
|
||||||
|
#
|
||||||
|
# @raise [UnsupportedOptionError] if given values contain unknown options
|
||||||
def initialize(values)
|
def initialize(values)
|
||||||
super(values)
|
super(values)
|
||||||
unsupported_options.any? && raise(UnsupportedOptionError, unsupported_options.inspect)
|
unsupported_options.any? && raise(UnsupportedOptionError, unsupported_options.inspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Set option key to val.
|
||||||
|
#
|
||||||
|
# @param key [Symbol]
|
||||||
|
# @param val [Object]
|
||||||
|
#
|
||||||
|
# @raise [UnsupportedOptionError] when trying to set an unknown option
|
||||||
def []=(key, val)
|
def []=(key, val)
|
||||||
supported_option?(key) || raise(UnsupportedOptionError, key.inspect)
|
supported_option?(key) || raise(UnsupportedOptionError, key.inspect)
|
||||||
values[key] = val
|
values[key] = val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Hash]
|
||||||
def to_hash
|
def to_hash
|
||||||
values
|
values
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Loads the configured Ruby files from the --require option.
|
||||||
|
def load_custom_ruby_files
|
||||||
|
self[:require].each { |f| require f }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Pretty-prints a censored options hash, if :verbose.
|
||||||
|
def print_options
|
||||||
|
return unless self[:verbose]
|
||||||
|
Helper.log.info "Using these options:"
|
||||||
|
pp(censored_values)
|
||||||
|
puts ""
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def values
|
def values
|
||||||
__getobj__
|
__getobj__
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns a censored options hash.
|
||||||
|
#
|
||||||
|
# @return [Hash] The GitHub `:token` key is censored in the output.
|
||||||
|
def censored_values
|
||||||
|
values.clone.tap { |opts| opts[:token] = opts[:token].nil? ? "No token used" : "hidden value" }
|
||||||
|
end
|
||||||
|
|
||||||
def unsupported_options
|
def unsupported_options
|
||||||
values.keys - KNOWN_OPTIONS
|
values.keys - KNOWN_OPTIONS
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
require "optparse"
|
require "optparse"
|
||||||
require "pp"
|
require "pp"
|
||||||
require_relative "version"
|
require "github_changelog_generator/version"
|
||||||
require_relative "helper"
|
require "github_changelog_generator/helper"
|
||||||
|
|
||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
class Parser
|
class Parser
|
||||||
# parse options with optparse
|
# parse options with optparse
|
||||||
@@ -19,45 +20,34 @@ module GitHubChangelogGenerator
|
|||||||
abort [e, parser].join("\n")
|
abort [e, parser].join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
fetch_user_and_project(options)
|
unless options[:user] && options[:project]
|
||||||
|
warn "Configure which user and project to work on."
|
||||||
|
warn "Options --user and --project, or settings to that effect. See --help for more."
|
||||||
|
abort(parser.banner)
|
||||||
|
end
|
||||||
|
|
||||||
abort(parser.banner) unless options[:user] && options[:project]
|
options.print_options
|
||||||
|
|
||||||
print_options(options)
|
|
||||||
|
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
# If options set to verbose, print the parsed options.
|
# Setup parsing options
|
||||||
#
|
#
|
||||||
# The GitHub `:token` key is censored in the output.
|
# @param options [Options]
|
||||||
#
|
# @return [OptionParser]
|
||||||
# @param options [Hash] The options to display
|
|
||||||
# @option options [Boolean] :verbose If false this method does nothing
|
|
||||||
def self.print_options(options)
|
|
||||||
if options[:verbose]
|
|
||||||
Helper.log.info "Performing task with options:"
|
|
||||||
options_to_display = options.clone
|
|
||||||
options_to_display[:token] = options_to_display[:token].nil? ? nil : "hidden value"
|
|
||||||
pp options_to_display
|
|
||||||
puts ""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# setup parsing options
|
|
||||||
def self.setup_parser(options)
|
def self.setup_parser(options)
|
||||||
parser = OptionParser.new do |opts| # rubocop:disable Metrics/BlockLength
|
OptionParser.new do |opts| # rubocop:disable Metrics/BlockLength
|
||||||
opts.banner = "Usage: github_changelog_generator [options]"
|
opts.banner = "Usage: github_changelog_generator --user USER --project PROJECT [options]"
|
||||||
opts.on("-u", "--user [USER]", "Username of the owner of target GitHub repo") do |last|
|
opts.on("-u", "--user USER", "Username of the owner of target GitHub repo") do |last|
|
||||||
options[:user] = last
|
options[:user] = last
|
||||||
end
|
end
|
||||||
opts.on("-p", "--project [PROJECT]", "Name of project on GitHub") do |last|
|
opts.on("-p", "--project PROJECT", "Name of project on GitHub") do |last|
|
||||||
options[:project] = last
|
options[:project] = last
|
||||||
end
|
end
|
||||||
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|
|
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|
|
||||||
options[:token] = last
|
options[:token] = last
|
||||||
end
|
end
|
||||||
opts.on("-f", "--date-format [FORMAT]", "Date format. Default is %Y-%m-%d") do |last|
|
opts.on("-f", "--date-format FORMAT", "Date format. Default is %Y-%m-%d") do |last|
|
||||||
options[:date_format] = last
|
options[:date_format] = last
|
||||||
end
|
end
|
||||||
opts.on("-o", "--output [NAME]", "Output file. Default is CHANGELOG.md") do |last|
|
opts.on("-o", "--output [NAME]", "Output file. Default is CHANGELOG.md") do |last|
|
||||||
@@ -72,6 +62,9 @@ module GitHubChangelogGenerator
|
|||||||
opts.on("--enhancement-label [LABEL]", "Setup custom label for enhancements section. Default is \"**Implemented enhancements:**\"") do |v|
|
opts.on("--enhancement-label [LABEL]", "Setup custom label for enhancements section. Default is \"**Implemented enhancements:**\"") do |v|
|
||||||
options[:enhancement_prefix] = v
|
options[:enhancement_prefix] = v
|
||||||
end
|
end
|
||||||
|
opts.on("--breaking-label [LABEL]", "Setup custom label for the breaking changes section. Default is \"**Breaking changes:**\"") do |v|
|
||||||
|
options[:breaking_prefix] = v
|
||||||
|
end
|
||||||
opts.on("--issues-label [LABEL]", "Setup custom label for closed-issues section. Default is \"**Closed issues:**\"") do |v|
|
opts.on("--issues-label [LABEL]", "Setup custom label for closed-issues section. Default is \"**Closed issues:**\"") do |v|
|
||||||
options[:issue_prefix] = v
|
options[:issue_prefix] = v
|
||||||
end
|
end
|
||||||
@@ -120,7 +113,7 @@ module GitHubChangelogGenerator
|
|||||||
opts.on("--include-labels x,y,z", Array, "Only issues with the specified labels will be included in the changelog.") do |list|
|
opts.on("--include-labels x,y,z", Array, "Only issues with the specified labels will be included in the changelog.") do |list|
|
||||||
options[:include_labels] = list
|
options[:include_labels] = list
|
||||||
end
|
end
|
||||||
opts.on("--exclude-labels x,y,z", Array, 'Issues with the specified labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list|
|
opts.on("--exclude-labels x,y,z", Array, "Issues with the specified labels will be always excluded from changelog. Default is 'duplicate,question,invalid,wontfix'") do |list|
|
||||||
options[:exclude_labels] = list
|
options[:exclude_labels] = list
|
||||||
end
|
end
|
||||||
opts.on("--bug-labels x,y,z", Array, 'Issues with the specified labels will be always added to "Fixed bugs" section. Default is \'bug,Bug\'') do |list|
|
opts.on("--bug-labels x,y,z", Array, 'Issues with the specified labels will be always added to "Fixed bugs" section. Default is \'bug,Bug\'') do |list|
|
||||||
@@ -129,6 +122,9 @@ module GitHubChangelogGenerator
|
|||||||
opts.on("--enhancement-labels x,y,z", Array, 'Issues with the specified labels will be always added to "Implemented enhancements" section. Default is \'enhancement,Enhancement\'') do |list|
|
opts.on("--enhancement-labels x,y,z", Array, 'Issues with the specified labels will be always added to "Implemented enhancements" section. Default is \'enhancement,Enhancement\'') do |list|
|
||||||
options[:enhancement_labels] = list
|
options[:enhancement_labels] = list
|
||||||
end
|
end
|
||||||
|
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\'') do |list|
|
||||||
|
options[:breaking_labels] = list
|
||||||
|
end
|
||||||
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|
|
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|
|
||||||
options[:issue_line_labels] = list
|
options[:issue_line_labels] = list
|
||||||
end
|
end
|
||||||
@@ -177,6 +173,9 @@ module GitHubChangelogGenerator
|
|||||||
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|
|
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|
|
||||||
options[:ssl_ca_file] = ssl_ca_file
|
options[:ssl_ca_file] = ssl_ca_file
|
||||||
end
|
end
|
||||||
|
opts.on("--require x,y,z", Array, "Path to Ruby file(s) to require.") do |paths|
|
||||||
|
options[:require] = paths
|
||||||
|
end
|
||||||
opts.on("--[no-]verbose", "Run verbosely. Default is true") do |v|
|
opts.on("--[no-]verbose", "Run verbosely. Default is true") do |v|
|
||||||
options[:verbose] = v
|
options[:verbose] = v
|
||||||
end
|
end
|
||||||
@@ -189,10 +188,9 @@ module GitHubChangelogGenerator
|
|||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
parser
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Hash] Default options
|
# @return [Options] Default options
|
||||||
def self.default_options
|
def self.default_options
|
||||||
Options.new(
|
Options.new(
|
||||||
date_format: "%Y-%m-%d",
|
date_format: "%Y-%m-%d",
|
||||||
@@ -210,6 +208,7 @@ module GitHubChangelogGenerator
|
|||||||
enhancement_labels: ["enhancement", "Enhancement", "Type: Enhancement"],
|
enhancement_labels: ["enhancement", "Enhancement", "Type: Enhancement"],
|
||||||
bug_labels: ["bug", "Bug", "Type: Bug"],
|
bug_labels: ["bug", "Bug", "Type: Bug"],
|
||||||
exclude_labels: ["duplicate", "question", "invalid", "wontfix", "Duplicate", "Question", "Invalid", "Wontfix", "Meta: Exclude From Changelog"],
|
exclude_labels: ["duplicate", "question", "invalid", "wontfix", "Duplicate", "Question", "Invalid", "Wontfix", "Meta: Exclude From Changelog"],
|
||||||
|
breaking_labels: %w[backwards-incompatible breaking],
|
||||||
issue_line_labels: [],
|
issue_line_labels: [],
|
||||||
max_issues: nil,
|
max_issues: nil,
|
||||||
simple_list: false,
|
simple_list: false,
|
||||||
@@ -220,114 +219,10 @@ module GitHubChangelogGenerator
|
|||||||
issue_prefix: "**Closed issues:**",
|
issue_prefix: "**Closed issues:**",
|
||||||
bug_prefix: "**Fixed bugs:**",
|
bug_prefix: "**Fixed bugs:**",
|
||||||
enhancement_prefix: "**Implemented enhancements:**",
|
enhancement_prefix: "**Implemented enhancements:**",
|
||||||
git_remote: "origin",
|
breaking_prefix: "**Breaking changes:**",
|
||||||
http_cache: true
|
http_cache: true,
|
||||||
|
require: []
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# If `:user` or `:project` not set in options, try setting them
|
|
||||||
# Valid unnamed parameters:
|
|
||||||
# 1) in 1 param: repo_name/project
|
|
||||||
# 2) in 2 params: repo name project
|
|
||||||
def self.fetch_user_and_project(options)
|
|
||||||
if options[:user].nil? || options[:project].nil?
|
|
||||||
user, project = user_and_project_from_git(options, ARGV[0], ARGV[1])
|
|
||||||
options[:user] ||= user
|
|
||||||
options[:project] ||= project
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sets `:user` and `:project` in `options` from CLI arguments or `git remote`
|
|
||||||
# @param [String] arg0 first argument in cli
|
|
||||||
# @param [String] arg1 second argument in cli
|
|
||||||
# @return [Array<String>] user and project, or nil if unsuccessful
|
|
||||||
def self.user_and_project_from_git(options, arg0 = nil, arg1 = nil)
|
|
||||||
user, project = user_project_from_option(arg0, arg1, options[:github_site])
|
|
||||||
unless user && project
|
|
||||||
if ENV["RUBYLIB"] =~ /ruby-debug-ide/
|
|
||||||
user = "skywinder"
|
|
||||||
project = "changelog_test"
|
|
||||||
else
|
|
||||||
remote = `git config --get remote.#{options[:git_remote]}.url`
|
|
||||||
user, project = user_project_from_remote(remote)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
[user, project]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns GitHub username and project from CLI arguments
|
|
||||||
#
|
|
||||||
# @param arg0 [String] This parameter takes two forms: Either a full
|
|
||||||
# GitHub URL, or a 'username/projectname', or
|
|
||||||
# simply a GitHub username
|
|
||||||
# @param arg1 [String] If arg0 is given as a username,
|
|
||||||
# then arg1 can given as a projectname
|
|
||||||
# @param github_site [String] Domain name of GitHub site
|
|
||||||
#
|
|
||||||
# @return [Array, nil] user and project, or nil if unsuccessful
|
|
||||||
def self.user_project_from_option(arg0, arg1, github_site)
|
|
||||||
user = nil
|
|
||||||
project = nil
|
|
||||||
github_site ||= "github.com"
|
|
||||||
if arg0 && !arg1
|
|
||||||
# this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or
|
|
||||||
# "skywinder/Github-Changelog-Generator" to user and name
|
|
||||||
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(arg0)
|
|
||||||
|
|
||||||
begin
|
|
||||||
param = match[2].nil?
|
|
||||||
rescue StandardError
|
|
||||||
puts "Can't detect user and name from first parameter: '#{arg0}' -> exit'"
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if param
|
|
||||||
return
|
|
||||||
else
|
|
||||||
user = match[1]
|
|
||||||
project = match[2]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
[user, project]
|
|
||||||
end
|
|
||||||
|
|
||||||
# These patterns match these formats:
|
|
||||||
#
|
|
||||||
# ```
|
|
||||||
# origin git@github.com:skywinder/Github-Changelog-Generator.git (fetch)
|
|
||||||
# git@github.com:skywinder/Github-Changelog-Generator.git
|
|
||||||
# ```
|
|
||||||
#
|
|
||||||
# and
|
|
||||||
#
|
|
||||||
# ```
|
|
||||||
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
|
||||||
# https://github.com/skywinder/ChangelogMerger
|
|
||||||
# ```
|
|
||||||
GIT_REMOTE_PATTERNS = [
|
|
||||||
/.*(?:[:\/])(?<user>(?:-|\w|\.)*)\/(?<project>(?:-|\w|\.)*)(?:\.git).*/,
|
|
||||||
/.*\/(?<user>(?:-|\w|\.)*)\/(?<project>(?:-|\w|\.)*).*/
|
|
||||||
]
|
|
||||||
|
|
||||||
# Returns GitHub username and project from git remote output
|
|
||||||
#
|
|
||||||
# @param git_remote_output [String] Output of git remote command
|
|
||||||
#
|
|
||||||
# @return [Array] user and project
|
|
||||||
def self.user_project_from_remote(git_remote_output)
|
|
||||||
user = nil
|
|
||||||
project = nil
|
|
||||||
GIT_REMOTE_PATTERNS.each do |git_remote_pattern|
|
|
||||||
git_remote_pattern =~ git_remote_output
|
|
||||||
|
|
||||||
if Regexp.last_match
|
|
||||||
user = Regexp.last_match(:user)
|
|
||||||
project = Regexp.last_match(:project)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
[user, project]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ module GitHubChangelogGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
KNOWN_ARRAY_KEYS = %i[exclude_labels include_labels bug_labels
|
KNOWN_ARRAY_KEYS = %i[exclude_labels include_labels bug_labels
|
||||||
enhancement_labels issue_line_labels between_tags exclude_tags]
|
enhancement_labels breaking_labels issue_line_labels between_tags exclude_tags]
|
||||||
KNOWN_INTEGER_KEYS = [:max_issues]
|
KNOWN_INTEGER_KEYS = [:max_issues]
|
||||||
|
|
||||||
def convert_value(value, option_name)
|
def convert_value(value, option_name)
|
||||||
@@ -91,6 +91,7 @@ module GitHubChangelogGenerator
|
|||||||
header_label: :header,
|
header_label: :header,
|
||||||
front_matter: :frontmatter,
|
front_matter: :frontmatter,
|
||||||
pr_label: :merge_prefix,
|
pr_label: :merge_prefix,
|
||||||
|
breaking_label: :breaking_prefix,
|
||||||
issues_wo_labels: :add_issues_wo_labels,
|
issues_wo_labels: :add_issues_wo_labels,
|
||||||
pr_wo_labels: :add_pr_wo_labels,
|
pr_wo_labels: :add_pr_wo_labels,
|
||||||
pull_requests: :pulls,
|
pull_requests: :pulls,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
OPTIONS = %w[ user project token date_format output
|
OPTIONS = %w[ user project token date_format output
|
||||||
bug_prefix enhancement_prefix issue_prefix
|
bug_prefix enhancement_prefix issue_prefix
|
||||||
|
breaking_labels issue_line_labels
|
||||||
header merge_prefix issues
|
header merge_prefix issues
|
||||||
add_issues_wo_labels add_pr_wo_labels
|
add_issues_wo_labels add_pr_wo_labels
|
||||||
pulls filter_issues_by_milestone author
|
pulls filter_issues_by_milestone author
|
||||||
@@ -48,13 +49,11 @@ module GitHubChangelogGenerator
|
|||||||
# mimick parse_options
|
# mimick parse_options
|
||||||
options = Parser.default_options
|
options = Parser.default_options
|
||||||
|
|
||||||
Parser.fetch_user_and_project(options)
|
|
||||||
|
|
||||||
OPTIONS.each do |o|
|
OPTIONS.each do |o|
|
||||||
v = instance_variable_get("@#{o}")
|
v = instance_variable_get("@#{o}")
|
||||||
options[o.to_sym] = v unless v.nil?
|
options[o.to_sym] = v unless v.nil?
|
||||||
end
|
end
|
||||||
|
abort "user and project are required." unless options[:user] && options[:project]
|
||||||
generator = Generator.new options
|
generator = Generator.new options
|
||||||
|
|
||||||
log = generator.compound_changelog
|
log = generator.compound_changelog
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
VERSION = "1.15.0-alpha"
|
VERSION = "1.15.0-rc"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.\" generated with Ronn/v0.7.3
|
.\" generated with Ronn/v0.7.3
|
||||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||||
.
|
.
|
||||||
.TH "GIT\-GENERATE\-CHANGELOG" "1" "December 2016" "" ""
|
.TH "GIT\-GENERATE\-CHANGELOG" "1" "October 2017" "" ""
|
||||||
.
|
.
|
||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
\fBgit\-generate\-changelog\fR \- Generate changelog from github
|
\fBgit\-generate\-changelog\fR \- Generate changelog from github
|
||||||
@@ -175,12 +175,6 @@ Issues with the specified labels will be always added to "Fixed bugs" section\.
|
|||||||
Issues with the specified labels will be always added to "Implemented enhancements" section\. Default is \'enhancement,Enhancement\'
|
Issues with the specified labels will be always added to "Implemented enhancements" section\. Default is \'enhancement,Enhancement\'
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
\-\-between\-tags x,y,z
|
|
||||||
.
|
|
||||||
.P
|
|
||||||
Change log will be filled only between specified tags
|
|
||||||
.
|
|
||||||
.P
|
|
||||||
\-\-exclude\-tags x,y,z
|
\-\-exclude\-tags x,y,z
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
@@ -264,6 +258,25 @@ Filename to use for cache\. Default is github\-changelog\-http\-cache in a tempo
|
|||||||
.P
|
.P
|
||||||
Filename to use for cache log\. Default is github\-changelog\-logger\.log in a temporary directory\.
|
Filename to use for cache log\. Default is github\-changelog\-logger\.log in a temporary directory\.
|
||||||
.
|
.
|
||||||
|
.IP "" 4
|
||||||
|
.
|
||||||
|
.nf
|
||||||
|
|
||||||
|
\-\-ssl\-ca\-file [PATH]
|
||||||
|
.
|
||||||
|
.fi
|
||||||
|
.
|
||||||
|
.IP "" 0
|
||||||
|
.
|
||||||
|
.P
|
||||||
|
Path to cacert\.pem file\. Default is a bundled lib/github_changelog_generator/ssl_certs/cacert\.pem\. Respects SSL_CA_PATH\.
|
||||||
|
.
|
||||||
|
.P
|
||||||
|
\-\-require file1\.rb,file2\.rb
|
||||||
|
.
|
||||||
|
.P
|
||||||
|
Paths to Ruby file(s) to require before generating changelog\.
|
||||||
|
.
|
||||||
.P
|
.P
|
||||||
\-\-[no\-]verbose
|
\-\-[no\-]verbose
|
||||||
.
|
.
|
||||||
|
|||||||
@@ -248,6 +248,15 @@
|
|||||||
|
|
||||||
<p> Filename to use for cache log. Default is github-changelog-logger.log in a temporary directory.</p>
|
<p> Filename to use for cache log. Default is github-changelog-logger.log in a temporary directory.</p>
|
||||||
|
|
||||||
|
<pre><code>--ssl-ca-file [PATH]
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p> Path to cacert.pem file. Default is a bundled lib/github_changelog_generator/ssl_certs/cacert.pem. Respects SSL_CA_PATH.</p>
|
||||||
|
|
||||||
|
<p> --require file1.rb,file2.rb</p>
|
||||||
|
|
||||||
|
<p> Paths to Ruby file(s) to require before generating changelog.</p>
|
||||||
|
|
||||||
<p> --[no-]verbose</p>
|
<p> --[no-]verbose</p>
|
||||||
|
|
||||||
<p> Run verbosely. Default is true</p>
|
<p> Run verbosely. Default is true</p>
|
||||||
@@ -277,7 +286,7 @@
|
|||||||
|
|
||||||
<ol class='man-decor man-foot man foot'>
|
<ol class='man-decor man-foot man foot'>
|
||||||
<li class='tl'></li>
|
<li class='tl'></li>
|
||||||
<li class='tc'>December 2016</li>
|
<li class='tc'>October 2017</li>
|
||||||
<li class='tr'>git-generate-changelog(1)</li>
|
<li class='tr'>git-generate-changelog(1)</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,11 @@ Automatically generate change log from your tags, issues, labels and pull reques
|
|||||||
|
|
||||||
--ssl-ca-file [PATH]
|
--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.
|
Path to cacert.pem file. Default is a bundled lib/github_changelog_generator/ssl_certs/cacert.pem. Respects SSL_CA_PATH.
|
||||||
|
|
||||||
|
--require file1.rb,file2.rb
|
||||||
|
|
||||||
|
Paths to Ruby file(s) to require before generating changelog.
|
||||||
|
|
||||||
--[no-]verbose
|
--[no-]verbose
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,61 @@ module GitHubChangelogGenerator
|
|||||||
end.not_to raise_error
|
end.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#parse_by_sections" do
|
||||||
|
def label(name)
|
||||||
|
{ "name" => name }
|
||||||
|
end
|
||||||
|
|
||||||
|
def issue(title, labels)
|
||||||
|
{ "title" => "issue #{title}", "labels" => labels.map { |l| label(l) } }
|
||||||
|
end
|
||||||
|
|
||||||
|
def pr(title, labels)
|
||||||
|
{ "title" => "pr #{title}", "labels" => labels.map { |l| label(l) } }
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_titles(issues)
|
||||||
|
issues.map { |issue| issue["title"] }
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:options) do
|
||||||
|
{
|
||||||
|
bug_labels: ["bug"],
|
||||||
|
enhancement_labels: ["enhancement"],
|
||||||
|
breaking_labels: ["breaking"]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:issues) do
|
||||||
|
[
|
||||||
|
issue("no labels", []),
|
||||||
|
issue("enhancement", ["enhancement"]),
|
||||||
|
issue("bug", ["bug"]),
|
||||||
|
issue("breaking", ["breaking"]),
|
||||||
|
issue("all the labels", %w[enhancement bug breaking])
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:pull_requests) do
|
||||||
|
[
|
||||||
|
pr("no labels", []),
|
||||||
|
pr("enhancement", ["enhancement"]),
|
||||||
|
pr("bug", ["bug"]),
|
||||||
|
pr("breaking", ["breaking"]),
|
||||||
|
pr("all the labels", %w[enhancement bug breaking])
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
sections = described_class.new(options).parse_by_sections(issues, pull_requests)
|
||||||
|
|
||||||
|
expect(get_titles(sections[:issues])).to eq(["issue no labels"])
|
||||||
|
expect(get_titles(sections[:enhancements])).to eq(["issue enhancement", "issue all the labels", "pr enhancement", "pr all the labels"])
|
||||||
|
expect(get_titles(sections[:bugs])).to eq(["issue bug", "pr bug"])
|
||||||
|
expect(get_titles(sections[:breaking])).to eq(["issue breaking", "pr breaking"])
|
||||||
|
expect(get_titles(pull_requests)).to eq(["pr no labels"])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -182,6 +182,11 @@ describe GitHubChangelogGenerator::Generator do
|
|||||||
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
|
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
|
||||||
it { is_expected.to be_a Array }
|
it { is_expected.to be_a Array }
|
||||||
it { is_expected.to match_array(tags_from_strings(%w[1 2])) }
|
it { is_expected.to match_array(tags_from_strings(%w[1 2])) }
|
||||||
|
|
||||||
|
context "with since tag set to the most recent tag" do
|
||||||
|
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "1") }
|
||||||
|
it { is_expected.to match_array(tags_from_strings(%w[1])) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with invalid since tag" do
|
context "with invalid since tag" do
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ RSpec.describe GitHubChangelogGenerator::Options do
|
|||||||
it "raises an error" do
|
it "raises an error" do
|
||||||
expect do
|
expect do
|
||||||
described_class.new(
|
described_class.new(
|
||||||
git_remote: "origin",
|
project: "rails",
|
||||||
strength: "super-strength",
|
strength: "super-strength",
|
||||||
wisdom: "deep"
|
wisdom: "deep"
|
||||||
)
|
)
|
||||||
@@ -22,13 +22,13 @@ RSpec.describe GitHubChangelogGenerator::Options do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#[]=(key, value)" do
|
describe "#[]=(key, value)" do
|
||||||
let(:options) { described_class.new(git_remote: "origin") }
|
let(:options) { described_class.new(project: "rails") }
|
||||||
|
|
||||||
context "with known options" do
|
context "with known options" do
|
||||||
it "sets the option value" do
|
it "sets the option value" do
|
||||||
expect do
|
expect do
|
||||||
options[:git_remote] = "in the cloud"
|
options[:project] = "trails"
|
||||||
end.to change { options[:git_remote] }.to "in the cloud"
|
end.to change { options[:project] }.to "trails"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,83 +1,4 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
describe GitHubChangelogGenerator::Parser do
|
describe GitHubChangelogGenerator::Parser do
|
||||||
describe ".user_project_from_remote" do
|
|
||||||
context "when remote is type 1" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("origin https://github.com/skywinder/ActionSheetPicker-3.0 (fetch)") }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
|
||||||
end
|
|
||||||
context "when remote is type 2" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("https://github.com/skywinder/ActionSheetPicker-3.0") }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
|
||||||
end
|
|
||||||
context "when remote is type 3" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("https://github.com/skywinder/ActionSheetPicker-3.0") }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
|
||||||
end
|
|
||||||
context "when remote is type 4" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("origin git@github.com:skywinder/ActionSheetPicker-3.0.git (fetch)") }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
|
||||||
end
|
|
||||||
context "when remote is invalid" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("some invalid text") }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array([nil, nil]) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
describe ".user_project_from_option" do
|
|
||||||
context "when option is invalid" do
|
|
||||||
it("should return nil") { expect(GitHubChangelogGenerator::Parser.user_project_from_option("blah", nil, nil)).to be_nil }
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when option is valid" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil, nil) }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
|
||||||
end
|
|
||||||
context "when option nil" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option(nil, nil, nil) }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array([nil, nil]) }
|
|
||||||
end
|
|
||||||
context "when site is nil" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil, nil) }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
|
||||||
end
|
|
||||||
context "when site is valid" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil, "https://codeclimate.com") }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
|
||||||
end
|
|
||||||
context "when second arg is not nil" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", "blah", nil) }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array([nil, nil]) }
|
|
||||||
end
|
|
||||||
context "when all args is not nil" do
|
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", "blah", "https://codeclimate.com") }
|
|
||||||
it { is_expected.to be_a(Array) }
|
|
||||||
it { is_expected.to match_array([nil, nil]) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
describe ".fetch_user_and_project" do
|
|
||||||
before do
|
|
||||||
stub_const("ARGV", ["https://github.com/skywinder/github-changelog-generator"])
|
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
|
||||||
let(:valid_user) { "initialized_user" }
|
|
||||||
let(:options) { { user: valid_user } }
|
|
||||||
let(:options_before_change) { options.dup }
|
|
||||||
it "should leave user unchanged" do
|
|
||||||
expect { GitHubChangelogGenerator::Parser.fetch_user_and_project(options) }.to change { options }
|
|
||||||
.from(options_before_change)
|
|
||||||
.to(options_before_change.merge(project: "github-changelog-generator"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user