refactoring

This commit is contained in:
Petr Korolev 2015-02-10 14:36:56 +02:00
parent cf4692c7b0
commit ae92488d6d
2 changed files with 20 additions and 16 deletions

View File

@ -28,17 +28,17 @@
- *Merged pull-request:* Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
- *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)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.2...1.2.3)
#### 16/12/14
- *Implemented enhancement:* Add ability to run with one parameter instead -u -p [\#38](https://github.com/skywinder/Github-Changelog-Generator/issues/38)
- *Implemented enhancement:* Detailed output [\#33](https://github.com/skywinder/Github-Changelog-Generator/issues/33)
- *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)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.2...1.2.3)
#### 16/12/14
## [1.2.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.1...1.2.2)
#### 10/12/14
@ -101,11 +101,11 @@
## [1.0.1](https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.1)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.0.0...1.0.1)
#### 10/11/14
- *Merged pull-request:* 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)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.1.0...1.0.0)
#### 07/11/14
- *Merged pull-request:* Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3) ([skywinder](https://github.com/skywinder))

View File

@ -38,7 +38,7 @@ module GitHubChangelogGenerator
@generator = Generator.new(@options)
@all_tags = self.get_all_tags
@pull_requests = self.get_all_closed_pull_requests
@pull_requests = self.get_filtered_pull_requests
if @options[:issues]
@issues = self.get_all_issues
else
@ -57,13 +57,10 @@ module GitHubChangelogGenerator
%x[#{exec_cmd}]
end
def get_all_closed_pull_requests
if @options[:verbose]
print "Fetching pull requests...\r"
end
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
pull_requests = []
@ -73,13 +70,19 @@ module GitHubChangelogGenerator
print "Fetching pull requests... #{page_i}\r"
pull_requests.concat(page)
end
print "\r"
if @options[:verbose]
puts "Received closed pull requests: #{pull_requests.count}"
end
pull_requests
end
def get_filtered_pull_requests
pull_requests = self.get_all_closed_pull_requests
unless @options[:pull_request_labels].nil?
if @options[:verbose]
@ -87,10 +90,11 @@ module GitHubChangelogGenerator
end
filtered_pull_requests = pull_requests.select { |pull_request|
#We need issue to fetch labels
#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
select_no_label = !issue.labels.map { |label| label.name }.any?
issue_without_labels = !issue.labels.map { |label| label.name }.any?
if @options[:verbose]
puts "Filter request \##{issue.number}."
@ -102,7 +106,7 @@ module GitHubChangelogGenerator
select_by_label = false
end
select_by_label | select_no_label
select_by_label | issue_without_labels
}
if @options[:verbose]
@ -116,7 +120,7 @@ module GitHubChangelogGenerator
def compund_changelog
if @options[:verbose]
puts 'Generating changelog:'
puts 'Generating changelog...'
end
log = "# Changelog\n\n"