From b3cfe76702bbe57db07a7157cc6feef2540823cb Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 23 Feb 2016 12:38:18 +0200 Subject: [PATCH 1/8] update rubocop todo --- .rubocop_todo.yml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8059430..41a8f1b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,17 @@ -# This configuration was generated by `rubocop --auto-gen-config` -# on 2015-07-16 14:46:25 +0300 using RuboCop version 0.31.0. +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2016-02-23 12:36:44 +0200 using RuboCop version 0.37.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 13 +# Offense count: 1 +Lint/ImplicitStringConcatenation: + Exclude: + - 'lib/github_changelog_generator/parser.rb' + +# Offense count: 14 Metrics/AbcSize: Enabled: false @@ -13,11 +19,11 @@ Metrics/AbcSize: Metrics/CyclomaticComplexity: Max: 7 -# Offense count: 1 +# Offense count: 2 Metrics/PerceivedComplexity: Max: 8 -# Offense count: 2 +# Offense count: 1 Style/AccessorMethodName: Enabled: false @@ -30,13 +36,16 @@ Style/Documentation: Style/GuardClause: Enabled: false -# Offense count: 1 +# Offense count: 2 +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +# SupportedStyles: skip_modifier_ifs, always Style/Next: Enabled: false # Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: Enabled: false From 4fcde1eb2851af994b03274502625f99ffbe596b Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 23 Feb 2016 12:38:27 +0200 Subject: [PATCH 2/8] update rakefile --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 3c6c2ea..755904b 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,7 @@ require "rubocop/rake_task" require "rspec/core/rake_task" require "pathname" require "fileutils" +require "overcommit" RuboCop::RakeTask.new RSpec::Core::RakeTask.new(:rspec) From 88e9a3ec885d1ce263c42d878522c21e6bddc825 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 23 Feb 2016 12:39:49 +0200 Subject: [PATCH 3/8] update gemscpec --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 8452dc5..8841647 100644 --- a/Gemfile +++ b/Gemfile @@ -8,4 +8,5 @@ group :test do gem "coveralls", "~>0.8", require: false gem "simplecov", "~>0.10", require: false gem "codeclimate-test-reporter", "~>0.4" + gem "overcommit", "~>0.31" end From a0f28d33935c5917b7a6d0da13d794ec59056c0f Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 23 Feb 2016 12:40:55 +0200 Subject: [PATCH 4/8] update gemfile --- Gemfile.lock | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index a4bce23..d7250b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,6 +10,8 @@ GEM specs: addressable (2.4.0) ast (2.2.0) + childprocess (0.5.9) + ffi (~> 1.0, >= 1.0.11) codeclimate-test-reporter (0.4.8) simplecov (>= 0.7.1, < 1.0.0) colorize (0.7.7) @@ -25,6 +27,7 @@ GEM docile (1.1.5) faraday (0.9.2) multipart-post (>= 1.2, < 3) + ffi (1.9.10) github_api (0.13.1) addressable (~> 2.4.0) descendants_tracker (~> 0.0.4) @@ -33,6 +36,7 @@ GEM multi_json (>= 1.7.5, < 2.0) oauth2 hashie (3.4.3) + iniparse (1.4.2) json (1.8.3) jwt (1.5.1) multi_json (1.11.2) @@ -44,6 +48,9 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) + overcommit (0.32.0) + childprocess (~> 0.5.8) + iniparse (~> 1.4) parser (2.3.0.6) ast (~> 2.2) powerpack (0.1.1) @@ -90,6 +97,7 @@ DEPENDENCIES codeclimate-test-reporter (~> 0.4) coveralls (~> 0.8) github_changelog_generator! + overcommit (~> 0.31) rake (~> 10.0) rspec (~> 3.2) rubocop (~> 0.31) From 62623ff2dd2af63d19d252d8edfee0664e5d4f2b Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 23 Feb 2016 12:45:14 +0200 Subject: [PATCH 5/8] update changelog --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c47ccf..79cd282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Change Log +## [v1.11.0](https://github.com/skywinder/github-changelog-generator/tree/v1.11.0) (2016-02-23) +[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.11.1...v1.11.0) + +## [1.11.1](https://github.com/skywinder/github-changelog-generator/tree/1.11.1) (2016-02-23) +[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.10.1...1.11.1) + +**Implemented enhancements:** + +- YAML front matter [\#322](https://github.com/skywinder/github-changelog-generator/pull/322) ([retorquere](https://github.com/retorquere)) +- Git Subcommand [\#288](https://github.com/skywinder/github-changelog-generator/pull/288) ([dlanileonardo](https://github.com/dlanileonardo)) + +**Fixed bugs:** + +- detect\_since\_tag undefined [\#328](https://github.com/skywinder/github-changelog-generator/issues/328) + +**Merged pull requests:** + +- Update README.md [\#324](https://github.com/skywinder/github-changelog-generator/pull/324) ([Zearin](https://github.com/Zearin)) + ## [1.10.1](https://github.com/skywinder/github-changelog-generator/tree/1.10.1) (2016-01-06) [Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.10.0...1.10.1) From 2691a3ef96021775e5ae0ea48035215aab712919 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 23 Feb 2016 17:06:55 +0200 Subject: [PATCH 6/8] Revert "Rubocop fixes" This reverts commit fa0267b586a08c634cc1dca28afdafeca6500c7f. --- Gemfile.lock | 2 +- lib/github_changelog_generator.rb | 2 +- lib/github_changelog_generator/fetcher.rb | 16 +++---- .../generator/generator_generation.rb | 44 +++++++++---------- .../generator/generator_processor.rb | 26 +++++------ .../generator/generator_tags.rb | 22 +++++----- lib/github_changelog_generator/helper.rb | 12 ++--- lib/github_changelog_generator/parser_file.rb | 4 +- lib/github_changelog_generator/task.rb | 6 +-- lib/github_changelog_generator/version.rb | 2 +- spec/unit/fetcher_spec.rb | 6 +-- 11 files changed, 71 insertions(+), 71 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d7250b4..c45a0ec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - github_changelog_generator (1.11.0) + github_changelog_generator (1.10.1) colorize (~> 0.7) github_api (~> 0.12) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index c689c95..31d86ae 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -28,7 +28,7 @@ module GitHubChangelogGenerator def run log = @generator.compound_changelog - output_filename = (@options[:output]).to_s + output_filename = "#{@options[:output]}" File.open(output_filename, "w") { |file| file.write(log) } puts "Done!" puts "Generated log placed in #{Dir.pwd}/#{output_filename}" diff --git a/lib/github_changelog_generator/fetcher.rb b/lib/github_changelog_generator/fetcher.rb index f00a943..eef3e6d 100644 --- a/lib/github_changelog_generator/fetcher.rb +++ b/lib/github_changelog_generator/fetcher.rb @@ -7,11 +7,11 @@ module GitHubChangelogGenerator class Fetcher PER_PAGE_NUMBER = 30 - CHANGELOG_GITHUB_TOKEN = "CHANGELOG_GITHUB_TOKEN".freeze + CHANGELOG_GITHUB_TOKEN = "CHANGELOG_GITHUB_TOKEN" GH_RATE_LIMIT_EXCEEDED_MSG = "Warning: Can't finish operation: GitHub API rate limit exceeded, change log may be " \ - "missing some issues. You can limit the number of issues fetched using the `--max-issues NUM` argument.".freeze + "missing some issues. You can limit the number of issues fetched using the `--max-issues NUM` argument." NO_TOKEN_PROVIDED = "Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found. " \ - "This script can make only 50 requests to GitHub API per hour without token!".freeze + "This script can make only 50 requests to GitHub API per hour without token!" def initialize(options = {}) @options = options || {} @@ -123,16 +123,16 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow def fetch_closed_pull_requests pull_requests = [] begin - response = if @options[:release_branch].nil? - @github.pull_requests.list @options[:user], + if @options[:release_branch].nil? + response = @github.pull_requests.list @options[:user], @options[:project], state: "closed" - else - @github.pull_requests.list @options[:user], + else + response = @github.pull_requests.list @options[:user], @options[:project], state: "closed", base: @options[:release_branch] - end + end page_i = 0 count_pages = response.count_pages response.each_page do |page| diff --git a/lib/github_changelog_generator/generator/generator_generation.rb b/lib/github_changelog_generator/generator/generator_generation.rb index b22fe40..cfaafe1 100644 --- a/lib/github_changelog_generator/generator/generator_generation.rb +++ b/lib/github_changelog_generator/generator/generator_generation.rb @@ -12,11 +12,11 @@ module GitHubChangelogGenerator log += @options[:frontmatter] if @options[:frontmatter] log += "#{@options[:header]}\n\n" - log += if @options[:unreleased_only] - generate_log_between_tags(filtered_tags[0], nil) - else - generate_log_for_all_tags - end + if @options[:unreleased_only] + log += generate_log_between_tags(filtered_tags[0], nil) + else + log += generate_log_for_all_tags + end log += File.read(@options[:base]) if File.file?(@options[:base]) @@ -39,10 +39,10 @@ module GitHubChangelogGenerator index2 = hash[tag2] log += generate_log_between_tags(all_tags[index1], all_tags[index2]) else - raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red + fail ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red end else - raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red + fail ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red end log end @@ -79,16 +79,16 @@ module GitHubChangelogGenerator time_string = newer_tag_time.strftime @options[:date_format] # Generate tag name and link - release_url = if @options[:release_url] - format(@options[:release_url], newer_tag_link) - else - "#{project_url}/tree/#{newer_tag_link}" - end - log += if newer_tag_name.equal? @options[:unreleased_label] - "## [#{newer_tag_name}](#{release_url})\n\n" - else - "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n" - end + if @options[:release_url] + release_url = format(@options[:release_url], newer_tag_link) + else + release_url = "#{project_url}/tree/#{newer_tag_link}" + end + if newer_tag_name.equal? @options[:unreleased_label] + log += "## [#{newer_tag_name}](#{release_url})\n\n" + else + log += "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n" + end if @options[:compare_link] && older_tag_link # Generate compare link @@ -171,11 +171,11 @@ module GitHubChangelogGenerator unless issue.pull_request.nil? if @options[:author] - title_with_number += if issue.user.nil? - " ({Null user})" - else - " ([#{issue.user.login}](#{issue.user.html_url}))" - end + if issue.user.nil? + title_with_number += " ({Null user})" + else + title_with_number += " ([#{issue.user.login}](#{issue.user.html_url}))" + end end end title_with_number diff --git a/lib/github_changelog_generator/generator/generator_processor.rb b/lib/github_changelog_generator/generator/generator_processor.rb index 1791711..ae745e6 100644 --- a/lib/github_changelog_generator/generator/generator_processor.rb +++ b/lib/github_changelog_generator/generator/generator_processor.rb @@ -7,7 +7,7 @@ module GitHubChangelogGenerator unless @options[:exclude_labels].nil? issues = issues.select do |issue| var = issue.labels.map(&:name) & @options[:exclude_labels] - !var.any? + !(var).any? end end issues @@ -83,7 +83,7 @@ module GitHubChangelogGenerator tag_in_range_new = tag_older_new_tag?(newer_tag_time, time) - tag_in_range = tag_in_range_old && tag_in_range_new + tag_in_range = (tag_in_range_old) && (tag_in_range_new) tag_in_range else @@ -93,20 +93,20 @@ module GitHubChangelogGenerator end def tag_older_new_tag?(newer_tag_time, time) - tag_in_range_new = if newer_tag_time.nil? - true - else - time <= newer_tag_time - end + if newer_tag_time.nil? + tag_in_range_new = true + else + tag_in_range_new = time <= newer_tag_time + end tag_in_range_new end def tag_newer_old_tag?(older_tag_time, t) - tag_in_range_old = if older_tag_time.nil? - true - else - t > older_tag_time - end + if older_tag_time.nil? + tag_in_range_old = true + else + tag_in_range_old = t > older_tag_time + end tag_in_range_old end @@ -133,7 +133,7 @@ module GitHubChangelogGenerator def filter_by_include_labels(issues) filtered_issues = @options[:include_labels].nil? ? issues : issues.select do |issue| labels = issue.labels.map(&:name) & @options[:include_labels] - labels.any? + (labels).any? end filtered_issues end diff --git a/lib/github_changelog_generator/generator/generator_tags.rb b/lib/github_changelog_generator/generator/generator_tags.rb index fbbc95d..006a345 100644 --- a/lib/github_changelog_generator/generator/generator_tags.rb +++ b/lib/github_changelog_generator/generator/generator_tags.rb @@ -19,7 +19,7 @@ module GitHubChangelogGenerator # @param [Hash] tag_name name of the tag # @return [Time] time of specified tag def get_time_of_tag(tag_name) - raise ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil? + fail ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil? name_of_tag = tag_name["name"] time_for_name = @tag_times_hash[name_of_tag] @@ -80,11 +80,11 @@ module GitHubChangelogGenerator if tag if all_tags.map(&:name).include? tag idx = all_tags.index { |t| t.name == tag } - filtered_tags = if idx > 0 - all_tags[0..idx - 1] - else - [] - end + if idx > 0 + filtered_tags = all_tags[0..idx - 1] + else + filtered_tags = [] + end else Helper.log.warn "Warning: can't find tag #{tag}, specified with --since-tag option." end @@ -101,11 +101,11 @@ module GitHubChangelogGenerator if (all_tags.count > 0) && (all_tags.map(&:name).include? tag) idx = all_tags.index { |t| t.name == tag } last_index = all_tags.count - 1 - filtered_tags = if idx > 0 && idx < last_index - all_tags[idx + 1..last_index] - else - [] - end + if idx > 0 && idx < last_index + filtered_tags = all_tags[idx + 1..last_index] + else + filtered_tags = [] + end else Helper.log.warn "Warning: can't find tag #{tag}, specified with --due-tag option." end diff --git a/lib/github_changelog_generator/helper.rb b/lib/github_changelog_generator/helper.rb index 15789ec..7c13407 100644 --- a/lib/github_changelog_generator/helper.rb +++ b/lib/github_changelog_generator/helper.rb @@ -3,14 +3,14 @@ module GitHubChangelogGenerator module Helper # @return true if the currently running program is a unit test def self.test? - defined? SpecHelper + defined?SpecHelper end - @log ||= if test? - Logger.new(nil) # don't show any logs when running tests - else - Logger.new(STDOUT) - end + if test? + @log ||= Logger.new(nil) # don't show any logs when running tests + else + @log ||= Logger.new(STDOUT) + end @log.formatter = proc do |severity, _datetime, _progname, msg| string = "#{msg}\n" diff --git a/lib/github_changelog_generator/parser_file.rb b/lib/github_changelog_generator/parser_file.rb index 38cc54d..df92814 100644 --- a/lib/github_changelog_generator/parser_file.rb +++ b/lib/github_changelog_generator/parser_file.rb @@ -20,8 +20,8 @@ module GitHubChangelogGenerator def parse_line!(line) key_sym, value = extract_pair(line) - value = true if value =~ /^(true|t|yes|y|1)$/i - value = false if value =~ /^(false|f|no|n|0)$/i + value = true if value =~ (/^(true|t|yes|y|1)$/i) + value = false if value =~ (/^(false|f|no|n|0)$/i) @options[key_sym] = value rescue raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\"" diff --git a/lib/github_changelog_generator/task.rb b/lib/github_changelog_generator/task.rb index f5b5b8e..035d6d5 100644 --- a/lib/github_changelog_generator/task.rb +++ b/lib/github_changelog_generator/task.rb @@ -17,7 +17,7 @@ module GitHubChangelogGenerator between_tags exclude_tags since_tag max_issues github_site github_endpoint simple_list future_release release_branch verbose release_url - base ).freeze + base ) OPTIONS.each do |o| attr_accessor o.to_sym @@ -37,7 +37,7 @@ module GitHubChangelogGenerator def define(args, &task_block) desc "Generate a Change log from GitHub" - yield(*[self, args].slice(0, task_block.arity)) if task_block + task_block.call(*[self, args].slice(0, task_block.arity)) if task_block # clear any (auto-)pre-existing task Rake::Task[@name].clear if Rake::Task.task_defined?(@name) @@ -57,7 +57,7 @@ module GitHubChangelogGenerator log = generator.compound_changelog - output_filename = (options[:output]).to_s + output_filename = "#{options[:output]}" File.open(output_filename, "w") { |file| file.write(log) } puts "Done!" puts "Generated log placed in #{Dir.pwd}/#{output_filename}" diff --git a/lib/github_changelog_generator/version.rb b/lib/github_changelog_generator/version.rb index d68aa5c..9ab5197 100644 --- a/lib/github_changelog_generator/version.rb +++ b/lib/github_changelog_generator/version.rb @@ -1,3 +1,3 @@ module GitHubChangelogGenerator - VERSION = "1.11.0".freeze + VERSION = "1.10.1" end diff --git a/spec/unit/fetcher_spec.rb b/spec/unit/fetcher_spec.rb index 983b741..bba0c19 100644 --- a/spec/unit/fetcher_spec.rb +++ b/spec/unit/fetcher_spec.rb @@ -1,8 +1,8 @@ -VALID_TOKEN = "0123456789abcdef".freeze -INVALID_TOKEN = "0000000000000000".freeze +VALID_TOKEN = "0123456789abcdef" +INVALID_TOKEN = "0000000000000000" DEFAULT_OPTIONS = { user: "skywinder", - project: "changelog_test" }.freeze + project: "changelog_test" } def options_with_invalid_token options = DEFAULT_OPTIONS From 857b9e6f5354c096cfd64aa86b0b0528f3600689 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 23 Feb 2016 17:18:36 +0200 Subject: [PATCH 7/8] rubocop updates --- .rubocop.yml | 36 +++++++++++++++ .rubocop_todo.yml | 33 +------------- lib/github_changelog_generator.rb | 2 +- lib/github_changelog_generator/fetcher.rb | 10 ++--- .../generator/generator_generation.rb | 44 +++++++++---------- .../generator/generator_processor.rb | 26 +++++------ .../generator/generator_tags.rb | 22 +++++----- lib/github_changelog_generator/helper.rb | 12 ++--- lib/github_changelog_generator/parser_file.rb | 4 +- lib/github_changelog_generator/task.rb | 4 +- 10 files changed, 99 insertions(+), 94 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 87f73fc..9579c43 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,3 +18,39 @@ Metrics/MethodLength: Style/FileName: Exclude: - 'bin/git-generate-changelog' + +#TODOS +# Offense count: 14 +Metrics/AbcSize: + Enabled: false + +# Offense count: 1 +Style/AccessorMethodName: + Enabled: false + +# Offense count: 10 +Style/Documentation: + Enabled: false + +# Offense count: 1 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +# SupportedStyles: skip_modifier_ifs, always +Style/Next: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Enabled: false + +Style/MutableConstant: + Enabled: false + diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 41a8f1b..70639f6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2016-02-23 12:36:44 +0200 using RuboCop version 0.37.2. +# on 2016-02-23 17:18:27 +0200 using RuboCop version 0.37.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -11,10 +11,6 @@ Lint/ImplicitStringConcatenation: Exclude: - 'lib/github_changelog_generator/parser.rb' -# Offense count: 14 -Metrics/AbcSize: - Enabled: false - # Offense count: 1 Metrics/CyclomaticComplexity: Max: 7 @@ -22,30 +18,3 @@ Metrics/CyclomaticComplexity: # Offense count: 2 Metrics/PerceivedComplexity: Max: 8 - -# Offense count: 1 -Style/AccessorMethodName: - Enabled: false - -# Offense count: 10 -Style/Documentation: - Enabled: false - -# Offense count: 1 -# Configuration parameters: MinBodyLength. -Style/GuardClause: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. -# SupportedStyles: skip_modifier_ifs, always -Style/Next: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. -# SupportedStyles: slashes, percent_r, mixed -Style/RegexpLiteral: - Enabled: false diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 31d86ae..c689c95 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -28,7 +28,7 @@ module GitHubChangelogGenerator def run log = @generator.compound_changelog - output_filename = "#{@options[:output]}" + output_filename = (@options[:output]).to_s File.open(output_filename, "w") { |file| file.write(log) } puts "Done!" puts "Generated log placed in #{Dir.pwd}/#{output_filename}" diff --git a/lib/github_changelog_generator/fetcher.rb b/lib/github_changelog_generator/fetcher.rb index eef3e6d..f375119 100644 --- a/lib/github_changelog_generator/fetcher.rb +++ b/lib/github_changelog_generator/fetcher.rb @@ -123,16 +123,16 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow def fetch_closed_pull_requests pull_requests = [] begin - if @options[:release_branch].nil? - response = @github.pull_requests.list @options[:user], + response = if @options[:release_branch].nil? + @github.pull_requests.list @options[:user], @options[:project], state: "closed" - else - response = @github.pull_requests.list @options[:user], + else + @github.pull_requests.list @options[:user], @options[:project], state: "closed", base: @options[:release_branch] - end + end page_i = 0 count_pages = response.count_pages response.each_page do |page| diff --git a/lib/github_changelog_generator/generator/generator_generation.rb b/lib/github_changelog_generator/generator/generator_generation.rb index cfaafe1..b22fe40 100644 --- a/lib/github_changelog_generator/generator/generator_generation.rb +++ b/lib/github_changelog_generator/generator/generator_generation.rb @@ -12,11 +12,11 @@ module GitHubChangelogGenerator log += @options[:frontmatter] if @options[:frontmatter] log += "#{@options[:header]}\n\n" - if @options[:unreleased_only] - log += generate_log_between_tags(filtered_tags[0], nil) - else - log += generate_log_for_all_tags - end + log += if @options[:unreleased_only] + generate_log_between_tags(filtered_tags[0], nil) + else + generate_log_for_all_tags + end log += File.read(@options[:base]) if File.file?(@options[:base]) @@ -39,10 +39,10 @@ module GitHubChangelogGenerator index2 = hash[tag2] log += generate_log_between_tags(all_tags[index1], all_tags[index2]) else - fail ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red + raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red end else - fail ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red + raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red end log end @@ -79,16 +79,16 @@ module GitHubChangelogGenerator time_string = newer_tag_time.strftime @options[:date_format] # Generate tag name and link - if @options[:release_url] - release_url = format(@options[:release_url], newer_tag_link) - else - release_url = "#{project_url}/tree/#{newer_tag_link}" - end - if newer_tag_name.equal? @options[:unreleased_label] - log += "## [#{newer_tag_name}](#{release_url})\n\n" - else - log += "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n" - end + release_url = if @options[:release_url] + format(@options[:release_url], newer_tag_link) + else + "#{project_url}/tree/#{newer_tag_link}" + end + log += if newer_tag_name.equal? @options[:unreleased_label] + "## [#{newer_tag_name}](#{release_url})\n\n" + else + "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n" + end if @options[:compare_link] && older_tag_link # Generate compare link @@ -171,11 +171,11 @@ module GitHubChangelogGenerator unless issue.pull_request.nil? if @options[:author] - if issue.user.nil? - title_with_number += " ({Null user})" - else - title_with_number += " ([#{issue.user.login}](#{issue.user.html_url}))" - end + title_with_number += if issue.user.nil? + " ({Null user})" + else + " ([#{issue.user.login}](#{issue.user.html_url}))" + end end end title_with_number diff --git a/lib/github_changelog_generator/generator/generator_processor.rb b/lib/github_changelog_generator/generator/generator_processor.rb index ae745e6..1791711 100644 --- a/lib/github_changelog_generator/generator/generator_processor.rb +++ b/lib/github_changelog_generator/generator/generator_processor.rb @@ -7,7 +7,7 @@ module GitHubChangelogGenerator unless @options[:exclude_labels].nil? issues = issues.select do |issue| var = issue.labels.map(&:name) & @options[:exclude_labels] - !(var).any? + !var.any? end end issues @@ -83,7 +83,7 @@ module GitHubChangelogGenerator tag_in_range_new = tag_older_new_tag?(newer_tag_time, time) - tag_in_range = (tag_in_range_old) && (tag_in_range_new) + tag_in_range = tag_in_range_old && tag_in_range_new tag_in_range else @@ -93,20 +93,20 @@ module GitHubChangelogGenerator end def tag_older_new_tag?(newer_tag_time, time) - if newer_tag_time.nil? - tag_in_range_new = true - else - tag_in_range_new = time <= newer_tag_time - end + tag_in_range_new = if newer_tag_time.nil? + true + else + time <= newer_tag_time + end tag_in_range_new end def tag_newer_old_tag?(older_tag_time, t) - if older_tag_time.nil? - tag_in_range_old = true - else - tag_in_range_old = t > older_tag_time - end + tag_in_range_old = if older_tag_time.nil? + true + else + t > older_tag_time + end tag_in_range_old end @@ -133,7 +133,7 @@ module GitHubChangelogGenerator def filter_by_include_labels(issues) filtered_issues = @options[:include_labels].nil? ? issues : issues.select do |issue| labels = issue.labels.map(&:name) & @options[:include_labels] - (labels).any? + labels.any? end filtered_issues end diff --git a/lib/github_changelog_generator/generator/generator_tags.rb b/lib/github_changelog_generator/generator/generator_tags.rb index 006a345..fbbc95d 100644 --- a/lib/github_changelog_generator/generator/generator_tags.rb +++ b/lib/github_changelog_generator/generator/generator_tags.rb @@ -19,7 +19,7 @@ module GitHubChangelogGenerator # @param [Hash] tag_name name of the tag # @return [Time] time of specified tag def get_time_of_tag(tag_name) - fail ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil? + raise ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil? name_of_tag = tag_name["name"] time_for_name = @tag_times_hash[name_of_tag] @@ -80,11 +80,11 @@ module GitHubChangelogGenerator if tag if all_tags.map(&:name).include? tag idx = all_tags.index { |t| t.name == tag } - if idx > 0 - filtered_tags = all_tags[0..idx - 1] - else - filtered_tags = [] - end + filtered_tags = if idx > 0 + all_tags[0..idx - 1] + else + [] + end else Helper.log.warn "Warning: can't find tag #{tag}, specified with --since-tag option." end @@ -101,11 +101,11 @@ module GitHubChangelogGenerator if (all_tags.count > 0) && (all_tags.map(&:name).include? tag) idx = all_tags.index { |t| t.name == tag } last_index = all_tags.count - 1 - if idx > 0 && idx < last_index - filtered_tags = all_tags[idx + 1..last_index] - else - filtered_tags = [] - end + filtered_tags = if idx > 0 && idx < last_index + all_tags[idx + 1..last_index] + else + [] + end else Helper.log.warn "Warning: can't find tag #{tag}, specified with --due-tag option." end diff --git a/lib/github_changelog_generator/helper.rb b/lib/github_changelog_generator/helper.rb index 7c13407..15789ec 100644 --- a/lib/github_changelog_generator/helper.rb +++ b/lib/github_changelog_generator/helper.rb @@ -3,14 +3,14 @@ module GitHubChangelogGenerator module Helper # @return true if the currently running program is a unit test def self.test? - defined?SpecHelper + defined? SpecHelper end - if test? - @log ||= Logger.new(nil) # don't show any logs when running tests - else - @log ||= Logger.new(STDOUT) - end + @log ||= if test? + Logger.new(nil) # don't show any logs when running tests + else + Logger.new(STDOUT) + end @log.formatter = proc do |severity, _datetime, _progname, msg| string = "#{msg}\n" diff --git a/lib/github_changelog_generator/parser_file.rb b/lib/github_changelog_generator/parser_file.rb index df92814..38cc54d 100644 --- a/lib/github_changelog_generator/parser_file.rb +++ b/lib/github_changelog_generator/parser_file.rb @@ -20,8 +20,8 @@ module GitHubChangelogGenerator def parse_line!(line) key_sym, value = extract_pair(line) - value = true if value =~ (/^(true|t|yes|y|1)$/i) - value = false if value =~ (/^(false|f|no|n|0)$/i) + value = true if value =~ /^(true|t|yes|y|1)$/i + value = false if value =~ /^(false|f|no|n|0)$/i @options[key_sym] = value rescue raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\"" diff --git a/lib/github_changelog_generator/task.rb b/lib/github_changelog_generator/task.rb index 035d6d5..8cbce70 100644 --- a/lib/github_changelog_generator/task.rb +++ b/lib/github_changelog_generator/task.rb @@ -37,7 +37,7 @@ module GitHubChangelogGenerator def define(args, &task_block) desc "Generate a Change log from GitHub" - task_block.call(*[self, args].slice(0, task_block.arity)) if task_block + yield(*[self, args].slice(0, task_block.arity)) if task_block # clear any (auto-)pre-existing task Rake::Task[@name].clear if Rake::Task.task_defined?(@name) @@ -57,7 +57,7 @@ module GitHubChangelogGenerator log = generator.compound_changelog - output_filename = "#{options[:output]}" + output_filename = (options[:output]).to_s File.open(output_filename, "w") { |file| file.write(log) } puts "Done!" puts "Generated log placed in #{Dir.pwd}/#{output_filename}" From 3a7dbf8138ff1ebe8f392441ec6d409ca7f5ab15 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 23 Feb 2016 17:19:38 +0200 Subject: [PATCH 8/8] Update gemspec to version 1.10.2 --- 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 9ab5197..cfcd57e 100644 --- a/lib/github_changelog_generator/version.rb +++ b/lib/github_changelog_generator/version.rb @@ -1,3 +1,3 @@ module GitHubChangelogGenerator - VERSION = "1.10.1" + VERSION = "1.10.2" end