Allow symlinking existing directories into repos, instead of cloning.
This commit is contained in:
@@ -9,7 +9,7 @@ class Homesick < Thor
|
|||||||
|
|
||||||
add_runtime_options!
|
add_runtime_options!
|
||||||
|
|
||||||
GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+)\/([A-Za-z_-]+)\Z/
|
GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/
|
||||||
|
|
||||||
def initialize(args=[], options={}, config={})
|
def initialize(args=[], options={}, config={})
|
||||||
super
|
super
|
||||||
@@ -19,8 +19,10 @@ 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
|
||||||
if uri =~ GITHUB_NAME_REPO_PATTERN
|
if File.exist?(uri)
|
||||||
git_clone "git://github.com/#{$1}/#{$2}.git", :destination => "#{$1}/#{$2}"
|
ln_s uri, File.basename(uri)
|
||||||
|
elsif uri =~ GITHUB_NAME_REPO_PATTERN
|
||||||
|
git_clone "git://github.com/#{$1}.git", :destination => $1
|
||||||
else
|
else
|
||||||
git_clone uri
|
git_clone uri
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Homesick
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ln_s(source, destination, config = {})
|
def ln_s(source, destination, config = {})
|
||||||
|
source = Pathname.new(source)
|
||||||
destination = Pathname.new(destination)
|
destination = Pathname.new(destination)
|
||||||
|
|
||||||
if destination.symlink?
|
if destination.symlink?
|
||||||
|
|||||||
@@ -6,6 +6,15 @@ describe Homesick do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "clone" do
|
describe "clone" do
|
||||||
|
it "should symlink existing directories" do
|
||||||
|
somewhere = create_construct
|
||||||
|
somewhere.directory('wtf')
|
||||||
|
wtf = somewhere + 'wtf'
|
||||||
|
|
||||||
|
@homesick.should_receive(:ln_s).with(wtf.to_s, wtf.basename.to_s)
|
||||||
|
|
||||||
|
@homesick.clone wtf.to_s
|
||||||
|
end
|
||||||
it "should clone git repo like git://host/path/to.git" do
|
it "should clone git repo like git://host/path/to.git" do
|
||||||
@homesick.should_receive(:git_clone).with('git://github.com/technicalpickles/pickled-vim.git')
|
@homesick.should_receive(:git_clone).with('git://github.com/technicalpickles/pickled-vim.git')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user