From 69e3b17d8b07525d197bd0115463713f2059702c Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 6 Feb 2015 16:36:52 +0200 Subject: [PATCH 01/20] Check for exception --- lib/github_changelog_generator/parser.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 1afc786..7f3acbc 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -72,15 +72,23 @@ module GitHubChangelogGenerator if ARGV[0] && !ARGV[1] 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]) - 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 else options[:user] = match[1] options[:project]= match[2] end + + end if !options[:user] && !options[:project] From cf4692c7b02e969c53f1f362b490f4b9b6d49c63 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Mon, 9 Feb 2015 17:52:45 +0200 Subject: [PATCH 02/20] fix #37 --- lib/github_changelog_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 9f8124e..51f92f1 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -294,7 +294,7 @@ module GitHubChangelogGenerator def delete_by_time(array, hash_key, newer_tag_time, older_tag_time = nil) array.select { |req| if req[hash_key] - t = Time.parse(req[hash_key]).utc + t = Time.parse(req[hash_key]).utc - 60 if older_tag_time.nil? tag_in_range_old = true From ae92488d6d905a4c3df61564dc703e9e053ef717 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 10 Feb 2015 14:36:56 +0200 Subject: [PATCH 03/20] refactoring --- CHANGELOG.md | 14 +++++++------- lib/github_changelog_generator.rb | 22 +++++++++++++--------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9e4479..d0fddcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 51f92f1..c2a2b2d 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -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" From f668aedafc28527b3721609ba773208536d5c44b Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Thu, 12 Feb 2015 13:49:41 +0200 Subject: [PATCH 04/20] prettify help message --- lib/github_changelog_generator/parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 7f3acbc..6aa4533 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -31,13 +31,13 @@ module GitHubChangelogGenerator opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v| options[:issues] = v 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 end opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v| options[:pulls] = v 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 end opts.on('--[no-]author', 'Add author of pull-request in the end. Default is true') do |author| From e6f12421ff86ca5c7fbaaff08c6d1761d33dc7e9 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 13 Feb 2015 15:17:46 +0200 Subject: [PATCH 05/20] Prettify output --- lib/github_changelog_generator.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index c2a2b2d..e6af016 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -67,10 +67,11 @@ module GitHubChangelogGenerator page_i = 0 response.each_page do |page| 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) end - print "\r" + print " \r" if @options[:verbose] puts "Received closed pull requests: #{pull_requests.count}" @@ -203,12 +204,13 @@ module GitHubChangelogGenerator tags = [] page_i = 0 + count_pages = response.count_pages response.each_page do |page| 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) end - print "\r" + print " \r" if @options[:verbose] puts "Found #{tags.count} tags" end @@ -421,13 +423,18 @@ module GitHubChangelogGenerator issues = [] page_i = 0 + count_pages = response.count_pages response.each_page do |page| 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) end - - print "\r" + # + # print " \r" + # + # # if @options[:verbose] + # puts "Received issues...: #{issues.count}" + # end # remove pull request from issues: issues.select! { |x| From 1eee70bfe54dadbd4961da32bd1c839af63046fa Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 13 Feb 2015 15:28:01 +0200 Subject: [PATCH 06/20] fixes --- lib/github_changelog_generator.rb | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index e6af016..3bb524e 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -71,10 +71,10 @@ module GitHubChangelogGenerator print "Fetching pull requests... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r" pull_requests.concat(page) end - print " \r" + print " \r" if @options[:verbose] - puts "Received closed pull requests: #{pull_requests.count}" + puts "Received pull requests: #{pull_requests.count}" end pull_requests @@ -120,9 +120,6 @@ module GitHubChangelogGenerator end def compund_changelog - if @options[:verbose] - puts 'Generating changelog...' - end log = "# Changelog\n\n" @@ -210,7 +207,7 @@ module GitHubChangelogGenerator print "Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r" tags.concat(page) end - print " \r" + print " \r" if @options[:verbose] puts "Found #{tags.count} tags" end @@ -429,23 +426,18 @@ module GitHubChangelogGenerator print "Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r" issues.concat(page) end - # - # print " \r" - # - # # if @options[:verbose] - # puts "Received issues...: #{issues.count}" - # end + + print " \r" + + if @options[:verbose] + puts "Received issues: #{issues.count}" + end # remove pull request from issues: issues.select! { |x| 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 From 4431f264578bd18998efaadceafa20e2440e28bc Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 13 Feb 2015 15:17:46 +0200 Subject: [PATCH 07/20] Prettify output --- lib/github_changelog_generator.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index c2a2b2d..e6af016 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -67,10 +67,11 @@ module GitHubChangelogGenerator page_i = 0 response.each_page do |page| 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) end - print "\r" + print " \r" if @options[:verbose] puts "Received closed pull requests: #{pull_requests.count}" @@ -203,12 +204,13 @@ module GitHubChangelogGenerator tags = [] page_i = 0 + count_pages = response.count_pages response.each_page do |page| 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) end - print "\r" + print " \r" if @options[:verbose] puts "Found #{tags.count} tags" end @@ -421,13 +423,18 @@ module GitHubChangelogGenerator issues = [] page_i = 0 + count_pages = response.count_pages response.each_page do |page| 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) end - - print "\r" + # + # print " \r" + # + # # if @options[:verbose] + # puts "Received issues...: #{issues.count}" + # end # remove pull request from issues: issues.select! { |x| From cf0a032fb64b49080385ce0ae67f0b99154fe277 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 19:45:11 +0200 Subject: [PATCH 08/20] refactoring --- lib/github_changelog_generator.rb | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 3bb524e..a2c1b76 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -242,17 +242,10 @@ module GitHubChangelogGenerator newer_tag_time = self.get_time_of_tag(newer_tag) newer_tag_name = newer_tag['name'] - if older_tag.nil? - older_tag_name = nil - 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 + filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, newer_tag_time, older_tag) + filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time, older_tag) + older_tag_name = older_tag.nil? ? nil : older_tag['name'] if @options[:filter_issues_by_milestone] #delete excess irrelevant issues (according milestones) @@ -294,7 +287,10 @@ module GitHubChangelogGenerator 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| if req[hash_key] t = Time.parse(req[hash_key]).utc - 60 @@ -398,16 +394,20 @@ module GitHubChangelogGenerator log end - def get_time_of_tag(prev_tag) + def get_time_of_tag(tag_name) - if @tag_times_hash[prev_tag['name']] - return @tag_times_hash[prev_tag['name']] + if tag_name.nil? + return nil 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.parse(time_string) - @tag_times_hash[prev_tag['name']] = Time.parse(time_string) + @tag_times_hash[tag_name['name']] = Time.parse(time_string) end def get_all_issues From 7d526de16533a4c1715cde6d3e7d9afbc83d2970 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 20:49:32 +0200 Subject: [PATCH 09/20] add test changelog file --- .gitignore | 1 - lib/CHANGELOG.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 lib/CHANGELOG.md diff --git a/.gitignore b/.gitignore index e9ed99d..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -/lib/CHANGELOG.md diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md new file mode 100644 index 0000000..1fef52d --- /dev/null +++ b/lib/CHANGELOG.md @@ -0,0 +1,28 @@ +# Changelog + +## [1.2.0](https://github.com/runar/gittest/tree/1.2.0) +[Full Changelog](https://github.com/runar/gittest/compare/1.1.1...1.2.0) +#### 14/02/15 +- *Merged pull-request:* Add ipsum feature [\#6](https://github.com/runar/gittest/pull/6) ([runar](https://github.com/runar)) + +- *Implemented enhancement:* Enhancement issue [\#5](https://github.com/runar/gittest/issues/5) + +- *Fixed bug:* Bug issue [\#4](https://github.com/runar/gittest/issues/4) + +## [1.1.1](https://github.com/runar/gittest/tree/1.1.1) +[Full Changelog](https://github.com/runar/gittest/compare/1.1.0...1.1.1) +#### 14/02/15 +- *Fixed bug:* Text in lorem should be capitalized [\#3](https://github.com/runar/gittest/issues/3) + +## [1.1.0](https://github.com/runar/gittest/tree/1.1.0) +[Full Changelog](https://github.com/runar/gittest/compare/1.0.0...1.1.0) +#### 14/02/15 +- *Implemented enhancement:* Add lorem file [\#1](https://github.com/runar/gittest/issues/1) + +## [1.0.0](https://github.com/runar/gittest/tree/1.0.0) +#### 14/02/15 +- *Merged pull-request:* Add lorem file [\#2](https://github.com/runar/gittest/pull/2) ([runar](https://github.com/runar)) + + + +\* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file From 4b59f3bd653bc014ffec025ebd33392849e33274 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 21:18:52 +0200 Subject: [PATCH 10/20] thread saety fix --- lib/github_changelog_generator.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index a2c1b76..53e4b6f 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -161,10 +161,15 @@ module GitHubChangelogGenerator def generate_log_for_all_tags log = '' + if @options[:verbose] + puts "Fetching tags dates.." + end + # Async fetching tags: threads = [] @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 } @@ -394,19 +399,18 @@ module GitHubChangelogGenerator log end - def get_time_of_tag(tag_name) + def get_time_of_tag(tag_name, tag_times_hash = @tag_times_hash) if tag_name.nil? return nil end - if @tag_times_hash[tag_name['name']] + 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.parse(time_string) @tag_times_hash[tag_name['name']] = Time.parse(time_string) end From 721357d65f578d2de35da8210baec71233947ece Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 22:41:04 +0200 Subject: [PATCH 11/20] changelog --- lib/CHANGELOG.md | 139 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 122 insertions(+), 17 deletions(-) diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index 1fef52d..c8a886c 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -1,28 +1,133 @@ # Changelog -## [1.2.0](https://github.com/runar/gittest/tree/1.2.0) -[Full Changelog](https://github.com/runar/gittest/compare/1.1.1...1.2.0) -#### 14/02/15 -- *Merged pull-request:* Add ipsum feature [\#6](https://github.com/runar/gittest/pull/6) ([runar](https://github.com/runar)) +## [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)) -- *Implemented enhancement:* Enhancement issue [\#5](https://github.com/runar/gittest/issues/5) +## [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)) -- *Fixed bug:* Bug issue [\#4](https://github.com/runar/gittest/issues/4) +## [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)) -## [1.1.1](https://github.com/runar/gittest/tree/1.1.1) -[Full Changelog](https://github.com/runar/gittest/compare/1.1.0...1.1.1) -#### 14/02/15 -- *Fixed bug:* Text in lorem should be capitalized [\#3](https://github.com/runar/gittest/issues/3) +- *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)) -## [1.1.0](https://github.com/runar/gittest/tree/1.1.0) -[Full Changelog](https://github.com/runar/gittest/compare/1.0.0...1.1.0) -#### 14/02/15 -- *Implemented enhancement:* Add lorem file [\#1](https://github.com/runar/gittest/issues/1) +- *Implemented enhancement:* Use milestone to specify in which version bug was fixed [\#22](https://github.com/skywinder/Github-Changelog-Generator/issues/22) -## [1.0.0](https://github.com/runar/gittest/tree/1.0.0) -#### 14/02/15 -- *Merged pull-request:* Add lorem file [\#2](https://github.com/runar/gittest/pull/2) ([runar](https://github.com/runar)) +- *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)) + +- *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) + +## [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 +- *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:* 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)* \ No newline at end of file From 70543e854b0893344aa8f6e31b81207401bab56d Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 23:30:24 +0200 Subject: [PATCH 12/20] update changelog --- lib/CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index c8a886c..e291b16 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -28,13 +28,13 @@ - *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:* 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) @@ -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)) From c73142e16924bbf5721367d4fd018db25a1cdca0 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 19:59:58 +0200 Subject: [PATCH 13/20] Revert "fix #37" This reverts commit cf4692c7b02e969c53f1f362b490f4b9b6d49c63. --- lib/github_changelog_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 53e4b6f..70bbc9c 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -298,7 +298,7 @@ module GitHubChangelogGenerator array.select { |req| if req[hash_key] - t = Time.parse(req[hash_key]).utc - 60 + t = Time.parse(req[hash_key]).utc if older_tag_time.nil? tag_in_range_old = true From 2cd6ba620d5e921ed264ff50f39f92ec3441cb7d Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 21:16:58 +0200 Subject: [PATCH 14/20] Async fetch events --- lib/github_changelog_generator.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 70bbc9c..e6c6e09 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -460,7 +460,22 @@ module GitHubChangelogGenerator end if @options[:verbose] - puts "Filtered issues: #{filtered_issues.count}" + print "Fetching events for issues...\r" + end + + # Async fetching events: + threads = [] + + 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 + } + threads.each { |thr| thr.join } + } + + if @options[:verbose] + puts "Fetching events for issues: Done!" end filtered_issues From c3884b9a55f595e9c9cf9dcf00534c1cf31a6947 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 22:39:37 +0200 Subject: [PATCH 15/20] cm --- lib/github_changelog_generator.rb | 51 +++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index e6c6e09..d9ddeba 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -41,6 +41,8 @@ module GitHubChangelogGenerator @pull_requests = self.get_filtered_pull_requests if @options[:issues] @issues = self.get_all_issues + fetch_event_for_issues(@issues) + detect_actual_closed_dates else @issues = [] end @@ -48,6 +50,24 @@ module GitHubChangelogGenerator @tag_times_hash = {} end + def detect_actual_closed_dates + @issues.each{|issue| + closed_date = find_closed_date_by_commit(issue) + + } + + end + + def find_closed_date_by_commit(issue) + puts issue[:number] + unless issue['events'].nil? + issue['events'].each{|event| + puts event[:event] + } + end + 0 + end + def print_json(json) puts JSON.pretty_generate(json) end @@ -442,15 +462,12 @@ module GitHubChangelogGenerator x.pull_request == nil } - 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| #compare is there any labels from @options[:labels] array (issue.labels.map { |label| label.name } & @options[:labels]).any? } + if @options[:add_issues_wo_labels] issues_wo_labels = issues.select { # add issues without any labels @@ -459,27 +476,37 @@ module GitHubChangelogGenerator filtered_issues.concat(issues_wo_labels) end + if @options[:verbose] - print "Fetching events for issues...\r" + puts "Filtered issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}: #{filtered_issues.count}" + end + + filtered_issues + + 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 = [] - filtered_issues.each{|issue| - threads << Thread.new{ - obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: issue['number'] + 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 } } + threads.each { |thr| thr.join } if @options[:verbose] puts "Fetching events for issues: Done!" end - - filtered_issues - end end From 0eacd9acda65d59aa0f05abb4bbc4c03d564cc47 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 23:09:07 +0200 Subject: [PATCH 16/20] put in actual date right closed date --- lib/github_changelog_generator.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index d9ddeba..87c150f 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -59,13 +59,24 @@ module GitHubChangelogGenerator end def find_closed_date_by_commit(issue) + closed_date = nil puts issue[:number] unless issue['events'].nil? - issue['events'].each{|event| - puts event[:event] + # 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 - 0 + closed_date end def print_json(json) From 04f1173616fd82969f1ac176308240f4081a0d6e Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 23:21:19 +0200 Subject: [PATCH 17/20] Make it works async and fast! --- lib/github_changelog_generator.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 87c150f..720b78a 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -51,16 +51,28 @@ module GitHubChangelogGenerator end def detect_actual_closed_dates - @issues.each{|issue| - closed_date = find_closed_date_by_commit(issue) + 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 + + return 0 end def find_closed_date_by_commit(issue) - closed_date = nil - puts issue[:number] unless issue['events'].nil? # reverse! - to find latest closed event. (event goes in date order) issue['events'].reverse!.each{|event| @@ -71,12 +83,10 @@ module GitHubChangelogGenerator commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id] issue[:actual_date] = commit[:author][:date] end - break end } end - closed_date end def print_json(json) From 3a9eca4233bc60ce89d90d7673c49b7152fe2a14 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 23:25:14 +0200 Subject: [PATCH 18/20] add todo reminder --- lib/github_changelog_generator.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 720b78a..99c5c9c 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -67,9 +67,6 @@ module GitHubChangelogGenerator if @options[:verbose] puts 'Fetching close commit date for issues: Done!' end - - return 0 - end def find_closed_date_by_commit(issue) @@ -87,6 +84,7 @@ module GitHubChangelogGenerator end } end + #TODO: assert issues, that remain without 'actual_date' hash for some reason. end def print_json(json) From 9d49b1488ac2c2b6fe02fb7976ddca7a4c0ce9e9 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 17 Feb 2015 23:29:08 +0200 Subject: [PATCH 19/20] Finaly fixed! Thanks, @runar ! :) Fix #37. --- lib/github_changelog_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 99c5c9c..49d611b 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -287,7 +287,7 @@ module GitHubChangelogGenerator newer_tag_name = newer_tag['name'] filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, newer_tag_time, older_tag) - filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time, older_tag) + filtered_issues = delete_by_time(@issues, :actual_date, newer_tag_time, older_tag) older_tag_name = older_tag.nil? ? nil : older_tag['name'] From e50ab5318d472569b3ff278c88be32496f5b8ea4 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 18 Feb 2015 00:48:41 +0200 Subject: [PATCH 20/20] Update gemspec to version 1.2.8 --- 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 6dd9262..361039c 100644 --- a/lib/github_changelog_generator/version.rb +++ b/lib/github_changelog_generator/version.rb @@ -1,3 +1,3 @@ module GitHubChangelogGenerator - VERSION = '1.2.7' + VERSION = '1.2.8' end