Revert "Rubocop fixes"
This reverts commit fa0267b586a08c634cc1dca28afdafeca6500c7f.
This commit is contained in:
		
							parent
							
								
									62623ff2dd
								
							
						
					
					
						commit
						2691a3ef96
					
				| @ -1,7 +1,7 @@ | |||||||
| PATH | PATH | ||||||
|   remote: . |   remote: . | ||||||
|   specs: |   specs: | ||||||
|     github_changelog_generator (1.11.0) |     github_changelog_generator (1.10.1) | ||||||
|       colorize (~> 0.7) |       colorize (~> 0.7) | ||||||
|       github_api (~> 0.12) |       github_api (~> 0.12) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ module GitHubChangelogGenerator | |||||||
|     def run |     def run | ||||||
|       log = @generator.compound_changelog |       log = @generator.compound_changelog | ||||||
| 
 | 
 | ||||||
|       output_filename = (@options[:output]).to_s |       output_filename = "#{@options[:output]}" | ||||||
|       File.open(output_filename, "w") { |file| file.write(log) } |       File.open(output_filename, "w") { |file| file.write(log) } | ||||||
|       puts "Done!" |       puts "Done!" | ||||||
|       puts "Generated log placed in #{Dir.pwd}/#{output_filename}" |       puts "Generated log placed in #{Dir.pwd}/#{output_filename}" | ||||||
|  | |||||||
| @ -7,11 +7,11 @@ module GitHubChangelogGenerator | |||||||
| 
 | 
 | ||||||
|   class Fetcher |   class Fetcher | ||||||
|     PER_PAGE_NUMBER = 30 |     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 " \ |     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. " \ |     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 = {}) |     def initialize(options = {}) | ||||||
|       @options = 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 |     def fetch_closed_pull_requests | ||||||
|       pull_requests = [] |       pull_requests = [] | ||||||
|       begin |       begin | ||||||
|         response = if @options[:release_branch].nil? |         if @options[:release_branch].nil? | ||||||
|                      @github.pull_requests.list @options[:user], |           response = @github.pull_requests.list @options[:user], | ||||||
|                                                 @options[:project], |                                                 @options[:project], | ||||||
|                                                 state: "closed" |                                                 state: "closed" | ||||||
|                    else |         else | ||||||
|                      @github.pull_requests.list @options[:user], |           response = @github.pull_requests.list @options[:user], | ||||||
|                                                 @options[:project], |                                                 @options[:project], | ||||||
|                                                 state: "closed", |                                                 state: "closed", | ||||||
|                                                 base: @options[:release_branch] |                                                 base: @options[:release_branch] | ||||||
|                    end |         end | ||||||
|         page_i = 0 |         page_i = 0 | ||||||
|         count_pages = response.count_pages |         count_pages = response.count_pages | ||||||
|         response.each_page do |page| |         response.each_page do |page| | ||||||
|  | |||||||
| @ -12,11 +12,11 @@ module GitHubChangelogGenerator | |||||||
|       log += @options[:frontmatter] if @options[:frontmatter] |       log += @options[:frontmatter] if @options[:frontmatter] | ||||||
|       log += "#{@options[:header]}\n\n" |       log += "#{@options[:header]}\n\n" | ||||||
| 
 | 
 | ||||||
|       log += if @options[:unreleased_only] |       if @options[:unreleased_only] | ||||||
|                generate_log_between_tags(filtered_tags[0], nil) |         log += generate_log_between_tags(filtered_tags[0], nil) | ||||||
|              else |       else | ||||||
|                generate_log_for_all_tags |         log += generate_log_for_all_tags | ||||||
|              end |       end | ||||||
| 
 | 
 | ||||||
|       log += File.read(@options[:base]) if File.file?(@options[:base]) |       log += File.read(@options[:base]) if File.file?(@options[:base]) | ||||||
| 
 | 
 | ||||||
| @ -39,10 +39,10 @@ module GitHubChangelogGenerator | |||||||
|           index2 = hash[tag2] |           index2 = hash[tag2] | ||||||
|           log += generate_log_between_tags(all_tags[index1], all_tags[index2]) |           log += generate_log_between_tags(all_tags[index1], all_tags[index2]) | ||||||
|         else |         else | ||||||
|           raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red |           fail ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red | ||||||
|         end |         end | ||||||
|       else |       else | ||||||
|         raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red |         fail ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red | ||||||
|       end |       end | ||||||
|       log |       log | ||||||
|     end |     end | ||||||
| @ -79,16 +79,16 @@ module GitHubChangelogGenerator | |||||||
|       time_string = newer_tag_time.strftime @options[:date_format] |       time_string = newer_tag_time.strftime @options[:date_format] | ||||||
| 
 | 
 | ||||||
|       # Generate tag name and link |       # Generate tag name and link | ||||||
|       release_url = if @options[:release_url] |       if @options[:release_url] | ||||||
|                       format(@options[:release_url], newer_tag_link) |         release_url = format(@options[:release_url], newer_tag_link) | ||||||
|                     else |       else | ||||||
|                       "#{project_url}/tree/#{newer_tag_link}" |         release_url = "#{project_url}/tree/#{newer_tag_link}" | ||||||
|                     end |       end | ||||||
|       log += if newer_tag_name.equal? @options[:unreleased_label] |       if newer_tag_name.equal? @options[:unreleased_label] | ||||||
|                "## [#{newer_tag_name}](#{release_url})\n\n" |         log += "## [#{newer_tag_name}](#{release_url})\n\n" | ||||||
|              else |       else | ||||||
|                "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n" |         log += "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n" | ||||||
|              end |       end | ||||||
| 
 | 
 | ||||||
|       if @options[:compare_link] && older_tag_link |       if @options[:compare_link] && older_tag_link | ||||||
|         # Generate compare link |         # Generate compare link | ||||||
| @ -171,11 +171,11 @@ module GitHubChangelogGenerator | |||||||
| 
 | 
 | ||||||
|       unless issue.pull_request.nil? |       unless issue.pull_request.nil? | ||||||
|         if @options[:author] |         if @options[:author] | ||||||
|           title_with_number += if issue.user.nil? |           if issue.user.nil? | ||||||
|                                  " ({Null user})" |             title_with_number += " ({Null user})" | ||||||
|                                else |           else | ||||||
|                                  " ([#{issue.user.login}](#{issue.user.html_url}))" |             title_with_number += " ([#{issue.user.login}](#{issue.user.html_url}))" | ||||||
|                                end |           end | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
|       title_with_number |       title_with_number | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ module GitHubChangelogGenerator | |||||||
|       unless @options[:exclude_labels].nil? |       unless @options[:exclude_labels].nil? | ||||||
|         issues = issues.select do |issue| |         issues = issues.select do |issue| | ||||||
|           var = issue.labels.map(&:name) & @options[:exclude_labels] |           var = issue.labels.map(&:name) & @options[:exclude_labels] | ||||||
|           !var.any? |           !(var).any? | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
|       issues |       issues | ||||||
| @ -83,7 +83,7 @@ module GitHubChangelogGenerator | |||||||
| 
 | 
 | ||||||
|           tag_in_range_new = tag_older_new_tag?(newer_tag_time, time) |           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 |           tag_in_range | ||||||
|         else |         else | ||||||
| @ -93,20 +93,20 @@ module GitHubChangelogGenerator | |||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     def tag_older_new_tag?(newer_tag_time, time) |     def tag_older_new_tag?(newer_tag_time, time) | ||||||
|       tag_in_range_new = if newer_tag_time.nil? |       if newer_tag_time.nil? | ||||||
|                            true |         tag_in_range_new = true | ||||||
|                          else |       else | ||||||
|                            time <= newer_tag_time |         tag_in_range_new = time <= newer_tag_time | ||||||
|                          end |       end | ||||||
|       tag_in_range_new |       tag_in_range_new | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     def tag_newer_old_tag?(older_tag_time, t) |     def tag_newer_old_tag?(older_tag_time, t) | ||||||
|       tag_in_range_old = if older_tag_time.nil? |       if older_tag_time.nil? | ||||||
|                            true |         tag_in_range_old = true | ||||||
|                          else |       else | ||||||
|                            t > older_tag_time |         tag_in_range_old = t > older_tag_time | ||||||
|                          end |       end | ||||||
|       tag_in_range_old |       tag_in_range_old | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
| @ -133,7 +133,7 @@ module GitHubChangelogGenerator | |||||||
|     def filter_by_include_labels(issues) |     def filter_by_include_labels(issues) | ||||||
|       filtered_issues = @options[:include_labels].nil? ? issues : issues.select do |issue| |       filtered_issues = @options[:include_labels].nil? ? issues : issues.select do |issue| | ||||||
|         labels = issue.labels.map(&:name) & @options[:include_labels] |         labels = issue.labels.map(&:name) & @options[:include_labels] | ||||||
|         labels.any? |         (labels).any? | ||||||
|       end |       end | ||||||
|       filtered_issues |       filtered_issues | ||||||
|     end |     end | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ module GitHubChangelogGenerator | |||||||
|     # @param [Hash] tag_name name of the tag |     # @param [Hash] tag_name name of the tag | ||||||
|     # @return [Time] time of specified tag |     # @return [Time] time of specified tag | ||||||
|     def get_time_of_tag(tag_name) |     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"] |       name_of_tag = tag_name["name"] | ||||||
|       time_for_name = @tag_times_hash[name_of_tag] |       time_for_name = @tag_times_hash[name_of_tag] | ||||||
| @ -80,11 +80,11 @@ module GitHubChangelogGenerator | |||||||
|       if tag |       if tag | ||||||
|         if all_tags.map(&:name).include? tag |         if all_tags.map(&:name).include? tag | ||||||
|           idx = all_tags.index { |t| t.name == tag } |           idx = all_tags.index { |t| t.name == tag } | ||||||
|           filtered_tags = if idx > 0 |           if idx > 0 | ||||||
|                             all_tags[0..idx - 1] |             filtered_tags = all_tags[0..idx - 1] | ||||||
|                           else |           else | ||||||
|                             [] |             filtered_tags = [] | ||||||
|                           end |           end | ||||||
|         else |         else | ||||||
|           Helper.log.warn "Warning: can't find tag #{tag}, specified with --since-tag option." |           Helper.log.warn "Warning: can't find tag #{tag}, specified with --since-tag option." | ||||||
|         end |         end | ||||||
| @ -101,11 +101,11 @@ module GitHubChangelogGenerator | |||||||
|         if (all_tags.count > 0) && (all_tags.map(&:name).include? tag) |         if (all_tags.count > 0) && (all_tags.map(&:name).include? tag) | ||||||
|           idx = all_tags.index { |t| t.name == tag } |           idx = all_tags.index { |t| t.name == tag } | ||||||
|           last_index = all_tags.count - 1 |           last_index = all_tags.count - 1 | ||||||
|           filtered_tags = if idx > 0 && idx < last_index |           if idx > 0 && idx < last_index | ||||||
|                             all_tags[idx + 1..last_index] |             filtered_tags = all_tags[idx + 1..last_index] | ||||||
|                           else |           else | ||||||
|                             [] |             filtered_tags = [] | ||||||
|                           end |           end | ||||||
|         else |         else | ||||||
|           Helper.log.warn "Warning: can't find tag #{tag}, specified with --due-tag option." |           Helper.log.warn "Warning: can't find tag #{tag}, specified with --due-tag option." | ||||||
|         end |         end | ||||||
|  | |||||||
| @ -3,14 +3,14 @@ module GitHubChangelogGenerator | |||||||
|   module Helper |   module Helper | ||||||
|     # @return true if the currently running program is a unit test |     # @return true if the currently running program is a unit test | ||||||
|     def self.test? |     def self.test? | ||||||
|       defined? SpecHelper |       defined?SpecHelper | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     @log ||= if test? |     if test? | ||||||
|                Logger.new(nil) # don't show any logs when running tests |       @log ||= Logger.new(nil) # don't show any logs when running tests | ||||||
|              else |     else | ||||||
|                Logger.new(STDOUT) |       @log ||= Logger.new(STDOUT) | ||||||
|              end |     end | ||||||
|     @log.formatter = proc do |severity, _datetime, _progname, msg| |     @log.formatter = proc do |severity, _datetime, _progname, msg| | ||||||
|       string = "#{msg}\n" |       string = "#{msg}\n" | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -20,8 +20,8 @@ module GitHubChangelogGenerator | |||||||
| 
 | 
 | ||||||
|     def parse_line!(line) |     def parse_line!(line) | ||||||
|       key_sym, value = extract_pair(line) |       key_sym, value = extract_pair(line) | ||||||
|       value = true if value =~ /^(true|t|yes|y|1)$/i |       value = true if value =~ (/^(true|t|yes|y|1)$/i) | ||||||
|       value = false if value =~ /^(false|f|no|n|0)$/i |       value = false if value =~ (/^(false|f|no|n|0)$/i) | ||||||
|       @options[key_sym] = value |       @options[key_sym] = value | ||||||
|     rescue |     rescue | ||||||
|       raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\"" |       raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\"" | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ module GitHubChangelogGenerator | |||||||
|                   between_tags exclude_tags since_tag max_issues |                   between_tags exclude_tags since_tag max_issues | ||||||
|                   github_site github_endpoint simple_list |                   github_site github_endpoint simple_list | ||||||
|                   future_release release_branch verbose release_url |                   future_release release_branch verbose release_url | ||||||
|                   base ).freeze |                   base ) | ||||||
| 
 | 
 | ||||||
|     OPTIONS.each do |o| |     OPTIONS.each do |o| | ||||||
|       attr_accessor o.to_sym |       attr_accessor o.to_sym | ||||||
| @ -37,7 +37,7 @@ module GitHubChangelogGenerator | |||||||
|     def define(args, &task_block) |     def define(args, &task_block) | ||||||
|       desc "Generate a Change log from GitHub" |       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 |       # clear any (auto-)pre-existing task | ||||||
|       Rake::Task[@name].clear if Rake::Task.task_defined?(@name) |       Rake::Task[@name].clear if Rake::Task.task_defined?(@name) | ||||||
| @ -57,7 +57,7 @@ module GitHubChangelogGenerator | |||||||
| 
 | 
 | ||||||
|         log = generator.compound_changelog |         log = generator.compound_changelog | ||||||
| 
 | 
 | ||||||
|         output_filename = (options[:output]).to_s |         output_filename = "#{options[:output]}" | ||||||
|         File.open(output_filename, "w") { |file| file.write(log) } |         File.open(output_filename, "w") { |file| file.write(log) } | ||||||
|         puts "Done!" |         puts "Done!" | ||||||
|         puts "Generated log placed in #{Dir.pwd}/#{output_filename}" |         puts "Generated log placed in #{Dir.pwd}/#{output_filename}" | ||||||
|  | |||||||
| @ -1,3 +1,3 @@ | |||||||
| module GitHubChangelogGenerator | module GitHubChangelogGenerator | ||||||
|   VERSION = "1.11.0".freeze |   VERSION = "1.10.1" | ||||||
| end | end | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| VALID_TOKEN = "0123456789abcdef".freeze | VALID_TOKEN = "0123456789abcdef" | ||||||
| INVALID_TOKEN = "0000000000000000".freeze | INVALID_TOKEN = "0000000000000000" | ||||||
| 
 | 
 | ||||||
| DEFAULT_OPTIONS = { user: "skywinder", | DEFAULT_OPTIONS = { user: "skywinder", | ||||||
|                     project: "changelog_test" }.freeze |                     project: "changelog_test" } | ||||||
| 
 | 
 | ||||||
| def options_with_invalid_token | def options_with_invalid_token | ||||||
|   options = DEFAULT_OPTIONS |   options = DEFAULT_OPTIONS | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Petr Korolev
						Petr Korolev