Cloning will now try to init and update git submodules, if they exist.
This commit is contained in:
@@ -19,13 +19,28 @@ class Homesick < Thor
|
|||||||
desc "clone URI", "Clone +uri+ as a castle for homesick"
|
desc "clone URI", "Clone +uri+ as a castle for homesick"
|
||||||
def clone(uri)
|
def clone(uri)
|
||||||
inside repos_dir do
|
inside repos_dir do
|
||||||
|
destination = nil
|
||||||
if File.exist?(uri)
|
if File.exist?(uri)
|
||||||
ln_s uri, File.basename(uri)
|
destination = Pathname.new(uri).basename
|
||||||
|
|
||||||
|
ln_s uri, destination
|
||||||
elsif uri =~ GITHUB_NAME_REPO_PATTERN
|
elsif uri =~ GITHUB_NAME_REPO_PATTERN
|
||||||
git_clone "git://github.com/#{$1}.git", :destination => $1
|
destination = Pathname.new($1)
|
||||||
|
git_clone "git://github.com/#{$1}.git", :destination => destination
|
||||||
else
|
else
|
||||||
|
if uri =~ /\/([^\/]*).git\Z/
|
||||||
|
destination = Pathname.new($1)
|
||||||
|
end
|
||||||
|
|
||||||
git_clone uri
|
git_clone uri
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if destination.join('.gitmodules').exist?
|
||||||
|
inside destination do
|
||||||
|
git_submodule_init
|
||||||
|
git_submodule_update
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class Homesick
|
|||||||
config ||= {}
|
config ||= {}
|
||||||
destination = config[:destination] || begin
|
destination = config[:destination] || begin
|
||||||
repo =~ /([^\/]+)\.git$/
|
repo =~ /([^\/]+)\.git$/
|
||||||
$1
|
$1
|
||||||
end
|
end
|
||||||
|
|
||||||
destination = Pathname.new(destination) unless destination.kind_of?(Pathname)
|
destination = Pathname.new(destination) unless destination.kind_of?(Pathname)
|
||||||
@@ -19,6 +19,16 @@ class Homesick
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def git_submodule_init(config = {})
|
||||||
|
say_status 'git submodule', 'init', :green unless options[:quiet]
|
||||||
|
system "git submodule --quiet init" unless options[:pretend]
|
||||||
|
end
|
||||||
|
|
||||||
|
def git_submodule_update(config = {})
|
||||||
|
say_status 'git submodule', 'update', :green unless options[:quiet]
|
||||||
|
system "git submodule --quiet update >/dev/null 2>&1" unless options[:pretend]
|
||||||
|
end
|
||||||
|
|
||||||
def ln_s(source, destination, config = {})
|
def ln_s(source, destination, config = {})
|
||||||
source = Pathname.new(source)
|
source = Pathname.new(source)
|
||||||
destination = Pathname.new(destination)
|
destination = Pathname.new(destination)
|
||||||
|
|||||||
Reference in New Issue
Block a user