add ability to disable milestones filtering

This commit is contained in:
Petr Korolev 2014-12-22 15:41:20 +02:00
parent 5304e4faf8
commit 657ce0e838
3 changed files with 39 additions and 36 deletions

View File

@ -12,24 +12,20 @@
- *Fixed bug:* Docs lacking or basic behavior not as advertised [\#30](https://github.com/skywinder/Github-Changelog-Generator/issues/30) - *Fixed bug:* Docs lacking or basic behavior not as advertised [\#30](https://github.com/skywinder/Github-Changelog-Generator/issues/30)
- *Fixed bug:* Crash when try generate log for rails [\#35](https://github.com/skywinder/Github-Changelog-Generator/issues/35)
## [1.2.3] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.3) ## [1.2.3] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.3)
#### 16/12/14 #### 16/12/14
- *Fixed bug:* Encapsulate \[ \> \* \_ \ \] signs in issues names [\#34](https://github.com/skywinder/Github-Changelog-Generator/issues/34)
## [1.2.2] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2) ## [1.2.2] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2)
#### 10/12/14 #### 10/12/14
- *Merged pull-request:* Add a Bitdeli Badge to README [\#36](https://github.com/skywinder/Github-Changelog-Generator/pull/36) ([bitdeli-chef](https://github.com/bitdeli-chef)) - *Merged pull-request:* Add a Bitdeli Badge to README [\#36](https://github.com/skywinder/Github-Changelog-Generator/pull/36) ([bitdeli-chef](https://github.com/bitdeli-chef))
- *Fixed bug:* Encapsulate \[ \> \* \_ \ \] signs in issues names [\#34](https://github.com/skywinder/Github-Changelog-Generator/issues/34)
## [1.2.1] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.1) ## [1.2.1] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.1)
#### 22/11/14 #### 22/11/14
- *Merged pull-request:* Issues for last tag not in list [\#29](https://github.com/skywinder/Github-Changelog-Generator/pull/29) ([skywinder](https://github.com/skywinder)) - *Merged pull-request:* Issues for last tag not in list [\#29](https://github.com/skywinder/Github-Changelog-Generator/pull/29) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Disable default --filter-pull-requests option. [\#28](https://github.com/skywinder/Github-Changelog-Generator/pull/28) ([skywinder](https://github.com/skywinder)) - *Merged pull-request:* Disable default --filter-pull-requests option. [\#28](https://github.com/skywinder/Github-Changelog-Generator/pull/28) ([skywinder](https://github.com/skywinder))
- *Fixed bug:* Script fills changelog only for first 30 tags. [\#20](https://github.com/skywinder/Github-Changelog-Generator/issues/20)
## [1.2.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.0) ## [1.2.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.0)
#### 19/11/14 #### 19/11/14
- *Merged pull-request:* Add filter for pull-requests labels. \(option --filter-pull-requests\) [\#27](https://github.com/skywinder/Github-Changelog-Generator/pull/27) ([skywinder](https://github.com/skywinder)) - *Merged pull-request:* Add filter for pull-requests labels. \(option --filter-pull-requests\) [\#27](https://github.com/skywinder/Github-Changelog-Generator/pull/27) ([skywinder](https://github.com/skywinder))
@ -46,6 +42,8 @@
- *Implemented enhancement:* Implement ability to retrieve GitHub token from ENV variable \(to not put it to script directly\) [\#19](https://github.com/skywinder/Github-Changelog-Generator/issues/19) - *Implemented enhancement:* Implement ability to retrieve GitHub token from ENV variable \(to not put it to script directly\) [\#19](https://github.com/skywinder/Github-Changelog-Generator/issues/19)
- *Fixed bug:* Script fills changelog only for first 30 tags. [\#20](https://github.com/skywinder/Github-Changelog-Generator/issues/20)
## [1.1.2] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.2) ## [1.1.2] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.2)
#### 12/11/14 #### 12/11/14
- *Merged pull-request:* Fix bug with dot signs in project name [\#18](https://github.com/skywinder/Github-Changelog-Generator/pull/18) ([skywinder](https://github.com/skywinder)) - *Merged pull-request:* Fix bug with dot signs in project name [\#18](https://github.com/skywinder/Github-Changelog-Generator/pull/18) ([skywinder](https://github.com/skywinder))

View File

@ -244,39 +244,41 @@ module GitHubChangelogGenerator
end end
#delete excess irrelevant issues (according milestones) if @options[:filter_issues_by_milestone]
filtered_issues.select!{ |issue| #delete excess irrelevant issues (according milestones)
if issue.milestone.nil? filtered_issues.select! { |issue|
true if issue.milestone.nil?
else true
#check, that this milestone in tag list: else
milestone_is_tag = @all_tags.find{|tag| #check, that this milestone in tag list:
tag.name == issue.milestone.title milestone_is_tag = @all_tags.find { |tag|
} tag.name == issue.milestone.title
milestone_is_tag.nil? }
end milestone_is_tag.nil?
end
} }
#add missed issues (according milestones) #add missed issues (according milestones)
issues_to_add = @issues.select{|issue| issues_to_add = @issues.select { |issue|
if issue.milestone.nil? if issue.milestone.nil?
false
else
#check, that this milestone in tag list:
milestone_is_tag = @all_tags.find{|tag|
tag.name == issue.milestone.title
}
if milestone_is_tag.nil?
false false
else else
issue.milestone.title == newer_tag_name #check, that this milestone in tag list:
end milestone_is_tag = @all_tags.find { |tag|
end tag.name == issue.milestone.title
} }
filtered_issues |= issues_to_add if milestone_is_tag.nil?
false
else
issue.milestone.title == newer_tag_name
end
end
}
filtered_issues |= issues_to_add
end
self.create_log(filtered_pull_requests, filtered_issues, newer_tag_name, newer_tag_time) self.create_log(filtered_pull_requests, filtered_issues, newer_tag_name, newer_tag_time)
@ -430,7 +432,7 @@ module GitHubChangelogGenerator
if @options[:add_issues_wo_labels] if @options[:add_issues_wo_labels]
issues_wo_labels = issues.select { issues_wo_labels = issues.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?
} }
filtered_issues.concat(issues_wo_labels) filtered_issues.concat(issues_wo_labels)
end end

View File

@ -6,7 +6,7 @@ require_relative 'version'
module GitHubChangelogGenerator module GitHubChangelogGenerator
class Parser class Parser
def self.parse_options def self.parse_options
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil} options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true}
parser = OptionParser.new { |opts| parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator [options]' opts.banner = 'Usage: changelog_generator [options]'
@ -37,6 +37,9 @@ module GitHubChangelogGenerator
opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v| opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
options[:pulls] = v options[:pulls] = v
end end
opts.on('--[no-]filter-issues-by-milestone', 'Use milestone to detect when issue was resolved. Default is true') do |last|
options[:filter_issues_by_milestone] = last
end
opts.on('--[no-]author', 'Add author of pull-request in the end. Default is true') do |author| opts.on('--[no-]author', 'Add author of pull-request in the end. Default is true') do |author|
options[:last] = author options[:last] = author
end end