fix regex mess
This commit is contained in:
parent
134c18ba06
commit
c3b9455dfd
|
@ -1,5 +1,5 @@
|
||||||
# This configuration was generated by `rubocop --auto-gen-config`
|
# This configuration was generated by `rubocop --auto-gen-config`
|
||||||
# on 2015-05-22 17:34:14 +0300 using RuboCop version 0.31.0.
|
# on 2015-05-25 12:59:32 +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
|
||||||
|
@ -7,29 +7,25 @@
|
||||||
|
|
||||||
# Offense count: 16
|
# Offense count: 16
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 73
|
Max: 68
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
Metrics/BlockNesting:
|
|
||||||
Max: 4
|
|
||||||
|
|
||||||
# Offense count: 4
|
# Offense count: 4
|
||||||
# Configuration parameters: CountComments.
|
# Configuration parameters: CountComments.
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Max: 162
|
Max: 166
|
||||||
|
|
||||||
# Offense count: 4
|
# Offense count: 3
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 15
|
Max: 9
|
||||||
|
|
||||||
# Offense count: 21
|
# Offense count: 22
|
||||||
# Configuration parameters: CountComments.
|
# Configuration parameters: CountComments.
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Max: 121
|
Max: 117
|
||||||
|
|
||||||
# Offense count: 5
|
# Offense count: 4
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 18
|
Max: 12
|
||||||
|
|
||||||
# Offense count: 2
|
# Offense count: 2
|
||||||
Style/AccessorMethodName:
|
Style/AccessorMethodName:
|
||||||
|
|
|
@ -30,7 +30,7 @@ module GitHubChangelogGenerator
|
||||||
issue_prefix: "**Closed issues:**",
|
issue_prefix: "**Closed issues:**",
|
||||||
bug_prefix: "**Fixed bugs:**",
|
bug_prefix: "**Fixed bugs:**",
|
||||||
enhancement_prefix: "**Implemented enhancements:**",
|
enhancement_prefix: "**Implemented enhancements:**",
|
||||||
branch: "origin"
|
git_remote: "origin"
|
||||||
}
|
}
|
||||||
|
|
||||||
parser = OptionParser.new do |opts|
|
parser = OptionParser.new do |opts|
|
||||||
|
@ -123,11 +123,6 @@ module GitHubChangelogGenerator
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
if ARGV[1]
|
|
||||||
options[:tag1] = ARGV[0]
|
|
||||||
options[:tag2] = ARGV[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
if options[:verbose]
|
if options[:verbose]
|
||||||
puts "Performing task with options:"
|
puts "Performing task with options:"
|
||||||
pp options
|
pp options
|
||||||
|
@ -138,6 +133,18 @@ module GitHubChangelogGenerator
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.detect_user_and_project(options)
|
def self.detect_user_and_project(options)
|
||||||
|
user_project_from_option(options)
|
||||||
|
if !options[:user] || !options[:project]
|
||||||
|
if ENV["RUBYLIB"] =~ /ruby-debug-ide/
|
||||||
|
options[:user] = "skywinder"
|
||||||
|
options[:project] = "changelog_test"
|
||||||
|
else
|
||||||
|
options[:user], options[:project] = user_project_from_remote(options[:git_remote])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.user_project_from_option(options)
|
||||||
if ARGV[0] && !ARGV[1]
|
if ARGV[0] && !ARGV[1]
|
||||||
github_site = options[:github_site] ? options[:github_site] : "github.com"
|
github_site = options[:github_site] ? options[:github_site] : "github.com"
|
||||||
# this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or "skywinder/Github-Changelog-Generator" to user and name
|
# this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or "skywinder/Github-Changelog-Generator" to user and name
|
||||||
|
@ -155,37 +162,41 @@ module GitHubChangelogGenerator
|
||||||
options[:user] = match[1]
|
options[:user] = match[1]
|
||||||
options[:project] = match[2]
|
options[:project] = match[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if !options[:user] && !options[:project]
|
# Try to find user and project name from git remote
|
||||||
if ENV["RUBYLIB"] =~ /ruby-debug-ide/
|
#
|
||||||
options[:user] = "skywinder"
|
# @return [Tuple] user and project
|
||||||
options[:project] = "changelog_test"
|
def self.user_project_from_remote(git_remote)
|
||||||
else
|
# try to find repo in format:
|
||||||
remote = `git config --get remote.#{options[:branch]}.url`
|
# origin git@github.com:skywinder/Github-Changelog-Generator.git (fetch)
|
||||||
# try to find repo in format:
|
# git@github.com:skywinder/Github-Changelog-Generator.git
|
||||||
# origin git@github.com:skywinder/Github-Changelog-Generator.git (fetch)
|
regex1 = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)(?:\.git).*/
|
||||||
# git@github.com:skywinder/Github-Changelog-Generator.git
|
|
||||||
match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)(?:\.git).*/.match(remote)
|
|
||||||
|
|
||||||
if match && match[1] && match[2]
|
# try to find repo in format:
|
||||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
||||||
options[:user] = match[1]
|
# https://github.com/skywinder/ChangelogMerger
|
||||||
options[:project] = match[2]
|
regex2 = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/
|
||||||
else
|
|
||||||
# try to find repo in format:
|
remote_structures = [regex1, regex2]
|
||||||
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
|
||||||
# https://github.com/skywinder/ChangelogMerger
|
remote = `git config --get remote.#{git_remote}.url`
|
||||||
match = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/.match(remote)
|
user = nil
|
||||||
if match && match[1] && match[2]
|
project = nil
|
||||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
remote_structures.each do |regex|
|
||||||
options[:user] = match[1]
|
matches = Regexp.new(regex).match(remote)
|
||||||
options[:project] = match[2]
|
|
||||||
end
|
if matches && matches[1] && matches[2]
|
||||||
end
|
puts "Detected user:#{matches[1]}, project:#{matches[2]}"
|
||||||
|
user = matches[1]
|
||||||
|
project = matches[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
break unless matches.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
[user, project]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user