rubocop auto-fixes
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
module GitHubChangelogGenerator
|
||||
class Generator
|
||||
|
||||
def initialize(options = nil)
|
||||
@options = options
|
||||
end
|
||||
|
||||
def get_string_for_issue(issue)
|
||||
encapsulated_title = self.encapsulate_string issue[:title]
|
||||
encapsulated_title = encapsulate_string issue[:title]
|
||||
|
||||
title_with_number = "#{encapsulated_title} [\\##{issue[:number]}](#{issue.html_url})"
|
||||
|
||||
unless issue.pull_request.nil?
|
||||
if @options[:author]
|
||||
if issue.user.nil?
|
||||
title_with_number += " ({Null user})"
|
||||
title_with_number += ' ({Null user})'
|
||||
else
|
||||
title_with_number += " ([#{issue.user.login}](#{issue.user.html_url}))"
|
||||
end
|
||||
@@ -23,17 +22,14 @@ module GitHubChangelogGenerator
|
||||
end
|
||||
|
||||
def encapsulate_string(string)
|
||||
|
||||
string.gsub! '\\', '\\\\'
|
||||
|
||||
encpas_chars = %w(> * _ \( \) [ ] #)
|
||||
encpas_chars.each { |char|
|
||||
encpas_chars.each do |char|
|
||||
string.gsub! char, "\\#{char}"
|
||||
}
|
||||
end
|
||||
|
||||
string
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,32 +6,31 @@ require_relative 'version'
|
||||
module GitHubChangelogGenerator
|
||||
class Parser
|
||||
def self.parse_options
|
||||
|
||||
options = {
|
||||
:tag1 => nil,
|
||||
:tag2 => nil,
|
||||
:format => '%Y-%m-%d',
|
||||
:output => 'CHANGELOG.md',
|
||||
:exclude_labels => %w(duplicate question invalid wontfix),
|
||||
:pulls => true,
|
||||
:issues => true,
|
||||
:verbose => true,
|
||||
:add_issues_wo_labels => true,
|
||||
:add_pr_wo_labels => true,
|
||||
:merge_prefix => '**Merged pull requests:**',
|
||||
:issue_prefix => '**Closed issues:**',
|
||||
:bug_prefix => '**Fixed bugs:**',
|
||||
:enhancement_prefix => '**Implemented enhancements:**',
|
||||
:author => true,
|
||||
:filter_issues_by_milestone => true,
|
||||
:max_issues => nil,
|
||||
:compare_link => true,
|
||||
:unreleased => true,
|
||||
:unreleased_label => 'Unreleased',
|
||||
:branch => 'origin'
|
||||
tag1: nil,
|
||||
tag2: nil,
|
||||
format: '%Y-%m-%d',
|
||||
output: 'CHANGELOG.md',
|
||||
exclude_labels: %w(duplicate question invalid wontfix),
|
||||
pulls: true,
|
||||
issues: true,
|
||||
verbose: true,
|
||||
add_issues_wo_labels: true,
|
||||
add_pr_wo_labels: true,
|
||||
merge_prefix: '**Merged pull requests:**',
|
||||
issue_prefix: '**Closed issues:**',
|
||||
bug_prefix: '**Fixed bugs:**',
|
||||
enhancement_prefix: '**Implemented enhancements:**',
|
||||
author: true,
|
||||
filter_issues_by_milestone: true,
|
||||
max_issues: nil,
|
||||
compare_link: true,
|
||||
unreleased: true,
|
||||
unreleased_label: 'Unreleased',
|
||||
branch: 'origin'
|
||||
}
|
||||
|
||||
parser = OptionParser.new { |opts|
|
||||
parser = OptionParser.new do |opts|
|
||||
opts.banner = 'Usage: github_changelog_generator [options]'
|
||||
opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo') do |last|
|
||||
options[:user] = last
|
||||
@@ -99,7 +98,7 @@ module GitHubChangelogGenerator
|
||||
opts.on('--[no-]verbose', 'Run verbosely. Default is true') do |v|
|
||||
options[:verbose] = v
|
||||
end
|
||||
opts.on('-v', '--version', 'Print version number') do |v|
|
||||
opts.on('-v', '--version', 'Print version number') do |_v|
|
||||
puts "Version: #{GitHubChangelogGenerator::VERSION}"
|
||||
exit
|
||||
end
|
||||
@@ -107,7 +106,7 @@ module GitHubChangelogGenerator
|
||||
puts opts
|
||||
exit
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
parser.parse!
|
||||
|
||||
@@ -126,10 +125,9 @@ module GitHubChangelogGenerator
|
||||
exit
|
||||
else
|
||||
options[:user] = match[1]
|
||||
options[:project]= match[2]
|
||||
options[:project] = match[2]
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
if !options[:user] && !options[:project]
|
||||
@@ -143,9 +141,9 @@ module GitHubChangelogGenerator
|
||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||
options[:user], options[:project] = match[1], match[2]
|
||||
else
|
||||
# try to find repo in format:
|
||||
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
||||
# https://github.com/skywinder/ChangelogMerger
|
||||
# try to find repo in format:
|
||||
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
||||
# https://github.com/skywinder/ChangelogMerger
|
||||
match = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/.match(remote)
|
||||
if match && match[1] && match[2]
|
||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||
@@ -154,7 +152,6 @@ module GitHubChangelogGenerator
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if !options[:user] || !options[:project]
|
||||
puts parser.banner
|
||||
exit
|
||||
|
||||
Reference in New Issue
Block a user