Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1232f339a0 | ||
|
|
3cc6418048 | ||
|
|
a4f93feb7d | ||
|
|
b0be9f8b06 | ||
|
|
aeaec739f5 | ||
|
|
bf27187dd3 | ||
|
|
0e0295645d | ||
|
|
b2fac89ec1 | ||
|
|
947163426b | ||
|
|
2900025f6f | ||
|
|
802fb44d38 | ||
|
|
8b299a0394 | ||
|
|
111931a958 | ||
|
|
5a47a075e2 | ||
|
|
a35d08f6c7 | ||
|
|
c2e73edc29 | ||
|
|
045dff7cbc | ||
|
|
7c85082e7d | ||
|
|
cc65da5153 | ||
|
|
c22f8b4a31 | ||
|
|
2c46d32531 | ||
|
|
e822ddfc98 | ||
|
|
25a9490a07 | ||
|
|
92a39a4107 | ||
|
|
583021b474 | ||
|
|
961aa20138 | ||
|
|
396622bec0 | ||
|
|
06575c9ab2 | ||
|
|
eba475ee76 | ||
|
|
aa88122d48 | ||
|
|
a69c2b5343 | ||
|
|
7fc862a100 | ||
|
|
87f95140d9 | ||
|
|
75ae6f4a3a | ||
|
|
31c13e8d1d | ||
|
|
a46fe7470b | ||
|
|
27fa9e8e02 | ||
|
|
b15f6b2837 | ||
|
|
0706f89c02 | ||
|
|
419e7e78ad | ||
|
|
6159ebba2f | ||
|
|
3a200e943c | ||
|
|
4dc5a094d2 | ||
|
|
07d52c9465 | ||
|
|
02b0f95ab0 | ||
|
|
0b1f0319db | ||
|
|
c20529bf32 | ||
|
|
26c393c2cc | ||
|
|
f8f887093a | ||
|
|
63bf4a59d4 | ||
|
|
af189dc66f | ||
|
|
917041424b | ||
|
|
2e5099efee | ||
|
|
9685d79f61 | ||
|
|
fb6b3dad5b | ||
|
|
8d27718648 | ||
|
|
8f8be4740d | ||
|
|
26bd24b7d2 | ||
|
|
049599a0a4 | ||
|
|
fcbf661d32 | ||
|
|
98cdd685b9 |
62
CHANGELOG.md
62
CHANGELOG.md
@@ -1,12 +1,52 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## [Unreleased](https://github.com/skywinder/Github-Changelog-Generator/tree/HEAD)
|
## [1.3.9](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.9) (2015-03-06)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.2...HEAD)
|
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.8...1.3.9)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Improve method of detecting owner and repository [\#63](https://github.com/skywinder/Github-Changelog-Generator/issues/63)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Concurrency problem in case of issues \> 2048 [\#65](https://github.com/skywinder/Github-Changelog-Generator/pull/65) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
|
## [1.3.8](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.8) (2015-03-05)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.6...1.3.8)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Fix `git remote` parsing in case, when script running without parameters inside destination directory [\#61](https://github.com/skywinder/Github-Changelog-Generator/pull/61) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
|
## [1.3.6](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.6) (2015-03-05)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.5...1.3.6)
|
||||||
|
|
||||||
|
## [1.3.5](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.5) (2015-03-04)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.4...1.3.5)
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- Pull Requests in Wrong Tag [\#60](https://github.com/skywinder/Github-Changelog-Generator/issues/60)
|
||||||
|
|
||||||
|
## [1.3.4](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.4) (2015-03-03)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.3...1.3.4)
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- --no-issues appears to break PRs [\#59](https://github.com/skywinder/Github-Changelog-Generator/issues/59)
|
||||||
|
|
||||||
|
## [1.3.3](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.3) (2015-03-03)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.2...1.3.3)
|
||||||
|
|
||||||
**Closed issues:**
|
**Closed issues:**
|
||||||
|
|
||||||
- Add \# character to wrapping list. [\#58](https://github.com/skywinder/Github-Changelog-Generator/issues/58)
|
- Add \# character to encapsulate list. [\#58](https://github.com/skywinder/Github-Changelog-Generator/issues/58)
|
||||||
|
|
||||||
## [1.3.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.2) (2015-03-03)
|
## [1.3.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.2) (2015-03-03)
|
||||||
|
|
||||||
@@ -100,10 +140,6 @@
|
|||||||
|
|
||||||
- Crash when try generate log for rails [\#35](https://github.com/skywinder/Github-Changelog-Generator/issues/35)
|
- Crash when try generate log for rails [\#35](https://github.com/skywinder/Github-Changelog-Generator/issues/35)
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
|
|
||||||
|
|
||||||
## [1.2.3](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.3) (2014-12-16)
|
## [1.2.3](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.3) (2014-12-16)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.2...1.2.3)
|
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.2...1.2.3)
|
||||||
@@ -120,6 +156,8 @@
|
|||||||
|
|
||||||
**Merged pull requests:**
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
- Fix crash when user is NULL [\#40](https://github.com/skywinder/Github-Changelog-Generator/pull/40) ([skywinder](https://github.com/skywinder))
|
- Fix crash when user is NULL [\#40](https://github.com/skywinder/Github-Changelog-Generator/pull/40) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
## [1.2.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2) (2014-12-10)
|
## [1.2.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2) (2014-12-10)
|
||||||
@@ -212,10 +250,6 @@
|
|||||||
|
|
||||||
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.0.0...1.0.1)
|
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.0.0...1.0.1)
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8) ([skywinder](https://github.com/skywinder))
|
|
||||||
|
|
||||||
## [1.0.0](https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.0) (2014-11-07)
|
## [1.0.0](https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.0) (2014-11-07)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.1.0...1.0.0)
|
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.1.0...1.0.0)
|
||||||
@@ -232,9 +266,9 @@
|
|||||||
|
|
||||||
**Merged pull requests:**
|
**Merged pull requests:**
|
||||||
|
|
||||||
- Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7) ([skywinder](https://github.com/skywinder))
|
- Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
- Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3) ([skywinder](https://github.com/skywinder))
|
- Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
## [0.1.0](https://github.com/skywinder/Github-Changelog-Generator/tree/0.1.0) (2014-11-07)
|
## [0.1.0](https://github.com/skywinder/Github-Changelog-Generator/tree/0.1.0) (2014-11-07)
|
||||||
|
|
||||||
@@ -242,6 +276,8 @@
|
|||||||
|
|
||||||
**Merged pull requests:**
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
- Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2) ([skywinder](https://github.com/skywinder))
|
- Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
- Add option \(-o --output\) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1) ([skywinder](https://github.com/skywinder))
|
- Add option \(-o --output\) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1) ([skywinder](https://github.com/skywinder))
|
||||||
|
|||||||
28
README.md
28
README.md
@@ -62,8 +62,8 @@ Changelog generation has never been so easy.
|
|||||||
github_changelog_generator
|
github_changelog_generator
|
||||||
|
|
||||||
- or from anywhere:
|
- or from anywhere:
|
||||||
|
- `github_changelog_generator -u github_username -p github_project`
|
||||||
github_changelog_generator -u github_username -p github_project
|
- `github_changelog_generator github_username/github_project`
|
||||||
|
|
||||||
As output you will get `CHANGELOG.md` file with pretty *Markdown-formatted* changelog.
|
As output you will get `CHANGELOG.md` file with pretty *Markdown-formatted* changelog.
|
||||||
|
|
||||||
@@ -116,19 +116,19 @@ It's time to create this token or wait for 1 hour before GitHub reset the counte
|
|||||||
|
|
||||||
##Features and advantages of this project
|
##Features and advantages of this project
|
||||||
- Generate canonical change log file, followed by [keepachangelog.com guidlines](http://keepachangelog.com/)
|
- Generate canonical change log file, followed by [keepachangelog.com guidlines](http://keepachangelog.com/)
|
||||||
- Simply add links for all closed issues and merged pull requests
|
|
||||||
- Possible to generate **Unreleased** changes (closed issues that have not released yet)
|
- Possible to generate **Unreleased** changes (closed issues that have not released yet)
|
||||||
- Flexible format customisation:
|
- **GitHub Enterprise support** via command line options!
|
||||||
- Customize issues, that should be added to changelog
|
- Flexible format **customisation**:
|
||||||
- Custom date format supported
|
- **Customize** issues, that **should be added** to changelog
|
||||||
|
- **Custom date format** supported
|
||||||
- Ability to manually specify in which version issue was fixed (in case, when closed date is not match) by setting `milestone` of issue the same name as tag of required version
|
- Ability to manually specify in which version issue was fixed (in case, when closed date is not match) by setting `milestone` of issue the same name as tag of required version
|
||||||
- Ability to exclude specific issues from change log (by labels)
|
- Ability to **exclude specific issues** from change log (by labels)
|
||||||
- Automatically exclude "questions" - issues marked as `question` labels (and other issues, that shouldn't be in change log file: with `duplicate invalid wontfix` labels)
|
- **Automatically exclude "questions"** - issues marked as `question` labels (and other issues, that shouldn't be in change log file: with `duplicate invalid wontfix` labels)
|
||||||
- Distinguish bug fixes, enchantments, and closed issues according labels.
|
- **Distinguish** bug fixes, enchantments, and closed issues **according labels**.
|
||||||
- **Issues** (closed issues w/o any labels)
|
- Issues (closed issues w/o any labels)
|
||||||
- **Merged pull-requests** (all merged pull-requests)
|
- Merged pull-requests (all merged pull-requests)
|
||||||
- **Bug-fixes** (by label `bug` in issue)
|
- Bug-fixes (by label `bug` in issue)
|
||||||
- **Enhancements** (by label `enhancement` in issue)
|
- Enhancements (by label `enhancement` in issue)
|
||||||
|
|
||||||
###Alternatives
|
###Alternatives
|
||||||
Here is a [wikipage list of alternatives](https://github.com/skywinder/Github-Changelog-Generator/wiki/Alternatives), that I found. But no one was satisfy my requirements.
|
Here is a [wikipage list of alternatives](https://github.com/skywinder/Github-Changelog-Generator/wiki/Alternatives), that I found. But no one was satisfy my requirements.
|
||||||
@@ -139,7 +139,7 @@ Here is a [wikipage list of alternatives](https://github.com/skywinder/Github-Ch
|
|||||||
### Projects using this library
|
### Projects using this library
|
||||||
[Wikipage with list of projects](https://github.com/skywinder/Github-Changelog-Generator/wiki/Projects-using-Github-Changelog-Generator)
|
[Wikipage with list of projects](https://github.com/skywinder/Github-Changelog-Generator/wiki/Projects-using-Github-Changelog-Generator)
|
||||||
|
|
||||||
*If you are using `github_changelog_generator` for generation change log in your project or know of project that uses it, please add it to [this] (https://github.com/skywinder/Github-Changelog-Generator/wiki/Projects-using-Github-Changelog-Generator) list.*
|
*If you are using `github_changelog_generator` for generation change log in your project or know another project that uses it, please add it to [this] (https://github.com/skywinder/Github-Changelog-Generator/wiki/Projects-using-Github-Changelog-Generator) list.*
|
||||||
|
|
||||||
## Am I missed some essential feature?
|
## Am I missed some essential feature?
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|||||||
spec.email = %q{sky4winder+github_changelog_generator@gmail.com}
|
spec.email = %q{sky4winder+github_changelog_generator@gmail.com}
|
||||||
spec.date = `date +"%Y-%m-%d"`.strip!
|
spec.date = `date +"%Y-%m-%d"`.strip!
|
||||||
spec.summary = %q{Script, that automatically generate changelog from your tags, issues, labels and pull requests.}
|
spec.summary = %q{Script, that automatically generate changelog from your tags, issues, labels and pull requests.}
|
||||||
spec.description = %q{Script, that automatically generate changelog from your tags, issues, labels and pull requests.}
|
spec.description = %q{Changelog generation has never been so easy. Fully automate changelog generation - this gem generate change log file based on tags, issues and merged pull requests from Github issue tracker.}
|
||||||
spec.homepage = %q{https://github.com/skywinder/Github-Changelog-Generator}
|
spec.homepage = %q{https://github.com/skywinder/Github-Changelog-Generator}
|
||||||
spec.license = "MIT"
|
spec.license = "MIT"
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,30 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## [Unreleased](https://github.com/nantas/changelog_test/tree/HEAD) (2015-03-03)
|
## [Unreleased](https://github.com/skywinder/changelog_test/tree/HEAD)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/nantas/changelog_test/compare/v0.0.1...HEAD)
|
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.3...HEAD)
|
||||||
|
|
||||||
**Fixed bugs:**
|
**Merged pull requests:**
|
||||||
|
|
||||||
- test issue closed by a commit that will be gone [\#3](https://github.com/nantas/changelog_test/issues/3)
|
- Add automatically generated change log file. [\#5](https://github.com/skywinder/changelog_test/pull/5) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
**Closed issues:**
|
## [v0.0.3](https://github.com/skywinder/changelog_test/tree/v0.0.3) (2015-03-04)
|
||||||
|
|
||||||
- test issue that will be closed in another repo [\#4](https://github.com/nantas/changelog_test/issues/4)
|
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.2...v0.0.3)
|
||||||
|
|
||||||
## [v0.0.1](https://github.com/nantas/changelog_test/tree/v0.0.1) (2015-03-02)
|
**Merged pull requests:**
|
||||||
|
|
||||||
**Fixed bugs:**
|
- fix \#3. hotfix. Should appear in v0.0.3 [\#4](https://github.com/skywinder/changelog_test/pull/4) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
- test issue that will be closed by a commit [\#2](https://github.com/nantas/changelog_test/issues/2)
|
## [v0.0.2](https://github.com/skywinder/changelog_test/tree/v0.0.2) (2015-03-04)
|
||||||
|
|
||||||
- test issue that will close normally [\#1](https://github.com/nantas/changelog_test/issues/1)
|
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.1...v0.0.2)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Here is a test hotfix should appear in v.0.0.2 [\#2](https://github.com/skywinder/changelog_test/pull/2) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
|
## [v0.0.1](https://github.com/skywinder/changelog_test/tree/v0.0.1) (2015-03-02)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,7 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
@options = Parser.parse_options
|
@options = Parser.parse_options
|
||||||
|
|
||||||
if options[:verbose]
|
fetch_github_token
|
||||||
puts 'Input options:'
|
|
||||||
pp options
|
|
||||||
puts ''
|
|
||||||
end
|
|
||||||
|
|
||||||
github_token
|
|
||||||
|
|
||||||
github_options = {per_page: PER_PAGE_NUMBER}
|
github_options = {per_page: PER_PAGE_NUMBER}
|
||||||
github_options[:oauth_token] = @github_token unless @github_token.nil?
|
github_options[:oauth_token] = @github_token unless @github_token.nil?
|
||||||
@@ -42,19 +36,18 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
if @options[:pulls]
|
if @options[:pulls]
|
||||||
@pull_requests = self.get_filtered_pull_requests
|
@pull_requests = self.get_filtered_pull_requests
|
||||||
self.fetch_merged_at_pull_requests
|
|
||||||
else
|
else
|
||||||
@pull_requests = []
|
@pull_requests = []
|
||||||
end
|
end
|
||||||
|
|
||||||
if @options[:issues]
|
if @options[:issues]
|
||||||
@issues = self.get_filtered_issues
|
@issues = self.get_filtered_issues
|
||||||
fetch_event_for_issues(@issues)
|
|
||||||
detect_actual_closed_dates
|
|
||||||
else
|
else
|
||||||
@issues = []
|
@issues = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fetch_event_for_issues_and_pr
|
||||||
|
detect_actual_closed_dates
|
||||||
@tag_times_hash = {}
|
@tag_times_hash = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -65,11 +58,18 @@ module GitHubChangelogGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
threads = []
|
threads = []
|
||||||
|
|
||||||
@issues.each { |issue|
|
@issues.each { |issue|
|
||||||
threads << Thread.new {
|
threads << Thread.new {
|
||||||
find_closed_date_by_commit(issue)
|
find_closed_date_by_commit(issue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@pull_requests.each { |pull_request|
|
||||||
|
threads << Thread.new {
|
||||||
|
find_closed_date_by_commit(pull_request)
|
||||||
|
}
|
||||||
|
}
|
||||||
threads.each { |thr| thr.join }
|
threads.each { |thr| thr.join }
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
@@ -79,9 +79,11 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
def find_closed_date_by_commit(issue)
|
def find_closed_date_by_commit(issue)
|
||||||
unless issue['events'].nil?
|
unless issue['events'].nil?
|
||||||
|
#if it's PR -> then find "merged event", in case of usual issue -> fond closed date
|
||||||
|
compare_string = issue[:merged_at].nil? ? 'closed' : 'merged'
|
||||||
# reverse! - to find latest closed event. (event goes in date order)
|
# reverse! - to find latest closed event. (event goes in date order)
|
||||||
issue['events'].reverse!.each { |event|
|
issue['events'].reverse!.each { |event|
|
||||||
if event[:event].eql? 'closed'
|
if event[:event].eql? compare_string
|
||||||
if event[:commit_id].nil?
|
if event[:commit_id].nil?
|
||||||
issue[:actual_date] = issue[:closed_at]
|
issue[:actual_date] = issue[:closed_at]
|
||||||
else
|
else
|
||||||
@@ -104,14 +106,9 @@ module GitHubChangelogGenerator
|
|||||||
puts JSON.pretty_generate(json)
|
puts JSON.pretty_generate(json)
|
||||||
end
|
end
|
||||||
|
|
||||||
def exec_command(cmd)
|
|
||||||
exec_cmd = "cd #{$project_path} and #{cmd}"
|
|
||||||
%x[#{exec_cmd}]
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetch_merged_at_pull_requests
|
def fetch_merged_at_pull_requests
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
print "Fetching pull requests...\r"
|
print "Fetching merged dates...\r"
|
||||||
end
|
end
|
||||||
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
|
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
|
||||||
|
|
||||||
@@ -120,31 +117,32 @@ module GitHubChangelogGenerator
|
|||||||
response.each_page do |page|
|
response.each_page do |page|
|
||||||
page_i += PER_PAGE_NUMBER
|
page_i += PER_PAGE_NUMBER
|
||||||
count_pages = response.count_pages
|
count_pages = response.count_pages
|
||||||
print "Fetching pull requests... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
|
print "Fetching merged dates... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
|
||||||
pull_requests.concat(page)
|
pull_requests.concat(page)
|
||||||
end
|
end
|
||||||
print " \r"
|
print " \r"
|
||||||
|
|
||||||
if @options[:verbose]
|
|
||||||
puts "Received pull requests: #{pull_requests.count}"
|
|
||||||
end
|
|
||||||
|
|
||||||
@pull_requests.each { |pr|
|
@pull_requests.each { |pr|
|
||||||
fetched_pr = pull_requests.find { |fpr|
|
fetched_pr = pull_requests.find { |fpr|
|
||||||
fpr.number == pr.number }
|
fpr.number == pr.number }
|
||||||
pr[:merged_at] = fetched_pr[:merged_at]
|
pr[:merged_at] = fetched_pr[:merged_at]
|
||||||
pull_requests.delete(fetched_pr)
|
pull_requests.delete(fetched_pr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if @options[:verbose]
|
||||||
|
puts 'Fetching merged dates... Done!'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_filtered_pull_requests
|
def get_filtered_pull_requests
|
||||||
|
|
||||||
pull_requests = @pull_requests
|
self.fetch_merged_at_pull_requests
|
||||||
filtered_pull_requests = pull_requests
|
|
||||||
|
|
||||||
|
filtered_pull_requests = @pull_requests.select {|pr| pr[:merged_at] != nil }
|
||||||
|
|
||||||
unless @options[:include_labels].nil?
|
unless @options[:include_labels].nil?
|
||||||
filtered_pull_requests = pull_requests.select { |issue|
|
filtered_pull_requests = @pull_requests.select { |issue|
|
||||||
#add all labels from @options[:incluse_labels] array
|
#add all labels from @options[:incluse_labels] array
|
||||||
(issue.labels.map { |label| label.name } & @options[:include_labels]).any?
|
(issue.labels.map { |label| label.name } & @options[:include_labels]).any?
|
||||||
}
|
}
|
||||||
@@ -158,7 +156,7 @@ module GitHubChangelogGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
if @options[:add_issues_wo_labels]
|
if @options[:add_issues_wo_labels]
|
||||||
issues_wo_labels = pull_requests.select {
|
issues_wo_labels = @pull_requests.select {
|
||||||
# add issues without any labels
|
# add issues without any labels
|
||||||
|issue| !issue.labels.map { |label| label.name }.any?
|
|issue| !issue.labels.map { |label| label.name }.any?
|
||||||
}
|
}
|
||||||
@@ -171,43 +169,6 @@ module GitHubChangelogGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
filtered_pull_requests
|
filtered_pull_requests
|
||||||
#
|
|
||||||
# #
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# unless @options[:pull_request_labels].nil?
|
|
||||||
#
|
|
||||||
# if @options[:verbose]
|
|
||||||
# puts 'Filter all pull requests by labels.'
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# filtered_pull_requests = filtered_pull_requests.select { |pull_request|
|
|
||||||
# #fetch this issue to get labels array
|
|
||||||
# issue = @github.issues.get @options[:user], @options[:project], pull_request.number
|
|
||||||
#
|
|
||||||
# #compare is there any labels from @options[:labels] array
|
|
||||||
# issue_without_labels = !issue.labels.map { |label| label.name }.any?
|
|
||||||
#
|
|
||||||
# if @options[:verbose]
|
|
||||||
# puts "Filter request \##{issue.number}."
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# if @options[:pull_request_labels].any?
|
|
||||||
# select_by_label = (issue.labels.map { |label| label.name } & @options[:pull_request_labels]).any?
|
|
||||||
# else
|
|
||||||
# select_by_label = false
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# select_by_label | issue_without_labels
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# if @options[:verbose]
|
|
||||||
# puts "Filtered pull requests with specified labels and w/o labels: #{filtered_pull_requests.count}"
|
|
||||||
# end
|
|
||||||
# return filtered_pull_requests
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# filtered_pull_requests
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def compund_changelog
|
def compund_changelog
|
||||||
@@ -267,7 +228,7 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
log = ''
|
log = ''
|
||||||
|
|
||||||
if @options[:unreleased]
|
if @options[:unreleased] && @all_tags.count != 0
|
||||||
unreleased_log = self.generate_log_between_tags(self.all_tags[0], nil)
|
unreleased_log = self.generate_log_between_tags(self.all_tags[0], nil)
|
||||||
if unreleased_log
|
if unreleased_log
|
||||||
log += unreleased_log
|
log += unreleased_log
|
||||||
@@ -277,8 +238,9 @@ module GitHubChangelogGenerator
|
|||||||
(1 ... self.all_tags.size).each { |index|
|
(1 ... self.all_tags.size).each { |index|
|
||||||
log += self.generate_log_between_tags(self.all_tags[index], self.all_tags[index-1])
|
log += self.generate_log_between_tags(self.all_tags[index], self.all_tags[index-1])
|
||||||
}
|
}
|
||||||
|
if @all_tags.count != 0
|
||||||
log += generate_log_between_tags(nil, self.all_tags.last)
|
log += generate_log_between_tags(nil, self.all_tags.last)
|
||||||
|
end
|
||||||
|
|
||||||
log
|
log
|
||||||
end
|
end
|
||||||
@@ -341,12 +303,8 @@ module GitHubChangelogGenerator
|
|||||||
tags
|
tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def github_token
|
def fetch_github_token
|
||||||
if @options[:token]
|
env_var = @options[:token] ? @options[:token] : (ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil)
|
||||||
return @github_token ||= @options[:token]
|
|
||||||
end
|
|
||||||
|
|
||||||
env_var = ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil
|
|
||||||
|
|
||||||
unless env_var
|
unless env_var
|
||||||
puts "Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found.".yellow
|
puts "Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found.".yellow
|
||||||
@@ -359,7 +317,7 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
def generate_log_between_tags(older_tag, newer_tag)
|
def generate_log_between_tags(older_tag, newer_tag)
|
||||||
# older_tag nil - means it's first tag, newer_tag nil - means it unreleased section
|
# older_tag nil - means it's first tag, newer_tag nil - means it unreleased section
|
||||||
filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, older_tag, newer_tag)
|
filtered_pull_requests = delete_by_time(@pull_requests, :actual_date, older_tag, newer_tag)
|
||||||
filtered_issues = delete_by_time(@issues, :actual_date, older_tag, newer_tag)
|
filtered_issues = delete_by_time(@issues, :actual_date, older_tag, newer_tag)
|
||||||
|
|
||||||
newer_tag_name = newer_tag.nil? ? nil : newer_tag['name']
|
newer_tag_name = newer_tag.nil? ? nil : newer_tag['name']
|
||||||
@@ -373,7 +331,7 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
if filtered_issues.empty? && filtered_pull_requests.empty? && newer_tag.nil?
|
if filtered_issues.empty? && filtered_pull_requests.empty? && newer_tag.nil?
|
||||||
# do not generate empty unreleased section
|
# do not generate empty unreleased section
|
||||||
return nil
|
return ''
|
||||||
end
|
end
|
||||||
|
|
||||||
self.create_log(filtered_pull_requests, filtered_issues, newer_tag, older_tag_name)
|
self.create_log(filtered_pull_requests, filtered_issues, newer_tag, older_tag_name)
|
||||||
@@ -416,7 +374,7 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
def delete_by_time(array, hash_key, older_tag = nil, newer_tag = nil)
|
def delete_by_time(array, hash_key, older_tag = nil, newer_tag = nil)
|
||||||
|
|
||||||
raise 'At least on of the tags should be not nil!' if (older_tag.nil? && newer_tag.nil?)
|
raise 'At least one of the tags should be not nil!' if (older_tag.nil? && newer_tag.nil?)
|
||||||
|
|
||||||
newer_tag_time = self.get_time_of_tag(newer_tag)
|
newer_tag_time = self.get_time_of_tag(newer_tag)
|
||||||
older_tag_time = self.get_time_of_tag(older_tag)
|
older_tag_time = self.get_time_of_tag(older_tag)
|
||||||
@@ -499,12 +457,11 @@ module GitHubChangelogGenerator
|
|||||||
log += generate_log_from_array(enhancement_a, @options[:enhancement_prefix])
|
log += generate_log_from_array(enhancement_a, @options[:enhancement_prefix])
|
||||||
log += generate_log_from_array(bugs_a, @options[:bug_prefix])
|
log += generate_log_from_array(bugs_a, @options[:bug_prefix])
|
||||||
log += generate_log_from_array(issues_a, @options[:issue_prefix])
|
log += generate_log_from_array(issues_a, @options[:issue_prefix])
|
||||||
|
end
|
||||||
|
|
||||||
if @options[:pulls]
|
if @options[:pulls]
|
||||||
# Generate pull requests:
|
# Generate pull requests:
|
||||||
log += generate_log_from_array(pull_requests, @options[:merge_prefix])
|
log += generate_log_from_array(pull_requests, @options[:merge_prefix])
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
log
|
log
|
||||||
@@ -629,30 +586,41 @@ module GitHubChangelogGenerator
|
|||||||
return issues_wo_pr, pull_requests
|
return issues_wo_pr, pull_requests
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_event_for_issues(filtered_issues)
|
def fetch_event_for_issues_and_pr
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
print "Fetching events for issues: 0/#{filtered_issues.count}\r"
|
print "Fetching events for issues and PR: 0/#{@issues.count + @pull_requests.count}\r"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Async fetching events:
|
# Async fetching events:
|
||||||
threads = []
|
|
||||||
|
|
||||||
i = 0
|
fetch_events_async(@issues + @pull_requests)
|
||||||
filtered_issues.each { |issue|
|
|
||||||
threads << Thread.new {
|
#to clear line from prev print
|
||||||
obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: issue['number']
|
print " \r"
|
||||||
issue[:events] = obj.body
|
|
||||||
print "Fetching events for issues: #{i+1}/#{filtered_issues.count}\r"
|
|
||||||
i +=1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
threads.each { |thr| thr.join }
|
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts "Fetching events for issues: Done!"
|
puts 'Fetching events for issues and PR: Done!'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fetch_events_async(issues)
|
||||||
|
i = 0
|
||||||
|
max_thread_number = 50
|
||||||
|
threads = []
|
||||||
|
issues.each_slice(max_thread_number) { |issues_slice|
|
||||||
|
issues_slice.each { |issue|
|
||||||
|
threads << Thread.new {
|
||||||
|
obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: issue['number']
|
||||||
|
issue[:events] = obj.body
|
||||||
|
print "Fetching events for issues and PR: #{i+1}/#{@issues.count + @pull_requests.count}\r"
|
||||||
|
i +=1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
threads.each { |thr| thr.join }
|
||||||
|
threads = []
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if __FILE__ == $0
|
if __FILE__ == $0
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ require_relative 'version'
|
|||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
class Parser
|
class Parser
|
||||||
def self.parse_options
|
def self.parse_options
|
||||||
# :include_labels => %w(bug enhancement),
|
|
||||||
hash = {
|
options = {
|
||||||
:tag1 => nil,
|
:tag1 => nil,
|
||||||
:tag2 => nil,
|
:tag2 => nil,
|
||||||
:format => '%Y-%m-%d',
|
:format => '%Y-%m-%d',
|
||||||
@@ -26,12 +26,12 @@ module GitHubChangelogGenerator
|
|||||||
:filter_issues_by_milestone => true,
|
:filter_issues_by_milestone => true,
|
||||||
:compare_link => true,
|
:compare_link => true,
|
||||||
:unreleased => true,
|
:unreleased => true,
|
||||||
:unreleased_label => 'Unreleased'
|
:unreleased_label => 'Unreleased',
|
||||||
|
:branch => 'origin'
|
||||||
}
|
}
|
||||||
options = hash
|
|
||||||
|
|
||||||
parser = OptionParser.new { |opts|
|
parser = OptionParser.new { |opts|
|
||||||
opts.banner = 'Usage: changelog_generator [options]'
|
opts.banner = 'Usage: github_changelog_generator [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
|
||||||
@@ -129,12 +129,24 @@ module GitHubChangelogGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
if !options[:user] && !options[:project]
|
if !options[:user] && !options[:project]
|
||||||
remote = `git remote -vv`.split("\n")
|
remote = `git config --get remote.#{options[:branch]}.url`
|
||||||
match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)?(?:\.git).*/.match(remote[0])
|
# try to find repo in format:
|
||||||
|
# origin git@github.com:skywinder/Github-Changelog-Generator.git (fetch)
|
||||||
|
# git@github.com:skywinder/Github-Changelog-Generator.git
|
||||||
|
match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)(?:\.git).*/.match(remote)
|
||||||
|
|
||||||
if match && match[1] && match[2]
|
if match && match[1] && match[2]
|
||||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||||
options[:user], options[:project] = match[1], match[2]
|
options[:user], options[:project] = match[1], match[2]
|
||||||
|
else
|
||||||
|
# try to find repo in format:
|
||||||
|
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
||||||
|
# https://github.com/skywinder/ChangelogMerger
|
||||||
|
match = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/.match(remote)
|
||||||
|
if match && match[1] && match[2]
|
||||||
|
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||||
|
options[:user], options[:project] = match[1], match[2]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -149,6 +161,12 @@ module GitHubChangelogGenerator
|
|||||||
options[:tag2] = ARGV[1]
|
options[:tag2] = ARGV[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if options[:verbose]
|
||||||
|
puts 'Performing task with options:'
|
||||||
|
pp options
|
||||||
|
puts ''
|
||||||
|
end
|
||||||
|
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
VERSION = '1.3.3'
|
VERSION = '1.3.10'
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user