From b3eea83ae1d99229e21ddfb472bf1067d64ba659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 25 Aug 2015 10:28:27 +0200 Subject: [PATCH 1/7] Honor labels in PRs, fix #266 --- .../generator/generator.rb | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/github_changelog_generator/generator/generator.rb b/lib/github_changelog_generator/generator/generator.rb index c6f2a8b..2145766 100644 --- a/lib/github_changelog_generator/generator/generator.rb +++ b/lib/github_changelog_generator/generator/generator.rb @@ -66,7 +66,7 @@ module GitHubChangelogGenerator if @options[:issues] # Generate issues: - log += issues_to_log(issues) + log += issues_to_log(issues, pull_requests) end if @options[:pulls] @@ -77,13 +77,14 @@ module GitHubChangelogGenerator log end - # Generate ready-to-paste log from list of issues. + # Generate ready-to-paste log from list of issues and pull requests. # # @param [Array] issues + # @param [Array] pull_requests # @return [String] generated log for issues - def issues_to_log(issues) + def issues_to_log(issues, pull_requests) log = "" - bugs_a, enhancement_a, issues_a = parse_by_sections(issues) + bugs_a, enhancement_a, issues_a = parse_by_sections(issues, pull_requests) log += generate_sub_section(enhancement_a, @options[:enhancement_prefix]) log += generate_sub_section(bugs_a, @options[:bug_prefix]) @@ -95,8 +96,9 @@ module GitHubChangelogGenerator # (bugs, features, or just closed issues) by labels # # @param [Array] issues + # @param [Array] pull_requests # @return [Array] tuple of filtered arrays: (Bugs, Enhancements Issues) - def parse_by_sections(issues) + def parse_by_sections(issues, pull_requests) issues_a = [] enhancement_a = [] bugs_a = [] @@ -117,6 +119,24 @@ module GitHubChangelogGenerator end issues_a.push dict unless added end + + pull_requests.each do |dict| + added = false + dict.labels.each do |label| + if @options[:bug_labels].include? label.name + bugs_a.push dict + added = true + next + end + if @options[:enhancement_labels].include? label.name + enhancement_a.push dict + added = true + next + end + end + pull_requests.delete(dict) if added + end + [bugs_a, enhancement_a, issues_a] end end From 31e98fbc41a1ea66e7b7b79bda1ab876db53077d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 25 Aug 2015 13:45:13 +0200 Subject: [PATCH 2/7] Use since_tag as default for older_tag --- .../generator/generator_generation.rb | 2 +- .../generator/generator_tags.rb | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/github_changelog_generator/generator/generator_generation.rb b/lib/github_changelog_generator/generator/generator_generation.rb index 1cd0349..41fd1f3 100644 --- a/lib/github_changelog_generator/generator/generator_generation.rb +++ b/lib/github_changelog_generator/generator/generator_generation.rb @@ -103,7 +103,7 @@ module GitHubChangelogGenerator def generate_log_between_tags(older_tag, newer_tag) filtered_issues, filtered_pull_requests = filter_issues_for_tags(newer_tag, older_tag) - older_tag_name = older_tag.nil? ? nil : older_tag["name"] + older_tag_name = older_tag.nil? ? detect_since_tag : older_tag["name"] if newer_tag.nil? && filtered_issues.empty? && filtered_pull_requests.empty? # do not generate empty unreleased section diff --git a/lib/github_changelog_generator/generator/generator_tags.rb b/lib/github_changelog_generator/generator/generator_tags.rb index 2cc28c8..db2579c 100644 --- a/lib/github_changelog_generator/generator/generator_tags.rb +++ b/lib/github_changelog_generator/generator/generator_tags.rb @@ -54,11 +54,13 @@ module GitHubChangelogGenerator # @return [Object] try to find newest tag using #Reader and :base option if specified otherwise returns nil def detect_since_tag - if @options[:base] && File.file?(@options[:base]) + @since_tag ||= @options[:since_tag] + if @since_tag.nil? && @options[:base] && File.file?(@options[:base]) reader = GitHubChangelogGenerator::Reader.new content = reader.read(@options[:base]) - return content[0]["version"] if content + @since_tag = content[0]["version"] if content end + @since_tag end # Return tags after filtering tags in lists provided by option: --between-tags & --exclude-tags @@ -74,8 +76,7 @@ module GitHubChangelogGenerator # @return [Array] filtered tags according :since_tag option def filter_since_tag(all_tags) filtered_tags = all_tags - tag = @options[:since_tag] - tag ||= detect_since_tag + tag = detect_since_tag if tag if all_tags.map(&:name).include? tag idx = all_tags.index { |t| t.name == tag } From 83ae430dd855a718920ecb6d0e8b140af26dd43a Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 25 Aug 2015 16:08:58 +0300 Subject: [PATCH 3/7] update change log --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea42cbe..8f51080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log +## [Unreleased](https://github.com/skywinder/github-changelog-generator/tree/HEAD) + +[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.8.0...HEAD) + +**Merged pull requests:** + +- Fix issue with missing events \(in case of events for issue \>30\) [\#268](https://github.com/skywinder/github-changelog-generator/pull/268) ([skywinder](https://github.com/skywinder)) +- Use since\_tag as default for older\_tag [\#267](https://github.com/skywinder/github-changelog-generator/pull/267) ([raphink](https://github.com/raphink)) + ## [1.8.0](https://github.com/skywinder/github-changelog-generator/tree/1.8.0) (2015-08-24) [Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.7.0...1.8.0) From ef332dd02b1941d5f23f3efef8feab2e134c8e89 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 25 Aug 2015 16:56:52 +0300 Subject: [PATCH 4/7] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 45ed78f..ab30e2b 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,8 @@ If you're seeing this warning: 6. Create a new Pull Request 7. Profit! :white_check_mark: +*To test change log workflow you can use [test repo](https://github.com/skywinder/changelog_test/)* + ## License Github Changelog Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT). From abd7175eef8b510a74c86dd960c8020c5c40685b Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 25 Aug 2015 17:28:07 +0300 Subject: [PATCH 5/7] simpify expressin & update change log --- lib/CHANGELOG.md | 2 +- .../generator/generator_generation.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index f9f5146..83dc711 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -7,6 +7,7 @@ **Implemented enhancements:** - Enchancment [\#9](https://github.com/skywinder/changelog_test/issues/9) +- PR with enhancement label [\#16](https://github.com/skywinder/changelog_test/pull/16) ([skywinder](https://github.com/skywinder)) **Fixed bugs:** @@ -22,7 +23,6 @@ **Merged pull requests:** - This a PR with a lot of comments and events [\#17](https://github.com/skywinder/changelog_test/pull/17) ([skywinder](https://github.com/skywinder)) -- PR [\#16](https://github.com/skywinder/changelog_test/pull/16) ([skywinder](https://github.com/skywinder)) - This PR closes 14 from commit [\#15](https://github.com/skywinder/changelog_test/pull/15) ([skywinder](https://github.com/skywinder)) - This PR to close \#12 from body [\#13](https://github.com/skywinder/changelog_test/pull/13) ([skywinder](https://github.com/skywinder)) diff --git a/lib/github_changelog_generator/generator/generator_generation.rb b/lib/github_changelog_generator/generator/generator_generation.rb index 41fd1f3..d642d57 100644 --- a/lib/github_changelog_generator/generator/generator_generation.rb +++ b/lib/github_changelog_generator/generator/generator_generation.rb @@ -51,9 +51,8 @@ module GitHubChangelogGenerator def generate_sub_section(issues, prefix) log = "" - log += "#{prefix}\n\n" if options[:simple_list] != true && issues.any? - if issues.any? + log += "#{prefix}\n\n" unless options[:simple_list] issues.each do |issue| merge_string = get_string_for_issue(issue) log += "- #{merge_string}\n" From f285176e255b074c485ccfe2340eec3d95edabad Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 25 Aug 2015 17:32:45 +0300 Subject: [PATCH 6/7] Update changelog for version 1.8.1 --- CHANGELOG.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f51080..e53299c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Change Log -## [Unreleased](https://github.com/skywinder/github-changelog-generator/tree/HEAD) +## [1.8.1](https://github.com/skywinder/github-changelog-generator/tree/1.8.1) (2015-08-25) +[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.8.0...1.8.1) -[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.8.0...HEAD) +**Implemented enhancements:** + +- Honor labels for Pull Requests [\#266](https://github.com/skywinder/github-changelog-generator/pull/266) ([raphink](https://github.com/raphink)) **Merged pull requests:** @@ -15,6 +18,7 @@ **Implemented enhancements:** - Generate change log since/due specific tag [\#254](https://github.com/skywinder/github-changelog-generator/issues/254) +- Add --base option [\#258](https://github.com/skywinder/github-changelog-generator/pull/258) ([raphink](https://github.com/raphink)) **Merged pull requests:** @@ -22,7 +26,6 @@ - Add release\_url to rake task options [\#264](https://github.com/skywinder/github-changelog-generator/pull/264) ([raphink](https://github.com/raphink)) - Add a rake task [\#260](https://github.com/skywinder/github-changelog-generator/pull/260) ([raphink](https://github.com/raphink)) - Add release\_url option [\#259](https://github.com/skywinder/github-changelog-generator/pull/259) ([raphink](https://github.com/raphink)) -- Add --base option [\#258](https://github.com/skywinder/github-changelog-generator/pull/258) ([raphink](https://github.com/raphink)) - Add --since-tag [\#257](https://github.com/skywinder/github-changelog-generator/pull/257) ([raphink](https://github.com/raphink)) ## [1.7.0](https://github.com/skywinder/github-changelog-generator/tree/1.7.0) (2015-07-16) @@ -104,6 +107,7 @@ - Parsing of existing Change Log file [\#212](https://github.com/skywinder/github-changelog-generator/issues/212) - Warn users about 0 tags in repo. [\#208](https://github.com/skywinder/github-changelog-generator/issues/208) +- Cleanup [\#220](https://github.com/skywinder/github-changelog-generator/pull/220) ([tuexss](https://github.com/tuexss)) **Closed issues:** @@ -113,7 +117,6 @@ - Implement fetcher class [\#227](https://github.com/skywinder/github-changelog-generator/pull/227) ([skywinder](https://github.com/skywinder)) - Add coveralls integration [\#223](https://github.com/skywinder/github-changelog-generator/pull/223) ([skywinder](https://github.com/skywinder)) -- Cleanup [\#220](https://github.com/skywinder/github-changelog-generator/pull/220) ([tuexss](https://github.com/tuexss)) - Rspec & rubocop integration [\#217](https://github.com/skywinder/github-changelog-generator/pull/217) ([skywinder](https://github.com/skywinder)) - Implement Reader class to parse ChangeLog.md [\#216](https://github.com/skywinder/github-changelog-generator/pull/216) ([estahn](https://github.com/estahn)) - Relatively require github\_changelog\_generator library [\#207](https://github.com/skywinder/github-changelog-generator/pull/207) ([sneal](https://github.com/sneal)) @@ -129,7 +132,7 @@ ## [1.3.10](https://github.com/skywinder/github-changelog-generator/tree/1.3.10) (2015-03-18) [Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.3.9...1.3.10) -**Merged pull requests:** +**Fixed bugs:** - Fix termination in case of empty unreleased section with `--unreleased-only` option. [\#70](https://github.com/skywinder/github-changelog-generator/pull/70) ([skywinder](https://github.com/skywinder)) @@ -140,7 +143,7 @@ - Improve method of detecting owner and repository [\#63](https://github.com/skywinder/github-changelog-generator/issues/63) -**Merged pull requests:** +**Fixed bugs:** - Resolved concurrency problem in case of issues \> 2048 [\#65](https://github.com/skywinder/github-changelog-generator/pull/65) ([skywinder](https://github.com/skywinder)) @@ -214,7 +217,7 @@ ## [1.2.7](https://github.com/skywinder/github-changelog-generator/tree/1.2.7) (2015-01-26) [Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.2.6...1.2.7) -**Merged pull requests:** +**Implemented enhancements:** - Add compare link between older version and newer version [\#46](https://github.com/skywinder/github-changelog-generator/pull/46) ([sue445](https://github.com/sue445)) @@ -235,10 +238,10 @@ **Fixed bugs:** - Error when trying to generate log for repo without tags [\#32](https://github.com/skywinder/github-changelog-generator/issues/32) +- PrettyPrint class is included using lowercase 'pp' [\#43](https://github.com/skywinder/github-changelog-generator/pull/43) ([schwing](https://github.com/schwing)) **Merged pull requests:** -- PrettyPrint class is included using lowercase 'pp' [\#43](https://github.com/skywinder/github-changelog-generator/pull/43) ([schwing](https://github.com/schwing)) - support enterprise github via command line options [\#42](https://github.com/skywinder/github-changelog-generator/pull/42) ([glenlovett](https://github.com/glenlovett)) ## [1.2.4](https://github.com/skywinder/github-changelog-generator/tree/1.2.4) (2014-12-16) @@ -348,6 +351,7 @@ - Add support for fixed issues and implemented enchanments. [\#6](https://github.com/skywinder/github-changelog-generator/issues/6) - Implement option to specify output filename [\#4](https://github.com/skywinder/github-changelog-generator/issues/4) +- Implement support of different tags. [\#8](https://github.com/skywinder/github-changelog-generator/pull/8) ([skywinder](https://github.com/skywinder)) **Fixed bugs:** @@ -355,7 +359,6 @@ **Merged pull requests:** -- Implement support of different tags. [\#8](https://github.com/skywinder/github-changelog-generator/pull/8) ([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) From 16f01dbda1207a019f8bca35185305cf3e0431af Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 25 Aug 2015 17:33:22 +0300 Subject: [PATCH 7/7] resolve --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1dd602d..d956225 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - github_changelog_generator (1.8.0) + github_changelog_generator (1.8.1) colorize (~> 0.7) github_api (~> 0.12)