From 953d2813fb964a95085793c60fd4db40b765306c 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/6] 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 0fae7e0f9e4700971a7a5e0890f2153158c0a5a7 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/6] 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 0b0a762a803e842823e35189aa259b3f698f693e Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 25 Aug 2015 16:08:58 +0300 Subject: [PATCH 3/6] 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 a9f50cd82e4dd5072c0533896880d24ad7c09849 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 25 Aug 2015 16:56:52 +0300 Subject: [PATCH 4/6] 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 7e21aacecccea1bf7c9ba00731c648676dde70c3 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 25 Aug 2015 17:28:07 +0300 Subject: [PATCH 5/6] 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 5a5de9ee4a55ec502244841aa26f232cf4961739 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 25 Aug 2015 17:31:54 +0300 Subject: [PATCH 6/6] Update gemspec to version 1.8.1 --- lib/github_changelog_generator/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github_changelog_generator/version.rb b/lib/github_changelog_generator/version.rb index ed56324..ac9c57e 100644 --- a/lib/github_changelog_generator/version.rb +++ b/lib/github_changelog_generator/version.rb @@ -1,3 +1,3 @@ module GitHubChangelogGenerator - VERSION = "1.8.0" + VERSION = "1.8.1" end