Merge branch 'master' into develop
This commit is contained in:
commit
c67cbb31f2
|
@ -1,11 +1,11 @@
|
||||||
# This configuration was generated by `rubocop --auto-gen-config`
|
# This configuration was generated by `rubocop --auto-gen-config`
|
||||||
# on 2015-04-04 02:29:34 +0300 using RuboCop version 0.29.1.
|
# on 2015-05-14 16:51:06 +0300 using RuboCop version 0.31.0.
|
||||||
# The point is for the user to remove these configuration records
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
# versions of RuboCop, may require this file to be generated again.
|
# versions of RuboCop, may require this file to be generated again.
|
||||||
|
|
||||||
# Offense count: 21
|
# Offense count: 15
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
@ -13,16 +13,16 @@ Metrics/AbcSize:
|
||||||
Metrics/BlockNesting:
|
Metrics/BlockNesting:
|
||||||
Max: 4
|
Max: 4
|
||||||
|
|
||||||
# Offense count: 2
|
# Offense count: 3
|
||||||
# Configuration parameters: CountComments.
|
# Configuration parameters: CountComments.
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Max: 457
|
Max: 337
|
||||||
|
|
||||||
# Offense count: 6
|
# Offense count: 5
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 15
|
Max: 15
|
||||||
|
|
||||||
# Offense count: 28
|
# Offense count: 22
|
||||||
# Configuration parameters: CountComments.
|
# Configuration parameters: CountComments.
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -31,7 +31,7 @@ Metrics/MethodLength:
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 18
|
Max: 18
|
||||||
|
|
||||||
# Offense count: 3
|
# Offense count: 4
|
||||||
Style/AccessorMethodName:
|
Style/AccessorMethodName:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
@ -41,31 +41,23 @@ Style/AccessorMethodName:
|
||||||
Style/AndOr:
|
Style/AndOr:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 27
|
# Offense count: 19
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Style/Blocks:
|
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
||||||
Enabled: false
|
Style/BlockDelimiters:
|
||||||
|
|
||||||
# Offense count: 7
|
|
||||||
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
|
|
||||||
Style/CaseIndentation:
|
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 4
|
# Offense count: 4
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 5
|
||||||
# Configuration parameters: AllowedVariables.
|
|
||||||
Style/GlobalVars:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 6
|
|
||||||
# Configuration parameters: MinBodyLength.
|
# Configuration parameters: MinBodyLength.
|
||||||
Style/GuardClause:
|
Style/GuardClause:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 17
|
# Offense count: 15
|
||||||
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: MaxLineLength.
|
# Configuration parameters: MaxLineLength.
|
||||||
Style/IfUnlessModifier:
|
Style/IfUnlessModifier:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -75,7 +67,8 @@ Style/IfUnlessModifier:
|
||||||
Style/Next:
|
Style/Next:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 5
|
# Offense count: 3
|
||||||
# Configuration parameters: MaxSlashes.
|
# Cop supports --auto-correct.
|
||||||
|
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
||||||
Style/RegexpLiteral:
|
Style/RegexpLiteral:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
221
bump_gemfile.rb
221
bump_gemfile.rb
|
@ -1,221 +0,0 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
require "optparse"
|
|
||||||
|
|
||||||
SPEC_TYPE = "gemspec"
|
|
||||||
|
|
||||||
:major
|
|
||||||
:minor
|
|
||||||
:patch
|
|
||||||
|
|
||||||
@options = { dry_run: false, bump_number: :patch }
|
|
||||||
|
|
||||||
OptionParser.new { |opts|
|
|
||||||
opts.banner = "Usage: bump.rb [options]"
|
|
||||||
|
|
||||||
opts.on("-d", "--dry-run", "Dry run") do |v|
|
|
||||||
@options[:dry_run] = v
|
|
||||||
end
|
|
||||||
opts.on("-a", "--major", "Bump major version") do |_v|
|
|
||||||
@options[:bump_number] = :major
|
|
||||||
end
|
|
||||||
opts.on("-m", "--minor", "Bump minor version") do |_v|
|
|
||||||
@options[:bump_number] = :minor
|
|
||||||
end
|
|
||||||
opts.on("-p", "--patch", "Bump patch version") do |_v|
|
|
||||||
@options[:bump_number] = :patch
|
|
||||||
end
|
|
||||||
opts.on("-r", "--revert", "Revert last bump") do |v|
|
|
||||||
@options[:revert] = v
|
|
||||||
end
|
|
||||||
}.parse!
|
|
||||||
|
|
||||||
p @options
|
|
||||||
|
|
||||||
def check_repo_is_clean_or_dry_run
|
|
||||||
value = `#{"git status --porcelain"}`
|
|
||||||
|
|
||||||
if value.empty?
|
|
||||||
puts "Repo is clean -> continue"
|
|
||||||
else
|
|
||||||
if @options[:dry_run]
|
|
||||||
puts 'Repo not clean, "Dry run" enabled -> continue'
|
|
||||||
else
|
|
||||||
puts "Repository not clean -> exit"
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_spec_file
|
|
||||||
list_of_specs = execute_line("find . -name '*.#{SPEC_TYPE}'")
|
|
||||||
arr = list_of_specs.split("\n")
|
|
||||||
|
|
||||||
spec_file = ""
|
|
||||||
|
|
||||||
case arr.count
|
|
||||||
when 0
|
|
||||||
puts "No #{SPEC_TYPE} files found. -> Exit."
|
|
||||||
exit
|
|
||||||
when 1
|
|
||||||
spec_file = arr[0]
|
|
||||||
else
|
|
||||||
puts "Which spec should be used?"
|
|
||||||
arr.each_with_index { |file, index| puts "#{index + 1}. #{file}" }
|
|
||||||
input_index = Integer(gets.chomp)
|
|
||||||
spec_file = arr[input_index - 1]
|
|
||||||
end
|
|
||||||
|
|
||||||
if spec_file.nil?
|
|
||||||
puts "Can't find specified spec file -> exit"
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
spec_file.sub("./", "")
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_current_gem_file
|
|
||||||
list_of_specs = execute_line("find . -name '*.gem'")
|
|
||||||
arr = list_of_specs.split("\n")
|
|
||||||
|
|
||||||
spec_file = ""
|
|
||||||
|
|
||||||
case arr.count
|
|
||||||
when 0
|
|
||||||
puts "No #{SPEC_TYPE} files found. -> Exit."
|
|
||||||
exit
|
|
||||||
when 1
|
|
||||||
spec_file = arr[0]
|
|
||||||
else
|
|
||||||
puts "Which spec should be used?"
|
|
||||||
arr.each_with_index { |file, index| puts "#{index + 1}. #{file}" }
|
|
||||||
input_index = Integer(gets.chomp)
|
|
||||||
spec_file = arr[input_index - 1]
|
|
||||||
end
|
|
||||||
|
|
||||||
if spec_file.nil?
|
|
||||||
puts "Can't find specified spec file -> exit"
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
spec_file.sub("./", "")
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_version_in_podspec(podspec)
|
|
||||||
readme = File.read(podspec)
|
|
||||||
|
|
||||||
# try to find version in format 1.22.333
|
|
||||||
re = /(\d+)\.(\d+)\.(\d+)/m
|
|
||||||
|
|
||||||
match_result = re.match(readme)
|
|
||||||
|
|
||||||
unless match_result
|
|
||||||
puts "Not found any versions"
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
puts "Found version #{match_result[0]}"
|
|
||||||
[match_result[0], match_result.captures]
|
|
||||||
end
|
|
||||||
|
|
||||||
def bump_version(versions_array)
|
|
||||||
bumped_result = versions_array.dup
|
|
||||||
bumped_result.map!(&:to_i)
|
|
||||||
|
|
||||||
case @options[:bump_number]
|
|
||||||
when :major
|
|
||||||
bumped_result[0] += 1
|
|
||||||
bumped_result[1] = 0
|
|
||||||
bumped_result[2] = 0
|
|
||||||
when :minor
|
|
||||||
bumped_result[1] += 1
|
|
||||||
bumped_result[2] = 0
|
|
||||||
when :patch
|
|
||||||
bumped_result[2] += 1
|
|
||||||
else
|
|
||||||
fail("unknown bump_number")
|
|
||||||
end
|
|
||||||
|
|
||||||
bumped_version = bumped_result.join(".")
|
|
||||||
puts "Bump version: #{versions_array.join('.')} -> #{bumped_version}"
|
|
||||||
bumped_version
|
|
||||||
end
|
|
||||||
|
|
||||||
def execute_line(line)
|
|
||||||
output = `#{line}`
|
|
||||||
check_exit_status(output)
|
|
||||||
|
|
||||||
output
|
|
||||||
end
|
|
||||||
|
|
||||||
def execute_line_if_not_dry_run(line)
|
|
||||||
if @options[:dry_run]
|
|
||||||
puts "Dry run: #{line}"
|
|
||||||
nil
|
|
||||||
else
|
|
||||||
puts line
|
|
||||||
value = `#{line}`
|
|
||||||
puts value
|
|
||||||
check_exit_status(value)
|
|
||||||
value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_exit_status(output)
|
|
||||||
if $CHILD_STATUS.exitstatus != 0
|
|
||||||
puts "Output:\n#{output}\nExit status = #{$CHILD_STATUS.exitstatus} ->Terminate script."
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def run_bumping_script
|
|
||||||
check_repo_is_clean_or_dry_run
|
|
||||||
spec_file = find_spec_file
|
|
||||||
result, versions_array = find_version_in_podspec(spec_file)
|
|
||||||
bumped_version = bump_version(versions_array)
|
|
||||||
|
|
||||||
unless @options[:dry_run]
|
|
||||||
puts "Are you sure? Press Y to continue:"
|
|
||||||
str = gets.chomp
|
|
||||||
if str != "Y"
|
|
||||||
puts "-> exit"
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
execute_line_if_not_dry_run("sed -i \"\" \"s/#{result}/#{bumped_version}/\" README.md")
|
|
||||||
execute_line_if_not_dry_run("sed -i \"\" \"s/#{result}/#{bumped_version}/\" #{spec_file}")
|
|
||||||
execute_line_if_not_dry_run("git commit --all -m \"Update #{$SPEC_TYPE} to version #{bumped_version}\"")
|
|
||||||
execute_line_if_not_dry_run("git tag #{bumped_version}")
|
|
||||||
execute_line_if_not_dry_run("git push")
|
|
||||||
execute_line_if_not_dry_run("git push --tags")
|
|
||||||
execute_line_if_not_dry_run("gem build #{spec_file}")
|
|
||||||
|
|
||||||
gem = find_current_gem_file
|
|
||||||
execute_line_if_not_dry_run("gem push #{gem}")
|
|
||||||
# execute_line_if_not_dry_run("pod trunk push #{spec_file}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def revert_last_bump
|
|
||||||
spec_file = find_spec_file
|
|
||||||
result, _ = find_version_in_podspec(spec_file)
|
|
||||||
|
|
||||||
puts "DELETE tag #{result} and HARD reset HEAD~1?\nPress Y to continue:"
|
|
||||||
str = gets.chomp
|
|
||||||
if str != "Y"
|
|
||||||
puts "-> exit"
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
execute_line_if_not_dry_run("git tag -d #{result}")
|
|
||||||
execute_line_if_not_dry_run("git reset --hard HEAD~1")
|
|
||||||
execute_line_if_not_dry_run("git push --delete origin #{result}")
|
|
||||||
end
|
|
||||||
|
|
||||||
if __FILE__ == $PROGRAM_NAME
|
|
||||||
|
|
||||||
if @options[:revert]
|
|
||||||
revert_last_bump
|
|
||||||
else
|
|
||||||
run_bumping_script
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -118,9 +118,9 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
|
||||||
end
|
end
|
||||||
|
|
||||||
# remove pull request from issues:
|
# remove pull request from issues:
|
||||||
issues.partition { |x|
|
issues.partition do |x|
|
||||||
x[:pull_request].nil?
|
x[:pull_request].nil?
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Fetch all pull requests. We need them to detect :merged_at parameter
|
# Fetch all pull requests. We need them to detect :merged_at parameter
|
||||||
|
@ -151,9 +151,9 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
|
||||||
i = 0
|
i = 0
|
||||||
max_thread_number = 50
|
max_thread_number = 50
|
||||||
threads = []
|
threads = []
|
||||||
issues.each_slice(max_thread_number) { |issues_slice|
|
issues.each_slice(max_thread_number) do |issues_slice|
|
||||||
issues_slice.each { |issue|
|
issues_slice.each do |issue|
|
||||||
threads << Thread.new {
|
threads << Thread.new do
|
||||||
begin
|
begin
|
||||||
obj = @github.issues.events.list user: @options[:user],
|
obj = @github.issues.events.list user: @options[:user],
|
||||||
repo: @options[:project],
|
repo: @options[:project],
|
||||||
|
@ -164,11 +164,11 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
|
||||||
issue[:events] = obj.body
|
issue[:events] = obj.body
|
||||||
print "Fetching events for issues and PR: #{i + 1}/#{issues.count}\r"
|
print "Fetching events for issues and PR: #{i + 1}/#{issues.count}\r"
|
||||||
i += 1
|
i += 1
|
||||||
}
|
end
|
||||||
}
|
end
|
||||||
threads.each(&:join)
|
threads.each(&:join)
|
||||||
threads = []
|
threads = []
|
||||||
}
|
end
|
||||||
|
|
||||||
# to clear line from prev print
|
# to clear line from prev print
|
||||||
print " \r"
|
print " \r"
|
||||||
|
|
|
@ -171,7 +171,8 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
if match && match[1] && match[2]
|
if match && match[1] && match[2]
|
||||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||||
options[:user], options[:project] = match[1], match[2]
|
options[:user] = match[1]
|
||||||
|
options[:project] = match[2]
|
||||||
else
|
else
|
||||||
# try to find repo in format:
|
# try to find repo in format:
|
||||||
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
||||||
|
@ -179,7 +180,8 @@ module GitHubChangelogGenerator
|
||||||
match = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/.match(remote)
|
match = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/.match(remote)
|
||||||
if match && match[1] && match[2]
|
if match && match[1] && match[2]
|
||||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||||
options[:user], options[:project] = match[1], match[2]
|
options[:user] = match[1]
|
||||||
|
options[:project] = match[2]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user