From 95d22951b352d8d554ff423248b6c76abaf54923 Mon Sep 17 00:00:00 2001 From: Jorge Dias Date: Fri, 9 Apr 2010 19:02:43 +0200 Subject: [PATCH 1/3] Implemented update action for castle --- lib/homesick.rb | 26 ++++++++++++++++++++------ lib/homesick/actions.rb | 5 +++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index fb82908..87a1982 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -44,13 +44,20 @@ class Homesick < Thor end end + desc "update NAME", "Update the specified castle" + def update(name) + check_castle_existance(name, "update") + + inside repos_dir.join(name) do + git_pull + git_submodule_init + git_submodule_update + end + end + desc "symlink NAME", "Symlinks all dotfiles from the specified castle" def symlink(name) - unless castle_dir(name).exist? - say_status :error, "Could not symlink #{name}, expected #{castle_dir(name)} exist and contain dotfiles", :red - - exit(1) - end + check_castle_existance(name, "symlink") inside castle_dir(name) do files = Pathname.glob('.*').reject{|a| [".",".."].include?(a.to_s)} @@ -85,9 +92,16 @@ class Homesick < Thor @repos_dir ||= home_dir.join('.homesick', 'repos').expand_path end - def castle_dir(name) repos_dir.join(name, 'home') end + def check_castle_existance(name, action) + unless castle_dir(name).exist? + say_status :error, "Could not #{action} #{name}, expected #{castle_dir(name)} exist and contain dotfiles", :red + + exit(1) + end + end + end diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index e92e688..4041ae7 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -29,6 +29,11 @@ class Homesick system "git submodule --quiet update >/dev/null 2>&1" unless options[:pretend] end + def git_pull(config = {}) + say_status 'git pull', '', :green unless options[:quiet] + system "git pull --quiet" unless options[:pretend] + end + def ln_s(source, destination, config = {}) source = Pathname.new(source) destination = Pathname.new(destination) From 94975b49e7714a18e7b1c8479e3be2114a3555a6 Mon Sep 17 00:00:00 2001 From: Jorge Dias Date: Sun, 2 May 2010 19:14:16 +0200 Subject: [PATCH 2/3] Changed update to pull to match git commands --- lib/homesick.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 87a1982..5efd216 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -44,9 +44,9 @@ class Homesick < Thor end end - desc "update NAME", "Update the specified castle" - def update(name) - check_castle_existance(name, "update") + desc "pull NAME", "Update the specified castle" + def pull(name) + check_castle_existance(name, "pull") inside repos_dir.join(name) do git_pull From 53ed5697b889149f31b9de4a16da38e48081cd62 Mon Sep 17 00:00:00 2001 From: Darcy Laycock Date: Mon, 17 May 2010 02:06:06 +0800 Subject: [PATCH 3/3] Add note to readme re. github and symlink --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index c46328c..00034a9 100644 --- a/README.markdown +++ b/README.markdown @@ -25,6 +25,10 @@ With the castle cloned, you can now link its contents into your home dir: homesick symlink pickled-vim +If uou use the shorthand syntax for GitHub repositories in your clone, please note you will instead need to run: + + homesick symlink technicalpickles/pickled-vim + If you're not sure what castles you have around, you can easily list them: homesick list