diff --git a/.rubocop.yml b/.rubocop.yml index 65c6cf8..b973d36 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,10 +10,10 @@ ClassLength: Enabled: false CyclomaticComplexity: - Max: 16 + Max: 9 LineLength: - Max: 174 + Max: 163 MethodLength: Max: 31 diff --git a/lib/homesick.rb b/lib/homesick.rb index 026d6e6..c707dfc 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -40,23 +40,13 @@ class Homesick < Thor elsif uri =~ GITHUB_NAME_REPO_PATTERN destination = Pathname.new(uri).basename git_clone "https://github.com/#{Regexp.last_match[1]}.git", destination: destination - elsif uri =~ /%r([^%r]*?)(\.git)?\Z/ + elsif uri =~ /%r([^%r]*?)(\.git)?\Z/ || uri =~ /[^:]+:([^:]+)(\.git)?\Z/ destination = Pathname.new(Regexp.last_match[1]) - git_clone uri - elsif uri =~ /[^:]+:([^:]+)(\.git)?\Z/ - destination = Pathname.new(Regexp.last_match[1]) - git_clone uri + git_clone uri, destination: destination else fail "Unknown URI format: #{uri}" end - if destination.join('.gitmodules').exist? - inside destination do - git_submodule_init - git_submodule_update - end - end - rc(destination) end end diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 096aad4..c9d73e9 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -16,6 +16,17 @@ class Homesick say_status 'git clone', "#{repo} to #{destination.expand_path}", :green unless options[:quiet] system "git clone -q --config push.default=upstream --recursive #{repo} #{destination}" unless options[:pretend] end + + git_setup_submodules destination + end + + def git_setup_submodules(path) + if path.join('.gitmodules').exist? + inside path do + git_submodule_init + git_submodule_update + end + end end def git_init(path = '.')