From 8dc50cf4836777bca6bb616eaf0347e3c20a23f7 Mon Sep 17 00:00:00 2001 From: sue445 Date: Mon, 26 Jan 2015 21:30:27 +0900 Subject: [PATCH] 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