From 4ba7bbcc907f29c56bae4ae7e8034e89fd40cb28 Mon Sep 17 00:00:00 2001 From: sue445 Date: Sat, 24 Jan 2015 21:42:11 +0900 Subject: [PATCH 1/5] Add compare link between older version and newer version --- lib/github_changelog_generator.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index dcf2e16..33d3fdf 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -240,10 +240,12 @@ module GitHubChangelogGenerator 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 @@ -285,7 +287,7 @@ module GitHubChangelogGenerator 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, older_tag_name) end @@ -315,13 +317,19 @@ module GitHubChangelogGenerator # @param [Array] issues # @param [String] tag_name # @param [String] tag_time +# @param [String] older_tag_name # @return [String] - def create_log(pull_requests, issues, tag_name, tag_time) + def create_log(pull_requests, issues, tag_name, tag_time, older_tag_name = nil) github_site = options[:github_site] || 'https://github.com' + project_url = "#{github_site}/#{@options[:user]}/#{@options[:project]}" + # Generate tag name and link - log = "## [#{tag_name}](#{github_site}/#{@options[:user]}/#{@options[:project]}/tree/#{tag_name})\n" + log = "## [#{tag_name}](#{project_url}/tree/#{tag_name})\n" + + # Generate compare link + log += "[Full Changelog](#{project_url}/compare/#{older_tag_name}...#{tag_name})\n" if older_tag_name #Generate date string: time_string = tag_time.strftime @options[:format] @@ -456,4 +464,4 @@ module GitHubChangelogGenerator GitHubChangelogGenerator::ChangelogGenerator.new.compund_changelog end -end \ No newline at end of file +end From 41f43932e0f2e45ecea543331bdef5431be48d27 Mon Sep 17 00:00:00 2001 From: sue445 Date: Sat, 24 Jan 2015 21:44:34 +0900 Subject: [PATCH 2/5] Refactorings * tweak indent * rename variable name (tag_xxx -> newer_tag_xxx) --- lib/github_changelog_generator.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 33d3fdf..65db5bb 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -313,26 +313,26 @@ module GitHubChangelogGenerator } end -# @param [Array] pull_requests -# @param [Array] issues -# @param [String] tag_name -# @param [String] tag_time -# @param [String] older_tag_name -# @return [String] - def create_log(pull_requests, issues, tag_name, tag_time, older_tag_name = nil) + # @param [Array] pull_requests + # @param [Array] issues + # @param [String] newer_tag_name + # @param [String] newer_tag_time + # @param [String] older_tag_name + # @return [String] + def create_log(pull_requests, issues, newer_tag_name, newer_tag_time, older_tag_name = nil) github_site = options[:github_site] || 'https://github.com' project_url = "#{github_site}/#{@options[:user]}/#{@options[:project]}" # Generate tag name and link - log = "## [#{tag_name}](#{project_url}/tree/#{tag_name})\n" + log = "## [#{newer_tag_name}](#{project_url}/tree/#{newer_tag_name})\n" # Generate compare link - log += "[Full Changelog](#{project_url}/compare/#{older_tag_name}...#{tag_name})\n" if older_tag_name + log += "[Full Changelog](#{project_url}/compare/#{older_tag_name}...#{newer_tag_name})\n" if older_tag_name #Generate date string: - time_string = tag_time.strftime @options[:format] + time_string = newer_tag_time.strftime @options[:format] log += "#### #{time_string}\n" if @options[:pulls] From eb9bd59f261812d0e13032bd6393c18d5a89251d Mon Sep 17 00:00:00 2001 From: sue445 Date: Sat, 24 Jan 2015 21:48:02 +0900 Subject: [PATCH 3/5] regenerate CHANGELOG --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3e9b0a..f4fe6c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # Changelog ## [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)) @@ -15,6 +17,7 @@ - *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)) @@ -29,14 +32,17 @@ - *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 - *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)) @@ -45,6 +51,7 @@ - *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)) @@ -55,18 +62,21 @@ - *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)) @@ -75,6 +85,7 @@ - *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) @@ -83,10 +94,12 @@ - *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)) @@ -99,12 +112,14 @@ - *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 From 1fced7278ed61d8d00e2c5c0e452dc0dd7d3244e Mon Sep 17 00:00:00 2001 From: sue445 Date: Mon, 26 Jan 2015 21:30:27 +0900 Subject: [PATCH 4/5] Add option: --compare-link --- lib/github_changelog_generator.rb | 6 ++++-- lib/github_changelog_generator/parser.rb | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 65db5bb..9f8124e 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -328,8 +328,10 @@ module GitHubChangelogGenerator # Generate tag name and link log = "## [#{newer_tag_name}](#{project_url}/tree/#{newer_tag_name})\n" - # Generate compare link - log += "[Full Changelog](#{project_url}/compare/#{older_tag_name}...#{newer_tag_name})\n" if older_tag_name + if @options[:compare_link] && older_tag_name + # Generate compare link + log += "[Full Changelog](#{project_url}/compare/#{older_tag_name}...#{newer_tag_name})\n" + end #Generate date string: time_string = newer_tag_time.strftime @options[:format] diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index b927b9a..1afc786 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -6,7 +6,7 @@ require_relative 'version' module GitHubChangelogGenerator class Parser 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, :filter_issues_by_milestone => true} + 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, :compare_link => true} parser = OptionParser.new { |opts| opts.banner = 'Usage: changelog_generator [options]' @@ -43,6 +43,9 @@ module GitHubChangelogGenerator opts.on('--[no-]author', 'Add author of pull-request in the end. Default is true') do |author| options[:last] = author end + opts.on('--[no-]compare-link', 'Include compare link between older version and newer version. Default is true') do |v| + options[:compare_link] = v + end opts.on('--labels x,y,z', Array, 'Issues with that labels will be included to changelog. Default is \'bug,enhancement\'') do |list| options[:labels] = list end From 52d1e8388808b41e3aa0d1144eea5672cc0eb1e2 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Mon, 26 Jan 2015 17:01:35 +0200 Subject: [PATCH 5/5] Update changelog for version 1.2.7 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4fe6c5..e9e4479 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # 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