From a90c276a9f7f019e3e34d16cd29085df226b6e75 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 18 Feb 2015 21:43:05 +0200 Subject: [PATCH] Fix milesones support for unreleased issues. Fix #47 --- lib/CHANGELOG.md | 8 ++------ lib/github_changelog_generator.rb | 16 ++++++---------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index c7d1d44..8fa7da4 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -5,19 +5,15 @@ - *Merged pull-request:* Implement filtering of Pull Requests by milestones [\#50](https://github.com/skywinder/Github-Changelog-Generator/pull/50) ([skywinder](https://github.com/skywinder)) -- *Merged pull-request:* Feature/fix 37 [\#49](https://github.com/skywinder/Github-Changelog-Generator/pull/49) ([skywinder](https://github.com/skywinder)) - -- *Merged pull-request:* Prettify output [\#48](https://github.com/skywinder/Github-Changelog-Generator/pull/48) ([skywinder](https://github.com/skywinder)) - - *Implemented enhancement:* Add support for forked repo \(to extend changelog with parent's changes\) [\#21](https://github.com/skywinder/Github-Changelog-Generator/issues/21) -- *Fixed bug:* Sometimes user is NULL during merges [\#41](https://github.com/skywinder/Github-Changelog-Generator/issues/41) - ## [1.2.8](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.8) (2015-02-17) [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.7...1.2.8) - *Merged pull-request:* Feature/fix 37 [\#49](https://github.com/skywinder/Github-Changelog-Generator/pull/49) ([skywinder](https://github.com/skywinder)) +- *Merged pull-request:* Prettify output [\#48](https://github.com/skywinder/Github-Changelog-Generator/pull/48) ([skywinder](https://github.com/skywinder)) + - *Closed issue:* Bugs, that closed simultaneously with push not appeared in correct version. [\#37](https://github.com/skywinder/Github-Changelog-Generator/issues/37) ## [1.2.7](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.7) (2015-01-26) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 3bd1bda..cf04249 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -285,14 +285,12 @@ module GitHubChangelogGenerator filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, older_tag, newer_tag) filtered_issues = delete_by_time(@issues, :actual_date, older_tag, newer_tag) - unless newer_tag.nil? - newer_tag_name = newer_tag['name'] + newer_tag_name = newer_tag.nil? ? nil : newer_tag['name'] - if @options[:filter_issues_by_milestone] - #delete excess irrelevant issues (according milestones) - filtered_issues = filter_by_milestone(filtered_issues, newer_tag_name, @issues) - filtered_pull_requests = filter_by_milestone(filtered_pull_requests, newer_tag_name, @pull_requests) - end + if @options[:filter_issues_by_milestone] + #delete excess irrelevant issues (according milestones) + filtered_issues = filter_by_milestone(filtered_issues, newer_tag_name, @issues) + filtered_pull_requests = filter_by_milestone(filtered_pull_requests, newer_tag_name, @pull_requests) end older_tag_name = older_tag.nil? ? nil : older_tag['name'] @@ -302,8 +300,6 @@ module GitHubChangelogGenerator end def filter_by_milestone(filtered_issues, newer_tag_name, src_array) - - filtered_issues.select! { |issue| # leave issues without milestones if issue.milestone.nil? @@ -313,7 +309,6 @@ module GitHubChangelogGenerator @all_tags.find { |tag| tag.name == issue.milestone.title }.nil? end } - unless newer_tag_name.nil? #add missed issues (according milestones) @@ -336,6 +331,7 @@ module GitHubChangelogGenerator filtered_issues |= issues_to_add end + filtered_issues end def delete_by_time(array, hash_key, older_tag = nil, newer_tag = nil)