Merge branch 'release/1.2.8'

This commit is contained in:
Petr Korolev 2015-02-18 00:48:42 +02:00
commit 54166a444a
6 changed files with 267 additions and 59 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
/lib/CHANGELOG.md

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)) - *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:* 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) - *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:* 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) ## [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) [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.1...1.2.2)
#### 10/12/14 #### 10/12/14
@ -101,11 +101,11 @@
## [1.0.1](https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.1) ## [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) [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.0.0...1.0.1)
#### 10/11/14 #### 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) ## [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) [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.1.0...1.0.0)
#### 07/11/14 #### 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:* 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)) - *Merged pull-request:* Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3) ([skywinder](https://github.com/skywinder))

133
lib/CHANGELOG.md Normal file
View File

@ -0,0 +1,133 @@
# Changelog
## [1.2.7](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.7)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.6...1.2.7)
#### 26/01/15
- *Merged pull-request:* Add compare link between older version and newer version [\#46](https://github.com/skywinder/Github-Changelog-Generator/pull/46) ([sue445](https://github.com/sue445))
## [1.2.6](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.6)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.5...1.2.6)
#### 21/01/15
- *Merged pull-request:* fix link tag format [\#45](https://github.com/skywinder/Github-Changelog-Generator/pull/45) ([sugamasao](https://github.com/sugamasao))
## [1.2.5](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.5)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.4...1.2.5)
#### 15/01/15
- *Merged pull-request:* PrettyPrint class is included using lowercase 'pp' [\#43](https://github.com/skywinder/Github-Changelog-Generator/pull/43) ([schwing](https://github.com/schwing))
- *Merged pull-request:* support enterprise github via command line options [\#42](https://github.com/skywinder/Github-Changelog-Generator/pull/42) ([glenlovett](https://github.com/glenlovett))
- *Implemented enhancement:* Use milestone to specify in which version bug was fixed [\#22](https://github.com/skywinder/Github-Changelog-Generator/issues/22)
- *Fixed bug:* Error when trying to generate log for repo without tags [\#32](https://github.com/skywinder/Github-Changelog-Generator/issues/32)
## [1.2.4](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.4)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.3...1.2.4)
#### 16/12/14
- *Merged pull-request:* Fix crash when user is NULL [\#40](https://github.com/skywinder/Github-Changelog-Generator/pull/40) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
- *Implemented enhancement:* Add ability to run with one parameter instead -u -p [\#38](https://github.com/skywinder/Github-Changelog-Generator/issues/38)
- *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:* 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)
## [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
- *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)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.0...1.2.1)
#### 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:* 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)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.1.4...1.2.0)
#### 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:* Test Pull-Request SHOULD NOT APPEAR IN LOG! [\#26](https://github.com/skywinder/Github-Changelog-Generator/pull/26) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Add ability to insert authors of pull-requests \(--\[no-\]author option\) [\#25](https://github.com/skywinder/Github-Changelog-Generator/pull/25) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Don't receive issues in case of --no-isses flag specied [\#24](https://github.com/skywinder/Github-Changelog-Generator/pull/24) ([skywinder](https://github.com/skywinder))
## [1.1.4](https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.4)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.1.2...1.1.4)
#### 18/11/14
- *Merged pull-request:* Sort tags by date [\#23](https://github.com/skywinder/Github-Changelog-Generator/pull/23) ([skywinder](https://github.com/skywinder))
- *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)
## [1.1.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.2)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.1.1...1.1.2)
#### 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 user name [\#17](https://github.com/skywinder/Github-Changelog-Generator/pull/17) ([skywinder](https://github.com/skywinder))
## [1.1.1](https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.1)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.1.0...1.1.1)
#### 10/11/14
- *Merged pull-request:* Remove duplicates of issues and pull-requests with same number [\#15](https://github.com/skywinder/Github-Changelog-Generator/pull/15) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Sort issues by tags [\#14](https://github.com/skywinder/Github-Changelog-Generator/pull/14) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Add ability to add or exclude issues without any labels [\#13](https://github.com/skywinder/Github-Changelog-Generator/pull/13) ([skywinder](https://github.com/skywinder))
## [1.1.0](https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.0)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.0.1...1.1.0)
#### 10/11/14
- *Implemented enhancement:* Detect username and project form origin [\#11](https://github.com/skywinder/Github-Changelog-Generator/issues/11)
- *Fixed bug:* Markdown formating in the last line wrong [\#9](https://github.com/skywinder/Github-Changelog-Generator/issues/9)
- *Fixed bug:* Bug with wrong credentials in 1.0.1 [\#12](https://github.com/skywinder/Github-Changelog-Generator/issues/12)
## [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
## [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))
- *Implemented enhancement:* Implement option to specify output filename [\#4](https://github.com/skywinder/Github-Changelog-Generator/issues/4)
- *Implemented enhancement:* Add support for fixed issues and implemented enchanments. [\#6](https://github.com/skywinder/Github-Changelog-Generator/issues/6)
- *Fixed bug:* Last tag not appeared in changelog [\#5](https://github.com/skywinder/Github-Changelog-Generator/issues/5)
## [0.1.0](https://github.com/skywinder/Github-Changelog-Generator/tree/0.1.0)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.0.2...0.1.0)
#### 07/11/14
- *Merged pull-request:* Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Add option \(-o --output\) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1) ([skywinder](https://github.com/skywinder))
## [0.0.2](https://github.com/skywinder/Github-Changelog-Generator/tree/0.0.2)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.0.1...0.0.2)
#### 06/11/14
## [0.0.1](https://github.com/skywinder/Github-Changelog-Generator/tree/0.0.1)
#### 06/11/14
\* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

View File

@ -38,9 +38,11 @@ module GitHubChangelogGenerator
@generator = Generator.new(@options) @generator = Generator.new(@options)
@all_tags = self.get_all_tags @all_tags = self.get_all_tags
@pull_requests = self.get_all_closed_pull_requests @pull_requests = self.get_filtered_pull_requests
if @options[:issues] if @options[:issues]
@issues = self.get_all_issues @issues = self.get_all_issues
fetch_event_for_issues(@issues)
detect_actual_closed_dates
else else
@issues = [] @issues = []
end end
@ -48,6 +50,43 @@ module GitHubChangelogGenerator
@tag_times_hash = {} @tag_times_hash = {}
end end
def detect_actual_closed_dates
if @options[:verbose]
print "Fetching close commit date for issues...\r"
end
threads = []
@issues.each{|issue|
threads << Thread.new {
find_closed_date_by_commit(issue)
}
}
threads.each { |thr| thr.join }
if @options[:verbose]
puts 'Fetching close commit date for issues: Done!'
end
end
def find_closed_date_by_commit(issue)
unless issue['events'].nil?
# reverse! - to find latest closed event. (event goes in date order)
issue['events'].reverse!.each{|event|
if event[:event].eql? 'closed'
if event[:commit_id].nil?
issue[:actual_date] = issue[:closed_at]
else
commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id]
issue[:actual_date] = commit[:author][:date]
end
break
end
}
end
#TODO: assert issues, that remain without 'actual_date' hash for some reason.
end
def print_json(json) def print_json(json)
puts JSON.pretty_generate(json) puts JSON.pretty_generate(json)
end end
@ -57,29 +96,33 @@ module GitHubChangelogGenerator
%x[#{exec_cmd}] %x[#{exec_cmd}]
end end
def get_all_closed_pull_requests def get_all_closed_pull_requests
if @options[:verbose] if @options[:verbose]
print "Fetching pull requests...\r" print "Fetching pull requests...\r"
end end
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed' response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
pull_requests = [] pull_requests = []
page_i = 0 page_i = 0
response.each_page do |page| response.each_page do |page|
page_i += PER_PAGE_NUMBER page_i += PER_PAGE_NUMBER
print "Fetching pull requests... #{page_i}\r" count_pages = response.count_pages
print "Fetching pull requests... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
pull_requests.concat(page) pull_requests.concat(page)
end end
print " \r" print " \r"
if @options[:verbose] if @options[:verbose]
puts "Received closed pull requests: #{pull_requests.count}" puts "Received pull requests: #{pull_requests.count}"
end end
pull_requests
end
def get_filtered_pull_requests
pull_requests = self.get_all_closed_pull_requests
unless @options[:pull_request_labels].nil? unless @options[:pull_request_labels].nil?
if @options[:verbose] if @options[:verbose]
@ -87,10 +130,11 @@ module GitHubChangelogGenerator
end end
filtered_pull_requests = pull_requests.select { |pull_request| 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 issue = @github.issues.get @options[:user], @options[:project], pull_request.number
#compare is there any labels from @options[:labels] array #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] if @options[:verbose]
puts "Filter request \##{issue.number}." puts "Filter request \##{issue.number}."
@ -102,7 +146,7 @@ module GitHubChangelogGenerator
select_by_label = false select_by_label = false
end end
select_by_label | select_no_label select_by_label | issue_without_labels
} }
if @options[:verbose] if @options[:verbose]
@ -115,9 +159,6 @@ module GitHubChangelogGenerator
end end
def compund_changelog def compund_changelog
if @options[:verbose]
puts 'Generating changelog:'
end
log = "# Changelog\n\n" log = "# Changelog\n\n"
@ -159,10 +200,15 @@ module GitHubChangelogGenerator
def generate_log_for_all_tags def generate_log_for_all_tags
log = '' log = ''
if @options[:verbose]
puts "Fetching tags dates.."
end
# Async fetching tags: # Async fetching tags:
threads = [] threads = []
@all_tags.each { |tag| @all_tags.each { |tag|
threads << Thread.new { self.get_time_of_tag(tag) } # explicit set @tag_times_hash to write data safety.
threads << Thread.new { self.get_time_of_tag(tag, @tag_times_hash) }
} }
threads.each { |thr| thr.join } threads.each { |thr| thr.join }
@ -199,9 +245,10 @@ module GitHubChangelogGenerator
tags = [] tags = []
page_i = 0 page_i = 0
count_pages = response.count_pages
response.each_page do |page| response.each_page do |page|
page_i += PER_PAGE_NUMBER page_i += PER_PAGE_NUMBER
print "Fetching tags... #{page_i}\r" print "Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
tags.concat(page) tags.concat(page)
end end
print " \r" print " \r"
@ -239,17 +286,10 @@ module GitHubChangelogGenerator
newer_tag_time = self.get_time_of_tag(newer_tag) newer_tag_time = self.get_time_of_tag(newer_tag)
newer_tag_name = newer_tag['name'] newer_tag_name = newer_tag['name']
if older_tag.nil? filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, newer_tag_time, older_tag)
older_tag_name = nil filtered_issues = delete_by_time(@issues, :actual_date, newer_tag_time, older_tag)
filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, newer_tag_time)
filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time)
else
older_tag_time = self.get_time_of_tag(older_tag)
older_tag_name = older_tag['name']
filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, newer_tag_time, older_tag_time)
filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time, older_tag_time)
end
older_tag_name = older_tag.nil? ? nil : older_tag['name']
if @options[:filter_issues_by_milestone] if @options[:filter_issues_by_milestone]
#delete excess irrelevant issues (according milestones) #delete excess irrelevant issues (according milestones)
@ -291,7 +331,10 @@ module GitHubChangelogGenerator
end end
def delete_by_time(array, hash_key, newer_tag_time, older_tag_time = nil) def delete_by_time(array, hash_key, newer_tag_time, older_tag = nil)
older_tag_time = self.get_time_of_tag(older_tag)
array.select { |req| array.select { |req|
if req[hash_key] if req[hash_key]
t = Time.parse(req[hash_key]).utc t = Time.parse(req[hash_key]).utc
@ -395,16 +438,19 @@ module GitHubChangelogGenerator
log log
end end
def get_time_of_tag(prev_tag) def get_time_of_tag(tag_name, tag_times_hash = @tag_times_hash)
if @tag_times_hash[prev_tag['name']] if tag_name.nil?
return @tag_times_hash[prev_tag['name']] return nil
end end
github_git_data_commits_get = @github.git_data.commits.get @options[:user], @options[:project], prev_tag['commit']['sha'] if tag_times_hash[tag_name['name']]
return @tag_times_hash[tag_name['name']]
end
github_git_data_commits_get = @github.git_data.commits.get @options[:user], @options[:project], tag_name['commit']['sha']
time_string = github_git_data_commits_get['committer']['date'] time_string = github_git_data_commits_get['committer']['date']
Time.parse(time_string) @tag_times_hash[tag_name['name']] = Time.parse(time_string)
@tag_times_hash[prev_tag['name']] = Time.parse(time_string)
end end
def get_all_issues def get_all_issues
@ -417,33 +463,30 @@ module GitHubChangelogGenerator
issues = [] issues = []
page_i = 0 page_i = 0
count_pages = response.count_pages
response.each_page do |page| response.each_page do |page|
page_i += PER_PAGE_NUMBER page_i += PER_PAGE_NUMBER
print "Fetching closed issues... #{page_i}\r" print "Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
issues.concat(page) issues.concat(page)
end end
print " \r" print " \r"
if @options[:verbose]
puts "Received issues: #{issues.count}"
end
# remove pull request from issues: # remove pull request from issues:
issues.select! { |x| issues.select! { |x|
x.pull_request == nil x.pull_request == nil
} }
if @options[:verbose]
puts "Received closed issues: #{issues.count}"
end
if @options[:verbose]
puts "Filtering issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}"
end
filtered_issues = issues.select { |issue| filtered_issues = issues.select { |issue|
#compare is there any labels from @options[:labels] array #compare is there any labels from @options[:labels] array
(issue.labels.map { |label| label.name } & @options[:labels]).any? (issue.labels.map { |label| label.name } & @options[:labels]).any?
} }
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
@ -452,14 +495,39 @@ module GitHubChangelogGenerator
filtered_issues.concat(issues_wo_labels) filtered_issues.concat(issues_wo_labels)
end end
if @options[:verbose] if @options[:verbose]
puts "Filtered issues: #{filtered_issues.count}" puts "Filtered issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}: #{filtered_issues.count}"
end end
filtered_issues filtered_issues
end end
def fetch_event_for_issues(filtered_issues)
if @options[:verbose]
print "Fetching events for issues: 0/#{filtered_issues.count}\r"
end
# Async fetching events:
threads = []
i = 0
filtered_issues.each { |issue|
threads << Thread.new {
obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: issue['number']
issue[:events] = obj.body
print "Fetching events for issues: #{i+1}/#{filtered_issues.count}\r"
i +=1
}
}
threads.each { |thr| thr.join }
if @options[:verbose]
puts "Fetching events for issues: Done!"
end
end
end end
if __FILE__ == $0 if __FILE__ == $0

View File

@ -31,13 +31,13 @@ module GitHubChangelogGenerator
opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v| opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v|
options[:issues] = v options[:issues] = v
end end
opts.on('--[no-]issues-without-labels', 'Include closed issues without any labels to changelog. Default is true') do |v| opts.on('--[no-]issues-wo-labels', 'Include closed issues without any labels to changelog. Default is true') do |v|
options[:add_issues_wo_labels] = v options[:add_issues_wo_labels] = v
end end
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| opts.on('--[no-]filter-by-milestone', 'Use milestone to detect when issue was resolved. Default is true') do |last|
options[:filter_issues_by_milestone] = last options[:filter_issues_by_milestone] = last
end 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|
@ -72,15 +72,23 @@ module GitHubChangelogGenerator
if ARGV[0] && !ARGV[1] if ARGV[0] && !ARGV[1]
github_site = options[:github_site] ? options[:github_site] : 'github.com' github_site = options[:github_site] ? options[:github_site] : 'github.com'
# this match should parse https://github.com/skywinder/Github-Changelog-Generator and skywinder/Github-Changelog-Generator to user and name # this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or "skywinder/Github-Changelog-Generator" to user and name
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(ARGV[0]) match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(ARGV[0])
if match[2].nil? begin
param = match[2].nil?
rescue
puts "Can't detect user and name from first parameter: '#{ARGV[0]}' -> exit'"
exit
end
if param
exit exit
else else
options[:user] = match[1] options[:user] = match[1]
options[:project]= match[2] options[:project]= match[2]
end end
end end
if !options[:user] && !options[:project] if !options[:user] && !options[:project]

View File

@ -1,3 +1,3 @@
module GitHubChangelogGenerator module GitHubChangelogGenerator
VERSION = '1.2.7' VERSION = '1.2.8'
end end