From 8a41dca46d526c9118c064d539063b42391c8398 Mon Sep 17 00:00:00 2001 From: Thilko Richter Date: Thu, 6 Sep 2012 07:38:54 +0200 Subject: [PATCH 01/97] destroy action implemented --- lib/homesick.rb | 20 +++++++++++++++++++- lib/homesick/actions.rb | 11 +++++++++++ spec/homesick_spec.rb | 23 ++++++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index f19aca9..4c8711c 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'thor' class Homesick < Thor @@ -102,7 +103,7 @@ class Homesick < Thor castle = Pathname.new(castle) file = Pathname.new(file) check_castle_existance(castle, 'track') - + absolute_path = file.expand_path castle_path = castle_dir(castle) mv absolute_path, castle_path @@ -141,6 +142,23 @@ class Homesick < Thor end end + desc "destroy CASTLE", "Delete all symlnks and remove the cloned repository" + def destroy(name) + check_castle_existance name, "destroy" + + inside castle_dir(name) do + files = Pathname.glob('{.*,*}').reject{|a| [".",".."].include?(a.to_s)} + files.each do |path| + + inside home_dir do + adjusted_path = (home_dir + path).basename + rm adjusted_path + end + end + rm_r castle_dir(name) + end + + end protected diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 603ad68..9d15c5a 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Homesick module Actions # TODO move this to be more like thor's template, empty_directory, etc @@ -75,6 +76,16 @@ class Homesick end end + def rm(file) + say_status "rm #{file}", '', :green unless options[:quiet] + system "rm #{file}" + end + + def rm_r(dir) + say_status "rm -r #{dir}", '', :green unless options[:quiet] + system "rm -r #{dir}" + end + def ln_s(source, destination, config = {}) source = Pathname.new(source) destination = Pathname.new(destination) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 5dd2b6d..4e912da 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -1,4 +1,5 @@ -require 'spec_helper' +# -*- encoding : utf-8 -*- +require 'spec_helper' describe "homesick" do let(:home) { create_construct } @@ -158,4 +159,24 @@ describe "homesick" do some_rc_file.readlink.should == tracked_file end end + + describe "destroy" do + it "removes the symlink files" do + given_castle("stronghold") + some_rc_file = home.file '.some_rc_file' + homesick.track(some_rc_file.to_s, "stronghold") + homesick.destroy('stronghold') + + some_rc_file.should_not be_exist + end + + it "deletes the cloned repository" do + castle = given_castle("stronghold") + some_rc_file = home.file '.some_rc_file' + homesick.track(some_rc_file.to_s, "stronghold") + homesick.destroy('stronghold') + + castle.should_not be_exist + end + end end From fede78c33736faff6320318aeb2adec6bc92c7e3 Mon Sep 17 00:00:00 2001 From: Thilko Richter Date: Thu, 6 Sep 2012 21:12:31 +0200 Subject: [PATCH 02/97] cleanup correctly --- lib/homesick.rb | 2 +- lib/homesick/actions.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 4c8711c..f927744 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -155,7 +155,7 @@ class Homesick < Thor rm adjusted_path end end - rm_r castle_dir(name) + rm_rf repos_dir + name end end diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 9d15c5a..6ea6402 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -78,12 +78,12 @@ class Homesick def rm(file) say_status "rm #{file}", '', :green unless options[:quiet] - system "rm #{file}" + system "rm #{file}" if File.exists?(file) end - def rm_r(dir) - say_status "rm -r #{dir}", '', :green unless options[:quiet] - system "rm -r #{dir}" + def rm_rf(dir) + say_status "rm -rf #{dir}", '', :green unless options[:quiet] + system "rm -rf #{dir}" end def ln_s(source, destination, config = {}) From 54b2b9b33926d91a855d49e9f76bd4a31cf5582a Mon Sep 17 00:00:00 2001 From: Thilko Richter Date: Thu, 6 Sep 2012 21:23:45 +0200 Subject: [PATCH 03/97] correct typo --- lib/homesick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index f927744..ce05897 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -142,7 +142,7 @@ class Homesick < Thor end end - desc "destroy CASTLE", "Delete all symlnks and remove the cloned repository" + desc "destroy CASTLE", "Delete all symlinks and remove the cloned repository" def destroy(name) check_castle_existance name, "destroy" From 2667053fde18bdd73f6d3c9af777c23660de6ebf Mon Sep 17 00:00:00 2001 From: Jorge Date: Sat, 30 Oct 2010 21:31:59 +0200 Subject: [PATCH 04/97] Making git repos uri non greedy so it works with uris with / --- lib/homesick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index ce05897..7646ff9 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -33,7 +33,7 @@ class Homesick < Thor elsif uri =~ GITHUB_NAME_REPO_PATTERN destination = Pathname.new($1) git_clone "git://github.com/#{$1}.git", :destination => destination - elsif uri =~ /\/([^\/]*)(\.git)?\Z/ + elsif uri =~ /\/([^\/]*?)(\.git)?\Z/ destination = Pathname.new($1) git_clone uri elsif uri =~ /[^:]+:([^:]+)(\.git)?\Z/ From 9ac754fd407ebdafdf1b67e7b5c5e3586b8a2d04 Mon Sep 17 00:00:00 2001 From: Jason Buckner Date: Sat, 24 Nov 2012 21:01:37 -0800 Subject: [PATCH 05/97] start adding git push functionality --- lib/homesick.rb | 15 +++++++++++++++ lib/homesick/actions.rb | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/homesick.rb b/lib/homesick.rb index 7646ff9..795e212 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -79,6 +79,13 @@ class Homesick < Thor end + desc "push NAME", "Push the specified castle" + method_option :all, :type => :boolean, :default => false, :required => false, :desc => "Update all cloned castles" + def push(name) + push_castle name + + end + desc "symlink NAME", "Symlinks all dotfiles from the specified castle" method_option :force, :default => false, :desc => "Overwrite existing conflicting symlinks without prompting." def symlink(name) @@ -207,4 +214,12 @@ class Homesick < Thor git_submodule_update end end + + def push_castle(castle) + check_castle_existance(castle, "push") + inside repos_dir.join(castle) do + git_commit_all + git_push + end + end end diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 6ea6402..998c696 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -60,6 +60,16 @@ class Homesick system "git pull --quiet" unless options[:pretend] end + def git_push(config = {}) + say_status 'git push', '', :green unless options[:quiet] + system "git push" unless options[:pretend] + end + + def git_commit_all(config = {}) + say_status 'git commit all', '', :green unless options[:quiet] + system "git commit -v -a" unless options[:pretend] + end + def mv(source, destination, config = {}) source = Pathname.new(source) destination = Pathname.new(destination + source.basename) From f18a4dc16f4531ad0d817a349de01d3fd3f3f0c7 Mon Sep 17 00:00:00 2001 From: Jason Buckner Date: Sat, 24 Nov 2012 21:24:41 -0800 Subject: [PATCH 06/97] add homesick push to readme, a placeholder test, and removed the all option from git push --- README.markdown | 8 ++++++++ lib/homesick.rb | 1 - spec/homesick_spec.rb | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index f264833..09411bf 100644 --- a/README.markdown +++ b/README.markdown @@ -33,6 +33,14 @@ If you're not sure what castles you have around, you can easily list them: homesick list +To pull your castle (omit CASTLE_NAME to pull all castles): + + homesick pull CASTLE_NAME + +To push your castle: + + homesick push CASTLE_NAME + Not sure what else homesick has up its sleeve? There's always the built in help: homesick help diff --git a/lib/homesick.rb b/lib/homesick.rb index 795e212..aa41310 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -80,7 +80,6 @@ class Homesick < Thor end desc "push NAME", "Push the specified castle" - method_option :all, :type => :boolean, :default => false, :required => false, :desc => "Update all cloned castles" def push(name) push_castle name diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 4e912da..1a64025 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -145,6 +145,12 @@ describe "homesick" do end + describe "push" do + + xit "needs testing" + + end + describe "track" do it "should move the tracked file into the castle" do castle = given_castle('castle_repo') From 0a022fddcc157df8ae780586920685340f837918 Mon Sep 17 00:00:00 2001 From: Jason Buckner Date: Sat, 24 Nov 2012 22:36:45 -0800 Subject: [PATCH 07/97] fix homesick pull documentation --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 09411bf..d9aac4e 100644 --- a/README.markdown +++ b/README.markdown @@ -33,9 +33,9 @@ If you're not sure what castles you have around, you can easily list them: homesick list -To pull your castle (omit CASTLE_NAME to pull all castles): +To pull your castle (or all castles): - homesick pull CASTLE_NAME + homesick pull --all|CASTLE_NAME To push your castle: From 5e9d134021901ed7f48366f77e6b4acfcf93afda Mon Sep 17 00:00:00 2001 From: Jason Buckner Date: Sat, 24 Nov 2012 22:56:17 -0800 Subject: [PATCH 08/97] update documentation for naming consistency --- README.markdown | 4 ++-- lib/homesick.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index d9aac4e..c58edfe 100644 --- a/README.markdown +++ b/README.markdown @@ -35,11 +35,11 @@ If you're not sure what castles you have around, you can easily list them: To pull your castle (or all castles): - homesick pull --all|CASTLE_NAME + homesick pull --all|CASTLE To push your castle: - homesick push CASTLE_NAME + homesick push CASTLE Not sure what else homesick has up its sleeve? There's always the built in help: diff --git a/lib/homesick.rb b/lib/homesick.rb index aa41310..a705046 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -65,7 +65,7 @@ class Homesick < Thor end end - desc "pull NAME", "Update the specified castle" + desc "pull CASTLE", "Update the specified castle" method_option :all, :type => :boolean, :default => false, :required => false, :desc => "Update all cloned castles" def pull(name="") if options[:all] @@ -79,13 +79,13 @@ class Homesick < Thor end - desc "push NAME", "Push the specified castle" + desc "push CASTLE", "Push the specified castle" def push(name) push_castle name end - desc "symlink NAME", "Symlinks all dotfiles from the specified castle" + desc "symlink CASTLE", "Symlinks all dotfiles from the specified castle" method_option :force, :default => false, :desc => "Overwrite existing conflicting symlinks without prompting." def symlink(name) check_castle_existance(name, "symlink") From 123e6cf82d04361900edd62fb216c8d8901c9e69 Mon Sep 17 00:00:00 2001 From: Jason Buckner Date: Sat, 24 Nov 2012 23:18:48 -0800 Subject: [PATCH 09/97] splits up castle commit from castle push for more fine-grained control --- README.markdown | 4 ++++ lib/homesick.rb | 14 +++++++++++++- spec/homesick_spec.rb | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index c58edfe..63e3d36 100644 --- a/README.markdown +++ b/README.markdown @@ -37,6 +37,10 @@ To pull your castle (or all castles): homesick pull --all|CASTLE +To commit your castle's changes: + + homesick commit CASTLE + To push your castle: homesick push CASTLE diff --git a/lib/homesick.rb b/lib/homesick.rb index a705046..634ea98 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -79,6 +79,12 @@ class Homesick < Thor end + desc "commit CASTLE", "Commit the specified castle's changes" + def commit(name) + commit_castle name + + end + desc "push CASTLE", "Push the specified castle" def push(name) push_castle name @@ -214,10 +220,16 @@ class Homesick < Thor end end + def commit_castle(castle) + check_castle_existance(castle, "commit") + inside repos_dir.join(castle) do + git_commit_all + end + end + def push_castle(castle) check_castle_existance(castle, "push") inside repos_dir.join(castle) do - git_commit_all git_push end end diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 1a64025..b3c5341 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -145,6 +145,12 @@ describe "homesick" do end + describe "commit" do + + xit "needs testing" + + end + describe "push" do xit "needs testing" From 3bc623be7c3203610cca75516f982af4b017ae2b Mon Sep 17 00:00:00 2001 From: Jason Buckner Date: Sat, 24 Nov 2012 23:56:12 -0800 Subject: [PATCH 10/97] perform a git add when doing a homesick track --- lib/homesick.rb | 4 ++++ lib/homesick/actions.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/homesick.rb b/lib/homesick.rb index 634ea98..06a6210 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -125,6 +125,10 @@ class Homesick < Thor home_path = home_dir + file ln_s absolute_path, home_path end + + inside castle_path do + git_add absolute_path + end end desc "list", "List cloned castles" diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 998c696..d5c0cfe 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -70,6 +70,11 @@ class Homesick system "git commit -v -a" unless options[:pretend] end + def git_add(file, config = {}) + say_status 'git add file', '', :green unless options[:quiet] + system "git add #{file}" unless options[:pretend] + end + def mv(source, destination, config = {}) source = Pathname.new(source) destination = Pathname.new(destination + source.basename) From 1df44aea40b6fe0db0606d39e0401818873f1e38 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 6 Dec 2012 20:10:18 +0900 Subject: [PATCH 11/97] enable recursive submodule --- lib/homesick/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index d5c0cfe..b06fc7e 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -52,7 +52,7 @@ class Homesick 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] + system "git submodule --quiet update --init --recursive >/dev/null 2>&1" unless options[:pretend] end def git_pull(config = {}) From 107dec388e7fb1d0be9dc810ff610cd33439f840 Mon Sep 17 00:00:00 2001 From: Josh Nichols Date: Sun, 9 Dec 2012 15:33:15 -0500 Subject: [PATCH 12/97] Fix git_clone to work with github URLs like https://github.com/technicalpickles/dotpickles --- lib/homesick/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index b06fc7e..060d266 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -5,7 +5,7 @@ class Homesick def git_clone(repo, config = {}) config ||= {} destination = config[:destination] || begin - repo =~ /([^\/]+)\.git$/ + repo =~ /([^\/]+)(?:\.git)?$/ $1 end From 73981c2e759d333f2c127b02f8ca90e4ec6872a2 Mon Sep 17 00:00:00 2001 From: Jacob Buys Date: Mon, 18 Mar 2013 23:03:44 +0200 Subject: [PATCH 13/97] Build with Travis CI --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e14e9bc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: ruby +rvm: + - 1.9.3 + - 1.8.7 From 9fe1d190dab468ef50e5e3ac791135473e832081 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Sat, 6 Apr 2013 03:07:11 +0900 Subject: [PATCH 14/97] prepare for release 0.8.0 --- ChangeLog.markdown | 6 ++++++ Rakefile | 6 +++--- homesick.gemspec | 29 +++++++++++++++-------------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 63234e3..475cf1a 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,9 @@ +# 0.8.0 + * Introduce commit & push command + * commit changes in castle and push to remote + * Enable recursive submodule update + * Git add when track + # 0.7.0 * Fixed double-cloning #14 * New option for pull command: --all diff --git a/Rakefile b/Rakefile index 40254bf..b9c583b 100644 --- a/Rakefile +++ b/Rakefile @@ -19,10 +19,10 @@ Jeweler::Tasks.new do |gem| Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. } - gem.email = "josh@technicalpickles.com" + gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" - gem.authors = ["Joshua Nichols"] - gem.version = "0.7.0" + gem.authors = ["Joshua Nichols", "Yusuke Murata"] + gem.version = "0.8.0" gem.license = "MIT" # Have dependencies? Add them to Gemfile diff --git a/homesick.gemspec b/homesick.gemspec index 598c4a2..a4bae03 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,13 +5,13 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.7.0" + s.version = "0.8.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Joshua Nichols"] - s.date = "2012-05-28" + s.authors = ["Joshua Nichols", "Yusuke Murata"] + s.date = "2013-04-05" s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n " - s.email = "josh@technicalpickles.com" + s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] s.executables = ["homesick"] s.extra_rdoc_files = [ "ChangeLog.markdown", @@ -21,6 +21,7 @@ Gem::Specification.new do |s| s.files = [ ".document", ".rspec", + ".travis.yml", "ChangeLog.markdown", "Gemfile", "Gemfile.lock", @@ -39,7 +40,7 @@ Gem::Specification.new do |s| s.homepage = "http://github.com/technicalpickles/homesick" s.licenses = ["MIT"] s.require_paths = ["lib"] - s.rubygems_version = "1.8.15" + s.rubygems_version = "1.8.24" s.summary = "A man's home is his castle. Never leave your dotfiles behind." if s.respond_to? :specification_version then @@ -47,29 +48,29 @@ Gem::Specification.new do |s| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0.14.0"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, ["~> 2.1.0"]) + s.add_development_dependency(%q, ["~> 0.8.7"]) + s.add_development_dependency(%q, ["~> 2.10"]) s.add_development_dependency(%q, [">= 1.6.2"]) s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0.14.0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, ["~> 2.1.0"]) + s.add_dependency(%q, ["~> 0.8.7"]) + s.add_dependency(%q, ["~> 2.10"]) s.add_dependency(%q, [">= 1.6.2"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0.14.0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, ["~> 2.1.0"]) + s.add_dependency(%q, ["~> 0.8.7"]) + s.add_dependency(%q, ["~> 2.10"]) s.add_dependency(%q, [">= 1.6.2"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) end end From a3d94fcca622d4df2a9a30d4cab6bfc6cd80b9cc Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Sat, 6 Apr 2013 03:23:40 +0900 Subject: [PATCH 15/97] add build status to README --- README.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.markdown b/README.markdown index 63e3d36..a0d239d 100644 --- a/README.markdown +++ b/README.markdown @@ -1,5 +1,7 @@ # homesick +[![Build Status](https://travis-ci.org/technicalpickles/homesick.png?branch=master)](https://travis-ci.org/technicalpickles/homesick) + A man's home (directory) is his castle, so don't leave home with out it. Homesick is sorta like [rip](http://github.com/defunkt/rip), but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in `~/.homesick`. It then allows you to symlink all the dotfiles into place with a single command. From 0c933c0085be119cc2ed8bde0d72fd2045370e66 Mon Sep 17 00:00:00 2001 From: Eric West Date: Fri, 17 May 2013 02:37:44 -0500 Subject: [PATCH 16/97] Fixes glob to work with 2.0.0 homesick list fails on ruby 2.0.0-rc2, I think because they fixed this bug: https://bugs.ruby-lang.org/issues/6977, changing the way recursive globs work. Test case: ```ruby require "homesick" require "pathname" repos = Homesick.new.send :repos_dir Dir.glob("#{repos}/**/*/.git") # => [] Dir.glob("#{repos}/**/*/.git", File::FNM_DOTMATCH) # => ["/home/eric/.homesick/repos/dotfiles/.git"] ``` This change, however, then broke 1.9.3, but removing the extra "/*" works on both 1.9 and 2.0. --- lib/homesick.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 06a6210..d37d451 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -125,7 +125,7 @@ class Homesick < Thor home_path = home_dir + file ln_s absolute_path, home_path end - + inside castle_path do git_add absolute_path end @@ -199,7 +199,7 @@ class Homesick < Thor end def all_castles - dirs = Pathname.glob("#{repos_dir}/**/*/.git") + dirs = Pathname.glob("#{repos_dir}/**/.git", File::FNM_DOTMATCH) # reject paths that lie inside another castle, like git submodules return dirs.reject do |dir| dirs.any? {|other| dir != other && dir.fnmatch(other.parent.join('*').to_s) } @@ -223,7 +223,7 @@ class Homesick < Thor git_submodule_update end end - + def commit_castle(castle) check_castle_existance(castle, "commit") inside repos_dir.join(castle) do From eeff0b40fbf38416ea9c5436456227514edd3d5f Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Sun, 19 May 2013 13:37:54 +0000 Subject: [PATCH 17/97] update rake version "rake spec" showed following warning /home/muratayusuke/.rvm/gems/ruby-1.9.3-p392/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. (in /mnt/projects/homesick) /home/muratayusuke/.rvm/rubies/ruby-1.9.3-p392/bin/ruby -S rspec spec/homesick_spec.rb so update rake version to fix it. --- Gemfile | 4 ++-- Gemfile.lock | 40 ++++++++++++++++++++-------------------- Rakefile | 4 ++-- homesick.gemspec | 6 +++--- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Gemfile b/Gemfile index 9f78bc7..787a355 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source :gemcutter +source 'https://rubygems.org' # Add dependencies required to use your gem here. gem "thor", ">= 0.14.0" @@ -6,7 +6,7 @@ gem "thor", ">= 0.14.0" # Add dependencies to develop your gem here. # Include everything needed to run rake, tests, features, etc. group :development do - gem "rake", "~> 0.8.7" + gem "rake", ">= 0.8.7" gem "rspec", "~> 2.10" gem "jeweler", ">= 1.6.2" gem "rcov", :platforms => :mri_18 diff --git a/Gemfile.lock b/Gemfile.lock index 1844d0e..b46cf39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,40 +1,40 @@ GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - diff-lcs (1.1.3) + diff-lcs (1.2.4) git (1.2.5) - jeweler (1.8.3) + jeweler (1.8.4) bundler (~> 1.0) git (>= 1.2.5) rake rdoc - json (1.7.3) - multi_json (1.3.6) - rake (0.8.7) + json (1.8.0) + multi_json (1.7.3) + rake (10.0.4) rcov (1.0.0) - rdoc (3.12) + rdoc (4.0.1) json (~> 1.4) - rspec (2.10.0) - rspec-core (~> 2.10.0) - rspec-expectations (~> 2.10.0) - rspec-mocks (~> 2.10.0) - rspec-core (2.10.1) - rspec-expectations (2.10.0) - diff-lcs (~> 1.1.3) - rspec-mocks (2.10.1) - simplecov (0.6.4) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.1) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.1) + simplecov (0.7.1) multi_json (~> 1.0) - simplecov-html (~> 0.5.3) - simplecov-html (0.5.3) + simplecov-html (~> 0.7.1) + simplecov-html (0.7.1) test-construct (1.2.0) - thor (0.15.2) + thor (0.18.1) PLATFORMS ruby DEPENDENCIES jeweler (>= 1.6.2) - rake (~> 0.8.7) + rake (>= 0.8.7) rcov rspec (~> 2.10) simplecov diff --git a/Rakefile b/Rakefile index b9c583b..34eb60b 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem| gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" gem.authors = ["Joshua Nichols", "Yusuke Murata"] - gem.version = "0.8.0" + gem.version = "0.8.1" gem.license = "MIT" # Have dependencies? Add them to Gemfile @@ -44,7 +44,7 @@ end task :default => :spec -require 'rake/rdoctask' +require 'rdoc/task' Rake::RDocTask.new do |rdoc| version = File.exist?('VERSION') ? File.read('VERSION') : "" diff --git a/homesick.gemspec b/homesick.gemspec index a4bae03..50872f7 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -48,7 +48,7 @@ Gem::Specification.new do |s| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0.14.0"]) - s.add_development_dependency(%q, ["~> 0.8.7"]) + s.add_development_dependency(%q, [">= 0.8.7"]) s.add_development_dependency(%q, ["~> 2.10"]) s.add_development_dependency(%q, [">= 1.6.2"]) s.add_development_dependency(%q, [">= 0"]) @@ -56,7 +56,7 @@ Gem::Specification.new do |s| s.add_development_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0.14.0"]) - s.add_dependency(%q, ["~> 0.8.7"]) + s.add_dependency(%q, [">= 0.8.7"]) s.add_dependency(%q, ["~> 2.10"]) s.add_dependency(%q, [">= 1.6.2"]) s.add_dependency(%q, [">= 0"]) @@ -65,7 +65,7 @@ Gem::Specification.new do |s| end else s.add_dependency(%q, [">= 0.14.0"]) - s.add_dependency(%q, ["~> 0.8.7"]) + s.add_dependency(%q, [">= 0.8.7"]) s.add_dependency(%q, ["~> 2.10"]) s.add_dependency(%q, [">= 1.6.2"]) s.add_dependency(%q, [">= 0"]) From 9b7fe331f6da4c54b9138ae91361483db86dd4e9 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Sun, 19 May 2013 13:42:32 +0000 Subject: [PATCH 18/97] update changelog --- ChangeLog.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 475cf1a..e2552f2 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,6 @@ +# 0.8.1 + *Fixed `homesick list` bug on ruby 2.0 #37 + # 0.8.0 * Introduce commit & push command * commit changes in castle and push to remote From 4ef315d4e249e734ee922b198e5b1b0dbca0768d Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Sun, 19 May 2013 13:42:49 +0000 Subject: [PATCH 19/97] Regenerate gemspec for version 0.8.1 --- homesick.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homesick.gemspec b/homesick.gemspec index 50872f7..14c77f6 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.8.0" + s.version = "0.8.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] - s.date = "2013-04-05" + s.date = "2013-05-19" s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n " s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] s.executables = ["homesick"] @@ -40,7 +40,7 @@ Gem::Specification.new do |s| s.homepage = "http://github.com/technicalpickles/homesick" s.licenses = ["MIT"] s.require_paths = ["lib"] - s.rubygems_version = "1.8.24" + s.rubygems_version = "1.8.25" s.summary = "A man's home is his castle. Never leave your dotfiles behind." if s.respond_to? :specification_version then From ccddbb13168c6d9873cf48332aed256528f74775 Mon Sep 17 00:00:00 2001 From: Eric West Date: Mon, 20 May 2013 19:11:48 -0500 Subject: [PATCH 20/97] Track now properly traverses folder structure --- .gitignore | 4 ++++ lib/homesick.rb | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 88cf2e9..e605e1e 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,7 @@ pkg # # For vim: *.swp +# +# For IDEA: +.idea/ +*.iml diff --git a/lib/homesick.rb b/lib/homesick.rb index d37d451..340ac87 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -113,16 +113,22 @@ class Homesick < Thor desc "track FILE CASTLE", "add a file to a castle" def track(file, castle) castle = Pathname.new(castle) - file = Pathname.new(file) + file = Pathname.new(file.chomp('/')) check_castle_existance(castle, 'track') absolute_path = file.expand_path - castle_path = castle_dir(castle) + relative_dir = absolute_path.relative_path_from(home_dir).dirname + castle_path = Pathname.new(castle_dir(castle)).join(relative_dir) + + unless castle_path.exist? + FileUtils.mkdir_p castle_path + end + mv absolute_path, castle_path inside home_dir do - absolute_path = castle_dir(castle) + file.basename - home_path = home_dir + file + absolute_path = castle_path + file.basename + home_path = home_dir + relative_dir + file.basename ln_s absolute_path, home_path end From 234532ebefbe9182eb57f6dd954eb3070fd6ebdc Mon Sep 17 00:00:00 2001 From: Eric West Date: Mon, 20 May 2013 21:06:31 -0500 Subject: [PATCH 21/97] Specs for track --- spec/homesick_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index b3c5341..51d4235 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -170,6 +170,28 @@ describe "homesick" do some_rc_file.readlink.should == tracked_file end + + it 'should track a file in nested folder structure' do + castle = given_castle('castle_repo') + + some_nested_file = home.file('some/nested/file.txt') + homesick.track(some_nested_file.to_s, 'castle_repo') + + tracked_file = castle.join('some/nested/file.txt') + tracked_file.should exist + some_nested_file.readlink.should == tracked_file + end + + it 'should track a nested directory' do + castle = given_castle('castle_repo') + + some_nested_dir = home.directory('some/nested/directory/') + homesick.track(some_nested_dir.to_s, 'castle_repo') + + tracked_file = castle.join('some/nested/directory/') + tracked_file.should exist + File.realdirpath(some_nested_dir).should == File.realdirpath(tracked_file) + end end describe "destroy" do From cf9058be048a907e6cd476f33811c88102d22e39 Mon Sep 17 00:00:00 2001 From: Eric West Date: Fri, 24 May 2013 07:52:54 -0500 Subject: [PATCH 22/97] Track makes entries in .manifest When a user tracks a file or directory that is in a nested folder, Homesick creates a .manifest in the user's castle (if there isn't one already) and adds an entry listing the file or directory's parent directory (if it isn't already listed). --- lib/homesick.rb | 9 +++++++++ spec/homesick_spec.rb | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lib/homesick.rb b/lib/homesick.rb index 340ac87..d043feb 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -135,6 +135,15 @@ class Homesick < Thor inside castle_path do git_add absolute_path end + + # are we tracking something nested? Add the parent dir to the manifest unless its already listed + unless relative_dir.eql?(Pathname.new('.')) + manifest_path = Pathname.new(repos_dir.join(castle, '.manifest')) + File.open(manifest_path, 'a+') do |manifest| + manifest.puts relative_dir unless manifest.readlines.inject(false) { |memo, line| line.eql?("#{relative_dir.to_s}\n") || memo } + end + end + end desc "list", "List cloned castles" diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 51d4235..99dc6cc 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -192,6 +192,35 @@ describe "homesick" do tracked_file.should exist File.realdirpath(some_nested_dir).should == File.realdirpath(tracked_file) end + + describe "manifest" do + + it 'should add the nested files parent to the manifest' do + castle = given_castle('castle_repo') + + some_nested_file = home.file('some/nested/file.txt') + homesick.track(some_nested_file.to_s, 'castle_repo') + + manifest = Pathname.new(castle.parent.join('.manifest')) + File.open(manifest, 'r') do |f| + f.readline.should == "some/nested\n" + end + end + + it 'should NOT add anything if the files parent is already listed' do + castle = given_castle('castle_repo') + + some_nested_file = home.file('some/nested/file.txt') + other_nested_file = home.file('some/nested/other.txt') + homesick.track(some_nested_file.to_s, 'castle_repo') + homesick.track(other_nested_file.to_s, 'castle_repo') + + manifest = Pathname.new(castle.parent.join('.manifest')) + File.open(manifest, 'r') do |f| + f.readlines.size.should == 1 + end + end + end end describe "destroy" do From 7620f40cb239bf87bf1b7a5b31454b22b269adb8 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Fri, 24 May 2013 17:40:35 +0000 Subject: [PATCH 23/97] symlink subdirs with .homesick_subdir --- lib/homesick.rb | 29 ++++++++++++++++++++++++++++- spec/homesick_spec.rb | 15 +++++++++++++++ spec/spec_helper.rb | 11 +++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index d043feb..c0ebe64 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -11,6 +11,7 @@ class Homesick < Thor add_runtime_options! GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/ + SUBDIR_FILENAME = ".homesick_subdir" def initialize(args=[], options={}, config={}) super @@ -97,7 +98,17 @@ class Homesick < Thor check_castle_existance(name, "symlink") inside castle_dir(name) do - files = Pathname.glob('{.*,*}').reject{|a| [".",".."].include?(a.to_s)} + # prepare subdir information + subdir_file = Pathname.new(".").join(SUBDIR_FILENAME) + subdirs = [] + if subdir_file.exist? then + subdir_file.readlines.each do |subdir| + subdirs.push(subdir.chomp) + end + end + + # link files + files = Pathname.glob('{.*,*}').reject{|a| [".", "..", SUBDIR_FILENAME, subdirs].flatten.include?(a.to_s)} files.each do |path| absolute_path = path.expand_path @@ -107,6 +118,22 @@ class Homesick < Thor ln_s absolute_path, adjusted_path end end + + # link files in subdirs + subdirs.each do |subdir| + inside subdir do + files = Pathname.glob('{.*,*}').reject{|a| [".", ".."].include?(a.to_s)} + files.each do |path| + absolute_path = path.expand_path + + inside home_dir.join(subdir) do + adjusted_path = (home_dir + path).basename + + ln_s absolute_path, adjusted_path + end + end + end + end end end diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 99dc6cc..3e68559 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -121,6 +121,21 @@ describe "homesick" do existing_dotdir_link.readlink.should == dotdir end end + + context "when .homesick_subdir exists" do + let(:castle) { given_castle("glencairn", "glencairn", [".config"]) } + + it "can symlink in sub directory" do + dotdir = castle.directory(".config") + dotfile = dotdir.file(".some_dotfile") + + homesick.symlink("glencairn") + + home_dotdir = home.join(".config") + home_dotdir.symlink?.should == false + home_dotdir.join(".some_dotfile").readlink.should == dotfile + end + end end describe "list" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 498bbab..26225f4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,12 +16,19 @@ RSpec.configure do |config| homesick.stub(:say_status) end - def given_castle(name, path=name) + def given_castle(name, path=name, subdirs=[]) castles.directory(path) do |castle| Dir.chdir(castle) do system "git init >/dev/null 2>&1" system "git remote add origin git://github.com/technicalpickles/#{name}.git >/dev/null 2>&1" - return castle.directory("home") + castle_home = castle.directory("home") + if subdirs then + subdir_file = castle_home.join(Homesick::SUBDIR_FILENAME) + subdirs.each do |subdir| + system "echo #{subdir} >> #{subdir_file}" + end + end + return castle_home end end end From b1c6c8f8358f3b159f05b0b7da659d95bf395b21 Mon Sep 17 00:00:00 2001 From: Eric West Date: Fri, 24 May 2013 16:24:42 -0500 Subject: [PATCH 24/97] Handling edge cases Covers only edge cases related to tracking, not yet handling linking or updating. Getting a bit hairy, must be refactored. --- lib/homesick.rb | 33 ++++++++++++++++++++++++++++++++- spec/homesick_spec.rb | 14 ++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index c0ebe64..b90de36 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -151,7 +151,38 @@ class Homesick < Thor FileUtils.mkdir_p castle_path end - mv absolute_path, castle_path + # Are we already tracking this or anything inside it? + target = Pathname.new(castle_path.join(file.basename)) + + if target.exist? + + if absolute_path.directory? + child_files = absolute_path.children + child_files.each do |child| + + if target.join(child.basename).exist? + next + end + + mv child, target + end + absolute_path.rmtree + manifest = Pathname.new(repos_dir.join(castle, '.manifest')) + if manifest.exist? + lines = IO.readlines(manifest).delete_if { |line| line == "#{relative_dir + file.basename}\n" } + File.open(manifest, 'w') { |manfile| manfile.puts lines } + end + + elsif absolute_path.mtime > target.mtime && !absolute_path.symlink? + target.delete + mv absolute_path, castle_path + else + shell.say_status(:track, "#{target} already exists, and is more recent than #{file}. Run 'homesick SYMLINK CASTLE' to create symlinks.") + end + + else + mv absolute_path, castle_path + end inside home_dir do absolute_path = castle_path + file.basename diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 3e68559..fed4a2c 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -235,6 +235,20 @@ describe "homesick" do f.readlines.size.should == 1 end end + + it 'should remove the parent of a tracked file from the manifest if the parent itself is tracked' do + castle = given_castle('castle_repo') + + some_nested_file = home.file('some/nested/file.txt') + nested_parent = home.directory('some/nested/') + homesick.track(some_nested_file.to_s, 'castle_repo') + homesick.track(nested_parent.to_s, 'castle_repo') + + manifest = Pathname.new(castle.parent.join('.manifest')) + File.open(manifest, 'r') do |f| + f.each_line { |line| line.should_not == "some/nested\n" } + end + end end end From 7db0b13d3035e0945382ce4e766aaed227ad1643 Mon Sep 17 00:00:00 2001 From: Eric West Date: Fri, 24 May 2013 21:57:12 -0500 Subject: [PATCH 25/97] refactor, cleanup and tweak --- lib/homesick.rb | 81 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index b90de36..6b28ef5 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -153,33 +153,18 @@ class Homesick < Thor # Are we already tracking this or anything inside it? target = Pathname.new(castle_path.join(file.basename)) - if target.exist? - if absolute_path.directory? - child_files = absolute_path.children - child_files.each do |child| - - if target.join(child.basename).exist? - next - end - - mv child, target - end + move_dir_contents(target, absolute_path) absolute_path.rmtree - manifest = Pathname.new(repos_dir.join(castle, '.manifest')) - if manifest.exist? - lines = IO.readlines(manifest).delete_if { |line| line == "#{relative_dir + file.basename}\n" } - File.open(manifest, 'w') { |manfile| manfile.puts lines } - end + manifest_remove(castle, relative_dir + file.basename) - elsif absolute_path.mtime > target.mtime && !absolute_path.symlink? + elsif more_recent? absolute_path, target target.delete mv absolute_path, castle_path else - shell.say_status(:track, "#{target} already exists, and is more recent than #{file}. Run 'homesick SYMLINK CASTLE' to create symlinks.") + shell.say_status(:track, "#{target} already exists, and is more recent than #{file}. Run 'homesick SYMLINK CASTLE' to create symlinks.", :blue) unless options[:quiet] end - else mv absolute_path, castle_path end @@ -194,14 +179,10 @@ class Homesick < Thor git_add absolute_path end - # are we tracking something nested? Add the parent dir to the manifest unless its already listed + # are we tracking something nested? Add the parent dir to the manifest unless relative_dir.eql?(Pathname.new('.')) - manifest_path = Pathname.new(repos_dir.join(castle, '.manifest')) - File.open(manifest_path, 'a+') do |manifest| - manifest.puts relative_dir unless manifest.readlines.inject(false) { |memo, line| line.eql?("#{relative_dir.to_s}\n") || memo } - end + manifest_add(castle, relative_dir) end - end desc "list", "List cloned castles" @@ -310,4 +291,54 @@ class Homesick < Thor git_push end end + + def manifest(castle) + Pathname.new(repos_dir.join(castle, '.manifest')) + end + + def manifest_add(castle, path) + manifest_path = manifest(castle) + File.open(manifest_path, 'a+') do |manifest| + manifest.puts path unless manifest.readlines.inject(false) { |memo, line| line.eql?("#{path.to_s}\n") || memo } + end + + inside castle_dir(castle) do + git_add manifest_path + end + end + + def manifest_remove(castle, path) + manifest_file = manifest(castle) + if manifest_file.exist? + lines = IO.readlines(manifest_file).delete_if { |line| line == "#{path}\n" } + File.open(manifest_file, 'w') { |manfile| manfile.puts lines } + end + + inside castle_dir(castle) do + git_add manifest_file + end + end + + def move_dir_contents(target, dir_path) + child_files = dir_path.children + child_files.each do |child| + + target_path = target.join(child.basename) + if target_path.exist? + if more_recent?(child, target_path) && target.file? + target_path.delete + mv child, target + end + next + end + + mv child, target + end + end + + def more_recent?(first, second) + first_p = Pathname.new(first) + second_p = Pathname.new(second) + first_p.mtime > second_p.mtime && !first_p.symlink? + end end From bba0e3ed7dd1694120c73e13a5e20c9888c4dbed Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Sun, 26 May 2013 17:12:28 +0000 Subject: [PATCH 26/97] support nested dir in .homesick_subdir --- lib/homesick.rb | 13 +++++++++++-- spec/homesick_spec.rb | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 6b28ef5..242bec3 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -106,9 +106,18 @@ class Homesick < Thor subdirs.push(subdir.chomp) end end + ignore_dirs = [] + subdirs.each do |subdir| + splited_subdir = Pathname.new(subdir).split + ignore_dir = splited_subdir[0].to_s + if ignore_dir == "." then + ignore_dir = splited_subdir[1].to_s + end + ignore_dirs.push(ignore_dir) + end # link files - files = Pathname.glob('{.*,*}').reject{|a| [".", "..", SUBDIR_FILENAME, subdirs].flatten.include?(a.to_s)} + files = Pathname.glob('{.*,*}').reject{|a| [".", "..", SUBDIR_FILENAME, ignore_dirs].flatten.include?(a.to_s)} files.each do |path| absolute_path = path.expand_path @@ -127,7 +136,7 @@ class Homesick < Thor absolute_path = path.expand_path inside home_dir.join(subdir) do - adjusted_path = (home_dir + path).basename + adjusted_path = (home_dir + subdir + path).basename ln_s absolute_path, adjusted_path end diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index fed4a2c..6596df1 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -122,9 +122,8 @@ describe "homesick" do end end - context "when .homesick_subdir exists" do + context "with '.config' in .homesick_subdir" do let(:castle) { given_castle("glencairn", "glencairn", [".config"]) } - it "can symlink in sub directory" do dotdir = castle.directory(".config") dotfile = dotdir.file(".some_dotfile") @@ -136,6 +135,20 @@ describe "homesick" do home_dotdir.join(".some_dotfile").readlink.should == dotfile end end + + context "with '.config/appA' in .homesick_subdir" do + let(:castle) { given_castle("glencairn", "glencairn", [".config/appA"]) } + it "can symlink in nested sub directory" do + dotdir = castle.directory(".config").directory("appA") + dotfile = dotdir.file(".some_dotfile") + + homesick.symlink("glencairn") + + home_dotdir = home.join(".config").join("appA") + home_dotdir.symlink?.should == false + home_dotdir.join(".some_dotfile").readlink.should == dotfile + end + end end describe "list" do From 01934d5b00c6fb2f6e92579c1d17bfb4a36315f3 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Mon, 27 May 2013 18:08:09 +0000 Subject: [PATCH 27/97] replace .manifest to .homesick_subdir --- lib/homesick.rb | 41 +++++++++++++++++++---------------------- spec/homesick_spec.rb | 18 +++++++++--------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 242bec3..424da1f 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -99,10 +99,10 @@ class Homesick < Thor inside castle_dir(name) do # prepare subdir information - subdir_file = Pathname.new(".").join(SUBDIR_FILENAME) + subdir_filepath = subdir_file(name) subdirs = [] - if subdir_file.exist? then - subdir_file.readlines.each do |subdir| + if subdir_filepath.exist? then + subdir_filepath.readlines.each do |subdir| subdirs.push(subdir.chomp) end end @@ -155,10 +155,7 @@ class Homesick < Thor absolute_path = file.expand_path relative_dir = absolute_path.relative_path_from(home_dir).dirname castle_path = Pathname.new(castle_dir(castle)).join(relative_dir) - - unless castle_path.exist? - FileUtils.mkdir_p castle_path - end + FileUtils.mkdir_p castle_path # Are we already tracking this or anything inside it? target = Pathname.new(castle_path.join(file.basename)) @@ -166,7 +163,7 @@ class Homesick < Thor if absolute_path.directory? move_dir_contents(target, absolute_path) absolute_path.rmtree - manifest_remove(castle, relative_dir + file.basename) + subdir_remove(castle, relative_dir + file.basename) elsif more_recent? absolute_path, target target.delete @@ -190,7 +187,7 @@ class Homesick < Thor # are we tracking something nested? Add the parent dir to the manifest unless relative_dir.eql?(Pathname.new('.')) - manifest_add(castle, relative_dir) + subdir_add(castle, relative_dir) end end @@ -301,30 +298,30 @@ class Homesick < Thor end end - def manifest(castle) - Pathname.new(repos_dir.join(castle, '.manifest')) + def subdir_file(castle) + castle_dir(castle).join(SUBDIR_FILENAME) end - def manifest_add(castle, path) - manifest_path = manifest(castle) - File.open(manifest_path, 'a+') do |manifest| - manifest.puts path unless manifest.readlines.inject(false) { |memo, line| line.eql?("#{path.to_s}\n") || memo } + def subdir_add(castle, path) + subdir_filepath = subdir_file(castle) + File.open(subdir_filepath, 'a+') do |subdir| + subdir.puts path unless subdir.readlines.inject(false) { |memo, line| line.eql?("#{path.to_s}\n") || memo } end inside castle_dir(castle) do - git_add manifest_path + git_add subdir_filepath end end - def manifest_remove(castle, path) - manifest_file = manifest(castle) - if manifest_file.exist? - lines = IO.readlines(manifest_file).delete_if { |line| line == "#{path}\n" } - File.open(manifest_file, 'w') { |manfile| manfile.puts lines } + def subdir_remove(castle, path) + subdir_filepath = subdir_file(castle) + if subdir_filepath.exist? + lines = IO.readlines(subdir_filepath).delete_if { |line| line == "#{path}\n" } + File.open(subdir_filepath, 'w') { |manfile| manfile.puts lines } end inside castle_dir(castle) do - git_add manifest_file + git_add subdir_filepath end end diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 6596df1..95f6fec 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -221,16 +221,16 @@ describe "homesick" do File.realdirpath(some_nested_dir).should == File.realdirpath(tracked_file) end - describe "manifest" do + describe "subdir_file" do - it 'should add the nested files parent to the manifest' do + it 'should add the nested files parent to the subdir_file' do castle = given_castle('castle_repo') some_nested_file = home.file('some/nested/file.txt') homesick.track(some_nested_file.to_s, 'castle_repo') - manifest = Pathname.new(castle.parent.join('.manifest')) - File.open(manifest, 'r') do |f| + subdir_file = castle.join(Homesick::SUBDIR_FILENAME) + File.open(subdir_file, 'r') do |f| f.readline.should == "some/nested\n" end end @@ -243,13 +243,13 @@ describe "homesick" do homesick.track(some_nested_file.to_s, 'castle_repo') homesick.track(other_nested_file.to_s, 'castle_repo') - manifest = Pathname.new(castle.parent.join('.manifest')) - File.open(manifest, 'r') do |f| + subdir_file = castle.join(Homesick::SUBDIR_FILENAME) + File.open(subdir_file, 'r') do |f| f.readlines.size.should == 1 end end - it 'should remove the parent of a tracked file from the manifest if the parent itself is tracked' do + it 'should remove the parent of a tracked file from the subdir_file if the parent itself is tracked' do castle = given_castle('castle_repo') some_nested_file = home.file('some/nested/file.txt') @@ -257,8 +257,8 @@ describe "homesick" do homesick.track(some_nested_file.to_s, 'castle_repo') homesick.track(nested_parent.to_s, 'castle_repo') - manifest = Pathname.new(castle.parent.join('.manifest')) - File.open(manifest, 'r') do |f| + subdir_file = castle.join(Homesick::SUBDIR_FILENAME) + File.open(subdir_file, 'r') do |f| f.each_line { |line| line.should_not == "some/nested\n" } end end From fd605285671aa0f6d2939bcce1d44a2ce9453b7f Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 30 May 2013 14:33:08 +0000 Subject: [PATCH 28/97] fix spec for ruby-1.8.7 --- spec/homesick_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 95f6fec..4d26014 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -218,7 +218,7 @@ describe "homesick" do tracked_file = castle.join('some/nested/directory/') tracked_file.should exist - File.realdirpath(some_nested_dir).should == File.realdirpath(tracked_file) + some_nested_dir.realpath.should == tracked_file.realpath end describe "subdir_file" do From ed71fd6227d5ad0f1f7c3c285876cced0396bb1d Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 30 May 2013 14:33:45 +0000 Subject: [PATCH 29/97] add ruby-2.0.0 to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e14e9bc..285725e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: ruby rvm: + - 2.0.0 - 1.9.3 - 1.8.7 From aa2dfcc42f8ff30d32c2c919772086bc2a711dda Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 30 May 2013 17:38:06 +0000 Subject: [PATCH 30/97] refactor given_castle --- spec/homesick_spec.rb | 6 +++--- spec/spec_helper.rb | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 4d26014..1be2f2d 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -123,7 +123,7 @@ describe "homesick" do end context "with '.config' in .homesick_subdir" do - let(:castle) { given_castle("glencairn", "glencairn", [".config"]) } + let(:castle) { given_castle("glencairn", [".config"]) } it "can symlink in sub directory" do dotdir = castle.directory(".config") dotfile = dotdir.file(".some_dotfile") @@ -137,7 +137,7 @@ describe "homesick" do end context "with '.config/appA' in .homesick_subdir" do - let(:castle) { given_castle("glencairn", "glencairn", [".config/appA"]) } + let(:castle) { given_castle("glencairn", [".config/appA"]) } it "can symlink in nested sub directory" do dotdir = castle.directory(".config").directory("appA") dotfile = dotdir.file(".some_dotfile") @@ -154,7 +154,7 @@ describe "homesick" do describe "list" do it "should say each castle in the castle directory" do given_castle('zomg') - given_castle('zomg', 'wtf/zomg') + given_castle('wtf/zomg') homesick.should_receive(:say_status).with("zomg", "git://github.com/technicalpickles/zomg.git", :cyan) homesick.should_receive(:say_status).with("wtf/zomg", "git://github.com/technicalpickles/zomg.git", :cyan) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 26225f4..9dfb5cb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,7 +16,8 @@ RSpec.configure do |config| homesick.stub(:say_status) end - def given_castle(name, path=name, subdirs=[]) + def given_castle(path, subdirs=[]) + name = Pathname.new(path).basename castles.directory(path) do |castle| Dir.chdir(castle) do system "git init >/dev/null 2>&1" From 830106a168e2a67e02f4c5700be9d673ca71e086 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Mon, 3 Jun 2013 18:17:38 +0000 Subject: [PATCH 31/97] refactor symlink --- lib/homesick.rb | 92 ++++++++++++++++++++++++----------------- lib/homesick/actions.rb | 1 + 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 424da1f..53507d7 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -98,50 +98,14 @@ class Homesick < Thor check_castle_existance(name, "symlink") inside castle_dir(name) do - # prepare subdir information - subdir_filepath = subdir_file(name) - subdirs = [] - if subdir_filepath.exist? then - subdir_filepath.readlines.each do |subdir| - subdirs.push(subdir.chomp) - end - end - ignore_dirs = [] - subdirs.each do |subdir| - splited_subdir = Pathname.new(subdir).split - ignore_dir = splited_subdir[0].to_s - if ignore_dir == "." then - ignore_dir = splited_subdir[1].to_s - end - ignore_dirs.push(ignore_dir) - end + subdirs = subdirs(name) # link files - files = Pathname.glob('{.*,*}').reject{|a| [".", "..", SUBDIR_FILENAME, ignore_dirs].flatten.include?(a.to_s)} - files.each do |path| - absolute_path = path.expand_path - - inside home_dir do - adjusted_path = (home_dir + path).basename - - ln_s absolute_path, adjusted_path - end - end + symlink_each(name, castle_dir(name), subdirs) # link files in subdirs subdirs.each do |subdir| - inside subdir do - files = Pathname.glob('{.*,*}').reject{|a| [".", ".."].include?(a.to_s)} - files.each do |path| - absolute_path = path.expand_path - - inside home_dir.join(subdir) do - adjusted_path = (home_dir + subdir + path).basename - - ln_s absolute_path, adjusted_path - end - end - end + symlink_each(name, subdir, subdirs) end end end @@ -302,6 +266,17 @@ class Homesick < Thor castle_dir(castle).join(SUBDIR_FILENAME) end + def subdirs(castle) + subdir_filepath = subdir_file(castle) + subdirs = [] + if subdir_filepath.exist? + subdir_filepath.readlines.each do |subdir| + subdirs.push(subdir.chomp) + end + end + subdirs + end + def subdir_add(castle, path) subdir_filepath = subdir_file(castle) File.open(subdir_filepath, 'a+') do |subdir| @@ -347,4 +322,43 @@ class Homesick < Thor second_p = Pathname.new(second) first_p.mtime > second_p.mtime && !first_p.symlink? end + + def symlink_each(castle, basedir, subdirs) + basedir = Pathname.new(basedir).expand_path + inside basedir do + files = Pathname.glob('{.*,*}').reject{|a| [".", ".."].include?(a.to_s)} + files.each do |path| + absolute_path = path.expand_path + castle_home = castle_dir(castle) + + # ignore subdir file + next if absolute_path == castle_home.join(SUBDIR_FILENAME) + + # make ignore dirs + ignore_dirs = [] + subdirs.each do |subdir| + splited_subdir = Pathname.new(subdir).split + ignore_dir = splited_subdir[0].to_s + if ignore_dir == "." then + ignore_dir = splited_subdir[1].to_s + end + ignore_dirs.push(ignore_dir) + end + + # ignore dirs written in subdir file + matched = false + ignore_dirs.each do |ignore_dir| + if absolute_path == castle_home.join(ignore_dir) + matched = true + next + end + end + next if matched + + relative_dir = basedir.relative_path_from(castle_home) + home_path = home_dir.join(relative_dir).join(path) + ln_s absolute_path, home_path + end + end + end end diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 060d266..6a01e01 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -104,6 +104,7 @@ class Homesick def ln_s(source, destination, config = {}) source = Pathname.new(source) destination = Pathname.new(destination) + FileUtils.mkdir_p destination.dirname if destination.symlink? if destination.readlink == source From 06975f79f5f28a26e6fecca33ece0313eb8e3891 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Tue, 4 Jun 2013 17:36:47 +0000 Subject: [PATCH 32/97] deal with edge case: the parent and descendant are both listed in the manifest --- lib/homesick.rb | 16 +++++++--------- spec/homesick_spec.rb | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 53507d7..be14b4d 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -324,7 +324,7 @@ class Homesick < Thor end def symlink_each(castle, basedir, subdirs) - basedir = Pathname.new(basedir).expand_path + absolute_basedir = Pathname.new(basedir).expand_path inside basedir do files = Pathname.glob('{.*,*}').reject{|a| [".", ".."].include?(a.to_s)} files.each do |path| @@ -337,25 +337,23 @@ class Homesick < Thor # make ignore dirs ignore_dirs = [] subdirs.each do |subdir| - splited_subdir = Pathname.new(subdir).split - ignore_dir = splited_subdir[0].to_s - if ignore_dir == "." then - ignore_dir = splited_subdir[1].to_s + # ignore all parent of each line in subdir file + Pathname.new(subdir).ascend do |p| + ignore_dirs.push(p) end - ignore_dirs.push(ignore_dir) end # ignore dirs written in subdir file matched = false - ignore_dirs.each do |ignore_dir| + ignore_dirs.uniq.each do |ignore_dir| if absolute_path == castle_home.join(ignore_dir) matched = true - next + break end end next if matched - relative_dir = basedir.relative_path_from(castle_home) + relative_dir = absolute_basedir.relative_path_from(castle_home) home_path = home_dir.join(relative_dir).join(path) ln_s absolute_path, home_path end diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 1be2f2d..b46db86 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -149,6 +149,25 @@ describe "homesick" do home_dotdir.join(".some_dotfile").readlink.should == dotfile end end + + context "with '.config' and '.config/appA' in .homesick_subdir" do + let(:castle) { given_castle("glencairn", [".config", ".config/appA"]) } + it "can symlink under both of .config and .config/appA" do + config_dir = castle.directory(".config") + config_dotfile = config_dir.file(".some_dotfile") + appA_dir = config_dir.directory("appA") + appA_dotfile = appA_dir.file(".some_appfile") + + homesick.symlink("glencairn") + + home_config_dir = home.join(".config") + home_appA_dir = home_config_dir.join("appA") + home_config_dir.symlink?.should == false + home_config_dir.join(".some_dotfile").readlink.should == config_dotfile + home_appA_dir.symlink?.should == false + home_appA_dir.join(".some_appfile").readlink.should == appA_dotfile + end + end end describe "list" do From c3c108bd500c79797aec2160c67f4e8256e06621 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Tue, 4 Jun 2013 18:14:20 +0000 Subject: [PATCH 33/97] add .homesick_subdir explanation to README --- README.markdown | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/README.markdown b/README.markdown index a0d239d..87fd3b4 100644 --- a/README.markdown +++ b/README.markdown @@ -51,6 +51,84 @@ Not sure what else homesick has up its sleeve? There's always the built in help: homesick help +## .homesick_subdir + +`homesick symlink` basically makes symlink to only first depth in `castle/home`. If you want to link nested files/directories, please use .homesick_subdir. + +For example, when you have castle like this: + + castle/home + `-- .config + `-- fooapp + |-- config1 + |-- config2 + `-- config3 + +and have home like this: + + $ tree -a + ~ + |-- .config + | `-- barapp + | |-- config1 + | |-- config2 + | `-- config3 + `-- .emacs.d + |-- elisp + `-- inits + +You may want to symlink only to `castle/home/.config/fooapp` instead of `castle/home/.config` because you already have `~/.config/barapp`. In this case, you can use .homesick_subdir. Please write "directories you want to look up sub direcoties (instead of just first depth)" in this file. + +castle/home/.homesick_subdir + + .config + +and run `homesick symlink CASTLE`. The result is: + + ~ + |-- .config + | |-- barapp + | | |-- config1 + | | |-- config2 + | | `-- config3 + | `-- fooapp -> castle/home/.config/fooapp + `-- .emacs.d + |-- elisp + `-- inits + +Or `homesick track NESTED_FILE CASTLE` adds a line automatically. For example: + + homesick track .emacs/elisp castle + +castle/home/.homesick_subdir + + .config + .emacs.d + +home directory + + ~ + |-- .config + | |-- barapp + | | |-- config1 + | | |-- config2 + | | `-- config3 + | `-- fooapp -> castle/home/.config/fooapp + `-- .emacs.d + |-- elisp -> castle/home/.emacs/elisp + `-- inits + +and castle + + castle/home + |-- .config + | `-- fooapp + | |-- config1 + | |-- config2 + | `-- config3 + `-- .emacs.d + `-- elisp + ## Note on Patches/Pull Requests * Fork the project. From eb74b90b425ec25fc77ba08093e083ab64be7010 Mon Sep 17 00:00:00 2001 From: Yusuke Murata Date: Wed, 5 Jun 2013 03:15:44 +0900 Subject: [PATCH 34/97] fix style of README --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 87fd3b4..ac4d3df 100644 --- a/README.markdown +++ b/README.markdown @@ -115,7 +115,7 @@ home directory | | `-- config3 | `-- fooapp -> castle/home/.config/fooapp `-- .emacs.d - |-- elisp -> castle/home/.emacs/elisp + |-- elisp -> castle/home/.emacs/elisp `-- inits and castle From f91f5743b6645568466d0836054039fd684e3f48 Mon Sep 17 00:00:00 2001 From: Yusuke Murata Date: Wed, 5 Jun 2013 03:18:40 +0900 Subject: [PATCH 35/97] fix style of README --- README.markdown | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/README.markdown b/README.markdown index ac4d3df..1a9460a 100644 --- a/README.markdown +++ b/README.markdown @@ -62,20 +62,20 @@ For example, when you have castle like this: `-- fooapp |-- config1 |-- config2 - `-- config3 + `-- config3 and have home like this: $ tree -a - ~ - |-- .config - | `-- barapp - | |-- config1 - | |-- config2 - | `-- config3 - `-- .emacs.d - |-- elisp - `-- inits + ~ + |-- .config + | `-- barapp + | |-- config1 + | |-- config2 + | `-- config3 + `-- .emacs.d + |-- elisp + `-- inits You may want to symlink only to `castle/home/.config/fooapp` instead of `castle/home/.config` because you already have `~/.config/barapp`. In this case, you can use .homesick_subdir. Please write "directories you want to look up sub direcoties (instead of just first depth)" in this file. @@ -85,16 +85,16 @@ castle/home/.homesick_subdir and run `homesick symlink CASTLE`. The result is: - ~ - |-- .config - | |-- barapp - | | |-- config1 - | | |-- config2 - | | `-- config3 - | `-- fooapp -> castle/home/.config/fooapp - `-- .emacs.d - |-- elisp - `-- inits + ~ + |-- .config + | |-- barapp + | | |-- config1 + | | |-- config2 + | | `-- config3 + | `-- fooapp -> castle/home/.config/fooapp + `-- .emacs.d + |-- elisp + `-- inits Or `homesick track NESTED_FILE CASTLE` adds a line automatically. For example: @@ -107,16 +107,16 @@ castle/home/.homesick_subdir home directory - ~ - |-- .config - | |-- barapp - | | |-- config1 - | | |-- config2 - | | `-- config3 - | `-- fooapp -> castle/home/.config/fooapp - `-- .emacs.d - |-- elisp -> castle/home/.emacs/elisp - `-- inits + ~ + |-- .config + | |-- barapp + | | |-- config1 + | | |-- config2 + | | `-- config3 + | `-- fooapp -> castle/home/.config/fooapp + `-- .emacs.d + |-- elisp -> castle/home/.emacs/elisp + `-- inits and castle @@ -126,8 +126,8 @@ and castle | |-- config1 | |-- config2 | `-- config3 - `-- .emacs.d - `-- elisp + `-- .emacs.d + `-- elisp ## Note on Patches/Pull Requests From a0862936e89d0f986fdecbbc42018deb025b9ea8 Mon Sep 17 00:00:00 2001 From: Yusuke Murata Date: Thu, 6 Jun 2013 21:19:21 +0900 Subject: [PATCH 36/97] fix typo --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 1a9460a..2ba35c8 100644 --- a/README.markdown +++ b/README.markdown @@ -98,7 +98,7 @@ and run `homesick symlink CASTLE`. The result is: Or `homesick track NESTED_FILE CASTLE` adds a line automatically. For example: - homesick track .emacs/elisp castle + homesick track .emacs.d/elisp castle castle/home/.homesick_subdir @@ -115,7 +115,7 @@ home directory | | `-- config3 | `-- fooapp -> castle/home/.config/fooapp `-- .emacs.d - |-- elisp -> castle/home/.emacs/elisp + |-- elisp -> castle/home/.emacs.d/elisp `-- inits and castle From cc1ee544c360adae98229632b9bf01f9121c8f9f Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 6 Jun 2013 12:39:41 +0000 Subject: [PATCH 37/97] move castle/home/.homesick_subdir to castle/.homesick_subdir --- lib/homesick.rb | 5 +---- spec/homesick_spec.rb | 6 +++--- spec/spec_helper.rb | 5 ++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index be14b4d..a8a294e 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -263,7 +263,7 @@ class Homesick < Thor end def subdir_file(castle) - castle_dir(castle).join(SUBDIR_FILENAME) + repos_dir.join(castle, SUBDIR_FILENAME) end def subdirs(castle) @@ -331,9 +331,6 @@ class Homesick < Thor absolute_path = path.expand_path castle_home = castle_dir(castle) - # ignore subdir file - next if absolute_path == castle_home.join(SUBDIR_FILENAME) - # make ignore dirs ignore_dirs = [] subdirs.each do |subdir| diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index b46db86..8e4f5a5 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -248,7 +248,7 @@ describe "homesick" do some_nested_file = home.file('some/nested/file.txt') homesick.track(some_nested_file.to_s, 'castle_repo') - subdir_file = castle.join(Homesick::SUBDIR_FILENAME) + subdir_file = castle.parent.join(Homesick::SUBDIR_FILENAME) File.open(subdir_file, 'r') do |f| f.readline.should == "some/nested\n" end @@ -262,7 +262,7 @@ describe "homesick" do homesick.track(some_nested_file.to_s, 'castle_repo') homesick.track(other_nested_file.to_s, 'castle_repo') - subdir_file = castle.join(Homesick::SUBDIR_FILENAME) + subdir_file = castle.parent.join(Homesick::SUBDIR_FILENAME) File.open(subdir_file, 'r') do |f| f.readlines.size.should == 1 end @@ -276,7 +276,7 @@ describe "homesick" do homesick.track(some_nested_file.to_s, 'castle_repo') homesick.track(nested_parent.to_s, 'castle_repo') - subdir_file = castle.join(Homesick::SUBDIR_FILENAME) + subdir_file = castle.parent.join(Homesick::SUBDIR_FILENAME) File.open(subdir_file, 'r') do |f| f.each_line { |line| line.should_not == "some/nested\n" } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9dfb5cb..1c78cf3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,14 +22,13 @@ RSpec.configure do |config| Dir.chdir(castle) do system "git init >/dev/null 2>&1" system "git remote add origin git://github.com/technicalpickles/#{name}.git >/dev/null 2>&1" - castle_home = castle.directory("home") if subdirs then - subdir_file = castle_home.join(Homesick::SUBDIR_FILENAME) + subdir_file = castle.join(Homesick::SUBDIR_FILENAME) subdirs.each do |subdir| system "echo #{subdir} >> #{subdir_file}" end end - return castle_home + return castle.directory("home") end end end From a595ead2c6062aa73d7b5120c927d6f89c4c258d Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 6 Jun 2013 12:58:36 +0000 Subject: [PATCH 38/97] bump up version and update changelog --- ChangeLog.markdown | 3 +++ Rakefile | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index e2552f2..430e539 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,6 @@ +# 0.9.0 + * Introduce .homesick_subdir #39 + # 0.8.1 *Fixed `homesick list` bug on ruby 2.0 #37 diff --git a/Rakefile b/Rakefile index 34eb60b..679c646 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem| gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" gem.authors = ["Joshua Nichols", "Yusuke Murata"] - gem.version = "0.8.1" + gem.version = "0.9.0" gem.license = "MIT" # Have dependencies? Add them to Gemfile From b668b7eda2795adece95532622fff68056f27ed5 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 6 Jun 2013 12:59:00 +0000 Subject: [PATCH 39/97] Regenerate gemspec for version 0.9.0 --- homesick.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homesick.gemspec b/homesick.gemspec index 14c77f6..16eb26b 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.8.1" + s.version = "0.9.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] - s.date = "2013-05-19" + s.date = "2013-06-06" s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n " s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] s.executables = ["homesick"] From c5b7dd2918da7187c153597f4895c63f12d9c30e Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Sun, 9 Jun 2013 23:10:21 +0000 Subject: [PATCH 40/97] fix #35 --- lib/homesick/actions.rb | 1 + spec/homesick_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 6a01e01..0accf72 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -120,6 +120,7 @@ class Homesick say_status :conflict, "#{destination} exists", :red unless options[:quiet] if options[:force] || shell.file_collision(destination) { source } + system "rm -rf #{destination}" unless options[:pretend] system "ln -sf #{source} #{destination}" unless options[:pretend] end else diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 8e4f5a5..7200508 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -120,6 +120,17 @@ describe "homesick" do existing_dotdir_link.readlink.should == dotdir end + + it "can override existing directory" do + somewhere_else = create_construct + existing_dotdir = home.directory(".vim") + + dotdir = castle.directory(".vim") + + homesick.symlink("glencairn") + + existing_dotdir.readlink.should == dotdir + end end context "with '.config' in .homesick_subdir" do From 1518cb1155ada26ab2995f10d8868bc115eb1f67 Mon Sep 17 00:00:00 2001 From: Fletcher Nichol Date: Sun, 16 Jun 2013 10:47:53 -0600 Subject: [PATCH 41/97] Remove .git suffix on destination directory if URL ends with it. For example, the following: homesick clone git://github.com/technicalpickles/pickled-vim.git should produce a castle directory of: $HOME/.homesick/repos/pickled-vim --- lib/homesick/actions.rb | 5 +---- spec/homesick_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 0accf72..c170174 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -4,10 +4,7 @@ class Homesick # TODO move this to be more like thor's template, empty_directory, etc def git_clone(repo, config = {}) config ||= {} - destination = config[:destination] || begin - repo =~ /([^\/]+)(?:\.git)?$/ - $1 - end + destination = config[:destination] || File.basename(repo, '.git') destination = Pathname.new(destination) unless destination.kind_of?(Pathname) FileUtils.mkdir_p destination.dirname diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 7200508..824ceb5 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -40,6 +40,14 @@ describe "homesick" do end end + it "should clone git repo like file:///path/to.git" do + bare_repo = File.join(create_construct.to_s, "dotfiles.git") + system "git init --bare #{bare_repo} >/dev/null 2>&1" + + homesick.clone "file://#{bare_repo}" + File.directory?(File.join(home.to_s, '.homesick/repos/dotfiles')).should be_true + end + 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') From 18c0e323099596af9abedc8977fa0de82523fbba Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Mon, 17 Jun 2013 12:35:39 +0000 Subject: [PATCH 42/97] bump up version --- ChangeLog.markdown | 3 +++ Rakefile | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 430e539..edda6f7 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,6 @@ +# 0.9.1 + * Fixed small bugs: #35, #40 + # 0.9.0 * Introduce .homesick_subdir #39 diff --git a/Rakefile b/Rakefile index 679c646..702c2e6 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem| gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" gem.authors = ["Joshua Nichols", "Yusuke Murata"] - gem.version = "0.9.0" + gem.version = "0.9.1" gem.license = "MIT" # Have dependencies? Add them to Gemfile From 937f1912d7bb18026c7b4132e77fa680ca1a96d2 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Mon, 17 Jun 2013 12:36:14 +0000 Subject: [PATCH 43/97] Regenerate gemspec for version 0.9.1 --- homesick.gemspec | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/homesick.gemspec b/homesick.gemspec index 16eb26b..07823ec 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -4,15 +4,20 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = "homesick" - s.version = "0.9.0" + s.name = %q{homesick} + s.version = "0.9.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Joshua Nichols", "Yusuke Murata"] - s.date = "2013-06-06" - s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n " - s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] - s.executables = ["homesick"] + s.authors = [%q{Joshua Nichols}, %q{Yusuke Murata}] + s.date = %q{2013-06-17} + s.description = %q{ + A man's home (directory) is his castle, so don't leave home with out it. + + Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. + + } + s.email = [%q{josh@technicalpickles.com}, %q{info@muratayusuke.com}] + s.executables = [%q{homesick}] s.extra_rdoc_files = [ "ChangeLog.markdown", "LICENSE", @@ -37,11 +42,11 @@ Gem::Specification.new do |s| "spec/spec.opts", "spec/spec_helper.rb" ] - s.homepage = "http://github.com/technicalpickles/homesick" - s.licenses = ["MIT"] - s.require_paths = ["lib"] - s.rubygems_version = "1.8.25" - s.summary = "A man's home is his castle. Never leave your dotfiles behind." + s.homepage = %q{http://github.com/technicalpickles/homesick} + s.licenses = [%q{MIT}] + s.require_paths = [%q{lib}] + s.rubygems_version = %q{1.8.5} + s.summary = %q{A man's home is his castle. Never leave your dotfiles behind.} if s.respond_to? :specification_version then s.specification_version = 3 From 359147e7e89910741b18b0950c1d960596360d71 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 19 Jun 2013 15:01:36 +0000 Subject: [PATCH 44/97] use rubocop --- Gemfile | 1 + Gemfile.lock | 10 ++++++++++ Rakefile | 10 +++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 787a355..fd8d17e 100644 --- a/Gemfile +++ b/Gemfile @@ -12,4 +12,5 @@ group :development do gem "rcov", :platforms => :mri_18 gem "simplecov", :platforms => :mri_19 gem "test-construct" + gem "rubocop" end diff --git a/Gemfile.lock b/Gemfile.lock index b46cf39..6a55be8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,7 @@ GEM remote: https://rubygems.org/ specs: + ast (1.1.0) diff-lcs (1.2.4) git (1.2.5) jeweler (1.8.4) @@ -10,6 +11,10 @@ GEM rdoc json (1.8.0) multi_json (1.7.3) + parser (2.0.0.beta5) + ast (~> 1.0) + slop (~> 3.4) + rainbow (1.1.4) rake (10.0.4) rcov (1.0.0) rdoc (4.0.1) @@ -22,10 +27,14 @@ GEM rspec-expectations (2.13.0) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.13.1) + rubocop (0.8.3) + parser (= 2.0.0.beta5) + rainbow (>= 1.1.4) simplecov (0.7.1) multi_json (~> 1.0) simplecov-html (~> 0.7.1) simplecov-html (0.7.1) + slop (3.4.5) test-construct (1.2.0) thor (0.18.1) @@ -37,6 +46,7 @@ DEPENDENCIES rake (>= 0.8.7) rcov rspec (~> 2.10) + rubocop simplecov test-construct thor (>= 0.14.0) diff --git a/Rakefile b/Rakefile index 702c2e6..a98e260 100644 --- a/Rakefile +++ b/Rakefile @@ -41,8 +41,16 @@ RSpec::Core::RakeTask.new(:rcov) do |spec| spec.rcov = true end +task :rubocop do + system('rubocop') +end -task :default => :spec +task :test do + Rake::Task['spec'].execute + Rake::Task['rubocop'].execute +end + +task :default => :test require 'rdoc/task' Rake::RDocTask.new do |rdoc| From b3298d18c8e5faae995979b793ae0c93ed4f3159 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 19 Jun 2013 15:30:18 +0000 Subject: [PATCH 45/97] fix coding style --- spec/homesick_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 824ceb5..2343b9e 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -150,7 +150,7 @@ describe "homesick" do homesick.symlink("glencairn") home_dotdir = home.join(".config") - home_dotdir.symlink?.should == false + home_dotdir.symlink?.should be == false home_dotdir.join(".some_dotfile").readlink.should == dotfile end end @@ -164,7 +164,7 @@ describe "homesick" do homesick.symlink("glencairn") home_dotdir = home.join(".config").join("appA") - home_dotdir.symlink?.should == false + home_dotdir.symlink?.should be == false home_dotdir.join(".some_dotfile").readlink.should == dotfile end end @@ -181,9 +181,9 @@ describe "homesick" do home_config_dir = home.join(".config") home_appA_dir = home_config_dir.join("appA") - home_config_dir.symlink?.should == false - home_config_dir.join(".some_dotfile").readlink.should == config_dotfile - home_appA_dir.symlink?.should == false + home_config_dir.symlink?.should be == false + home_config_dir.join(".some_dotfile").readlink.should be == config_dotfile + home_appA_dir.symlink?.should be == false home_appA_dir.join(".some_appfile").readlink.should == appA_dotfile end end From d7aca1025f9859b5cc1b3a23e615b7a63a1e070e Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 19 Jun 2013 15:41:53 +0000 Subject: [PATCH 46/97] don't run rubocode on ruby 1.8.7 --- Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index a98e260..52d2dfd 100644 --- a/Rakefile +++ b/Rakefile @@ -42,7 +42,9 @@ RSpec::Core::RakeTask.new(:rcov) do |spec| end task :rubocop do - system('rubocop') + if RUBY_VERSION >= '1.9.2' + raise unless system('rubocop') + end end task :test do From 91770998a7d8f2e6107b0af7c799c571c8867ad5 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 19 Jun 2013 15:58:45 +0000 Subject: [PATCH 47/97] don't install rubocop under ruby 1.9.2 --- Gemfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index fd8d17e..88b1506 100644 --- a/Gemfile +++ b/Gemfile @@ -12,5 +12,7 @@ group :development do gem "rcov", :platforms => :mri_18 gem "simplecov", :platforms => :mri_19 gem "test-construct" - gem "rubocop" + if RUBY_VERSION >= '1.9.2' + gem "rubocop" + end end From 1563814cb08b4979dbf9567f24099301fdfa67cc Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 19 Jun 2013 16:23:00 +0000 Subject: [PATCH 48/97] use single-quate if don't need double-quate --- lib/homesick.rb | 42 +++++----- lib/homesick/actions.rb | 14 ++-- spec/homesick_spec.rb | 164 ++++++++++++++++++++-------------------- spec/spec_helper.rb | 4 +- 4 files changed, 112 insertions(+), 112 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index a8a294e..3a0eebb 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -11,14 +11,14 @@ class Homesick < Thor add_runtime_options! GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/ - SUBDIR_FILENAME = ".homesick_subdir" + SUBDIR_FILENAME = '.homesick_subdir' def initialize(args=[], options={}, config={}) super self.shell = Homesick::Shell.new end - desc "clone URI", "Clone +uri+ as a castle for homesick" + desc 'clone URI', 'Clone +uri+ as a castle for homesick' def clone(uri) inside repos_dir do destination = nil @@ -55,20 +55,20 @@ class Homesick < Thor if homesickrc.exist? proceed = shell.yes?("#{uri} has a .homesickrc. Proceed with evaling it? (This could be destructive)") if proceed - shell.say_status "eval", homesickrc + shell.say_status 'eval', homesickrc inside destination do eval homesickrc.read, binding, homesickrc.expand_path end else - shell.say_status "eval skip", "not evaling #{homesickrc}, #{destination} may need manual configuration", :blue + shell.say_status 'eval skip', "not evaling #{homesickrc}, #{destination} may need manual configuration", :blue end end end end - desc "pull CASTLE", "Update the specified castle" - method_option :all, :type => :boolean, :default => false, :required => false, :desc => "Update all cloned castles" - def pull(name="") + desc 'pull CASTLE', 'Update the specified castle' + method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles' + def pull(name='') if options[:all] inside_each_castle do |castle| shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':' @@ -80,22 +80,22 @@ class Homesick < Thor end - desc "commit CASTLE", "Commit the specified castle's changes" + desc 'commit CASTLE', "Commit the specified castle's changes" def commit(name) commit_castle name end - desc "push CASTLE", "Push the specified castle" + desc 'push CASTLE', 'Push the specified castle' def push(name) push_castle name end - desc "symlink CASTLE", "Symlinks all dotfiles from the specified castle" - method_option :force, :default => false, :desc => "Overwrite existing conflicting symlinks without prompting." + desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle' + method_option :force, :default => false, :desc => 'Overwrite existing conflicting symlinks without prompting.' def symlink(name) - check_castle_existance(name, "symlink") + check_castle_existance(name, 'symlink') inside castle_dir(name) do subdirs = subdirs(name) @@ -110,7 +110,7 @@ class Homesick < Thor end end - desc "track FILE CASTLE", "add a file to a castle" + desc 'track FILE CASTLE', 'add a file to a castle' def track(file, castle) castle = Pathname.new(castle) file = Pathname.new(file.chomp('/')) @@ -155,19 +155,19 @@ class Homesick < Thor end end - desc "list", "List cloned castles" + desc 'list', 'List cloned castles' def list inside_each_castle do |castle| say_status castle.relative_path_from(repos_dir).to_s, `git config remote.origin.url`.chomp, :cyan end end - desc "generate PATH", "generate a homesick-ready git repo at PATH" + desc 'generate PATH', 'generate a homesick-ready git repo at PATH' def generate(castle) castle = Pathname.new(castle).expand_path github_user = `git config github.user`.chomp - github_user = nil if github_user == "" + github_user = nil if github_user == '' github_repo = castle.basename empty_directory castle @@ -178,7 +178,7 @@ class Homesick < Thor git_remote_add 'origin', url end - empty_directory "home" + empty_directory 'home' end end @@ -240,7 +240,7 @@ class Homesick < Thor end def update_castle(castle) - check_castle_existance(castle, "pull") + check_castle_existance(castle, 'pull') inside repos_dir.join(castle) do git_pull git_submodule_init @@ -249,14 +249,14 @@ class Homesick < Thor end def commit_castle(castle) - check_castle_existance(castle, "commit") + check_castle_existance(castle, 'commit') inside repos_dir.join(castle) do git_commit_all end end def push_castle(castle) - check_castle_existance(castle, "push") + check_castle_existance(castle, 'push') inside repos_dir.join(castle) do git_push end @@ -326,7 +326,7 @@ class Homesick < Thor def symlink_each(castle, basedir, subdirs) absolute_basedir = Pathname.new(basedir).expand_path inside basedir do - files = Pathname.glob('{.*,*}').reject{|a| [".", ".."].include?(a.to_s)} + files = Pathname.glob('{.*,*}').reject{|a| ['.', '..'].include?(a.to_s)} files.each do |path| absolute_path = path.expand_path castle_home = castle_dir(castle) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index c170174..d0f7639 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -17,13 +17,13 @@ class Homesick end end - def git_init(path = ".") + def git_init(path = '.') path = Pathname.new(path) inside path do unless path.join('.git').exist? say_status 'git init', '' unless options[:quiet] - system "git init >/dev/null" unless options[:pretend] + system 'git init >/dev/null' unless options[:pretend] else say_status 'git init', 'already initialized', :blue unless options[:quiet] end @@ -44,27 +44,27 @@ class Homesick def git_submodule_init(config = {}) say_status 'git submodule', 'init', :green unless options[:quiet] - system "git submodule --quiet init" unless options[:pretend] + 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 --init --recursive >/dev/null 2>&1" unless options[:pretend] + system 'git submodule --quiet update --init --recursive >/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] + system 'git pull --quiet' unless options[:pretend] end def git_push(config = {}) say_status 'git push', '', :green unless options[:quiet] - system "git push" unless options[:pretend] + system 'git push' unless options[:pretend] end def git_commit_all(config = {}) say_status 'git commit all', '', :green unless options[:quiet] - system "git commit -v -a" unless options[:pretend] + system 'git commit -v -a' unless options[:pretend] end def git_add(file, config = {}) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 2343b9e..f0308c6 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -1,237 +1,237 @@ # -*- encoding : utf-8 -*- require 'spec_helper' -describe "homesick" do +describe 'homesick' do let(:home) { create_construct } after { home.destroy! } - let(:castles) { home.directory(".homesick/repos") } + let(:castles) { home.directory('.homesick/repos') } let(:homesick) { Homesick.new } before { homesick.stub!(:repos_dir).and_return(castles) } - describe "clone" do - context "of a file" do - it "should symlink existing directories" do + describe 'clone' do + context 'of a file' do + it 'should symlink existing directories' do somewhere = create_construct local_repo = somewhere.directory('wtf') homesick.clone local_repo - castles.join("wtf").readlink.should == local_repo + castles.join('wtf').readlink.should == local_repo end - context "when it exists in a repo directory" do + context 'when it exists in a repo directory' do before do - existing_castle = given_castle("existing_castle") + existing_castle = given_castle('existing_castle') @existing_dir = existing_castle.parent end - it "should not symlink" do + it 'should not symlink' do homesick.should_not_receive(:git_clone) homesick.clone @existing_dir.to_s rescue nil end - it "should raise an error" do + it 'should raise an error' do expect { homesick.clone @existing_dir.to_s }.to raise_error(/already cloned/i) end end end - it "should clone git repo like file:///path/to.git" do - bare_repo = File.join(create_construct.to_s, "dotfiles.git") + it 'should clone git repo like file:///path/to.git' do + bare_repo = File.join(create_construct.to_s, 'dotfiles.git') system "git init --bare #{bare_repo} >/dev/null 2>&1" homesick.clone "file://#{bare_repo}" File.directory?(File.join(home.to_s, '.homesick/repos/dotfiles')).should be_true 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.clone "git://github.com/technicalpickles/pickled-vim.git" + homesick.clone 'git://github.com/technicalpickles/pickled-vim.git' 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.clone 'git@github.com:technicalpickles/pickled-vim.git' end - it "should clone git repo like http://host/path/to.git" do + it 'should clone git repo like http://host/path/to.git' do homesick.should_receive(:git_clone).with('http://github.com/technicalpickles/pickled-vim.git') homesick.clone 'http://github.com/technicalpickles/pickled-vim.git' end - it "should clone git repo like http://host/path/to" do + it 'should clone git repo like http://host/path/to' do homesick.should_receive(:git_clone).with('http://github.com/technicalpickles/pickled-vim') homesick.clone 'http://github.com/technicalpickles/pickled-vim' end - it "should clone git repo like host-alias:repos.git" do + it 'should clone git repo like host-alias:repos.git' do homesick.should_receive(:git_clone).with('gitolite:pickled-vim.git') homesick.clone 'gitolite:pickled-vim.git' end - it "should not try to clone a malformed uri like malformed" do + it 'should not try to clone a malformed uri like malformed' do homesick.should_not_receive(:git_clone) homesick.clone 'malformed' rescue nil end - it "should throw an exception when trying to clone a malformed uri like malformed" do + it 'should throw an exception when trying to clone a malformed uri like malformed' do expect { homesick.clone 'malformed' }.to raise_error end - it "should clone a github repo" do + it 'should clone a github repo' do homesick.should_receive(:git_clone).with('git://github.com/wfarr/dotfiles.git', :destination => Pathname.new('wfarr/dotfiles')) - homesick.clone "wfarr/dotfiles" + homesick.clone 'wfarr/dotfiles' end end - describe "symlink" do - let(:castle) { given_castle("glencairn") } + describe 'symlink' do + let(:castle) { given_castle('glencairn') } - it "links dotfiles from a castle to the home folder" do - dotfile = castle.file(".some_dotfile") + it 'links dotfiles from a castle to the home folder' do + dotfile = castle.file('.some_dotfile') - homesick.symlink("glencairn") + homesick.symlink('glencairn') - home.join(".some_dotfile").readlink.should == dotfile + home.join('.some_dotfile').readlink.should == dotfile end - it "links non-dotfiles from a castle to the home folder" do - dotfile = castle.file("bin") + it 'links non-dotfiles from a castle to the home folder' do + dotfile = castle.file('bin') - homesick.symlink("glencairn") + homesick.symlink('glencairn') - home.join("bin").readlink.should == dotfile + home.join('bin').readlink.should == dotfile end - context "when forced" do + context 'when forced' do let(:homesick) { Homesick.new [], :force => true } - it "can override symlinks to directories" do + it 'can override symlinks to directories' do somewhere_else = create_construct - existing_dotdir_link = home.join(".vim") + existing_dotdir_link = home.join('.vim') FileUtils.ln_s somewhere_else, existing_dotdir_link - dotdir = castle.directory(".vim") + dotdir = castle.directory('.vim') - homesick.symlink("glencairn") + homesick.symlink('glencairn') existing_dotdir_link.readlink.should == dotdir end - it "can override existing directory" do + it 'can override existing directory' do somewhere_else = create_construct - existing_dotdir = home.directory(".vim") + existing_dotdir = home.directory('.vim') - dotdir = castle.directory(".vim") + dotdir = castle.directory('.vim') - homesick.symlink("glencairn") + homesick.symlink('glencairn') existing_dotdir.readlink.should == dotdir end end context "with '.config' in .homesick_subdir" do - let(:castle) { given_castle("glencairn", [".config"]) } - it "can symlink in sub directory" do - dotdir = castle.directory(".config") - dotfile = dotdir.file(".some_dotfile") + let(:castle) { given_castle('glencairn', ['.config']) } + it 'can symlink in sub directory' do + dotdir = castle.directory('.config') + dotfile = dotdir.file('.some_dotfile') - homesick.symlink("glencairn") + homesick.symlink('glencairn') - home_dotdir = home.join(".config") + home_dotdir = home.join('.config') home_dotdir.symlink?.should be == false - home_dotdir.join(".some_dotfile").readlink.should == dotfile + home_dotdir.join('.some_dotfile').readlink.should == dotfile end end context "with '.config/appA' in .homesick_subdir" do - let(:castle) { given_castle("glencairn", [".config/appA"]) } - it "can symlink in nested sub directory" do - dotdir = castle.directory(".config").directory("appA") - dotfile = dotdir.file(".some_dotfile") + let(:castle) { given_castle('glencairn', ['.config/appA']) } + it 'can symlink in nested sub directory' do + dotdir = castle.directory('.config').directory('appA') + dotfile = dotdir.file('.some_dotfile') - homesick.symlink("glencairn") + homesick.symlink('glencairn') - home_dotdir = home.join(".config").join("appA") + home_dotdir = home.join('.config').join('appA') home_dotdir.symlink?.should be == false - home_dotdir.join(".some_dotfile").readlink.should == dotfile + home_dotdir.join('.some_dotfile').readlink.should == dotfile end end context "with '.config' and '.config/appA' in .homesick_subdir" do - let(:castle) { given_castle("glencairn", [".config", ".config/appA"]) } - it "can symlink under both of .config and .config/appA" do - config_dir = castle.directory(".config") - config_dotfile = config_dir.file(".some_dotfile") - appA_dir = config_dir.directory("appA") - appA_dotfile = appA_dir.file(".some_appfile") + let(:castle) { given_castle('glencairn', ['.config', '.config/appA']) } + it 'can symlink under both of .config and .config/appA' do + config_dir = castle.directory('.config') + config_dotfile = config_dir.file('.some_dotfile') + appA_dir = config_dir.directory('appA') + appA_dotfile = appA_dir.file('.some_appfile') - homesick.symlink("glencairn") + homesick.symlink('glencairn') - home_config_dir = home.join(".config") - home_appA_dir = home_config_dir.join("appA") + home_config_dir = home.join('.config') + home_appA_dir = home_config_dir.join('appA') home_config_dir.symlink?.should be == false - home_config_dir.join(".some_dotfile").readlink.should be == config_dotfile + home_config_dir.join('.some_dotfile').readlink.should be == config_dotfile home_appA_dir.symlink?.should be == false - home_appA_dir.join(".some_appfile").readlink.should == appA_dotfile + home_appA_dir.join('.some_appfile').readlink.should == appA_dotfile end end end - describe "list" do - it "should say each castle in the castle directory" do + describe 'list' do + it 'should say each castle in the castle directory' do given_castle('zomg') given_castle('wtf/zomg') - homesick.should_receive(:say_status).with("zomg", "git://github.com/technicalpickles/zomg.git", :cyan) - homesick.should_receive(:say_status).with("wtf/zomg", "git://github.com/technicalpickles/zomg.git", :cyan) + homesick.should_receive(:say_status).with('zomg', 'git://github.com/technicalpickles/zomg.git', :cyan) + homesick.should_receive(:say_status).with('wtf/zomg', 'git://github.com/technicalpickles/zomg.git', :cyan) homesick.list end end - describe "pull" do + describe 'pull' do - xit "needs testing" + xit 'needs testing' - describe "--all" do - xit "needs testing" + describe '--all' do + xit 'needs testing' end end - describe "commit" do + describe 'commit' do - xit "needs testing" + xit 'needs testing' end - describe "push" do + describe 'push' do - xit "needs testing" + xit 'needs testing' end - describe "track" do - it "should move the tracked file into the castle" do + describe 'track' do + it 'should move the tracked file into the castle' do castle = given_castle('castle_repo') some_rc_file = home.file '.some_rc_file' homesick.track(some_rc_file.to_s, 'castle_repo') - tracked_file = castle.join(".some_rc_file") + tracked_file = castle.join('.some_rc_file') tracked_file.should exist some_rc_file.readlink.should == tracked_file @@ -259,7 +259,7 @@ describe "homesick" do some_nested_dir.realpath.should == tracked_file.realpath end - describe "subdir_file" do + describe 'subdir_file' do it 'should add the nested files parent to the subdir_file' do castle = given_castle('castle_repo') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1c78cf3..97110d7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,7 +20,7 @@ RSpec.configure do |config| name = Pathname.new(path).basename castles.directory(path) do |castle| Dir.chdir(castle) do - system "git init >/dev/null 2>&1" + system 'git init >/dev/null 2>&1' system "git remote add origin git://github.com/technicalpickles/#{name}.git >/dev/null 2>&1" if subdirs then subdir_file = castle.join(Homesick::SUBDIR_FILENAME) @@ -28,7 +28,7 @@ RSpec.configure do |config| system "echo #{subdir} >> #{subdir_file}" end end - return castle.directory("home") + return castle.directory('home') end end end From bf248cd645aab401f338ff6f1663361349a3422c Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 19 Jun 2013 16:41:12 +0000 Subject: [PATCH 49/97] don't fail test even if rubocop detects some offence --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 52d2dfd..fc4e5b8 100644 --- a/Rakefile +++ b/Rakefile @@ -43,7 +43,7 @@ end task :rubocop do if RUBY_VERSION >= '1.9.2' - raise unless system('rubocop') + system('rubocop') end end From f8a6fb9ce2875a7168af41e988f2a09c26422607 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 19 Jun 2013 17:21:24 +0000 Subject: [PATCH 50/97] follow Ruby Style Guide for some points --- bin/homesick | 2 +- lib/homesick.rb | 20 +++++++++++--------- lib/homesick/actions.rb | 4 ++-- spec/homesick_spec.rb | 31 ++++++++++++++++++++----------- spec/spec_helper.rb | 4 ++-- 5 files changed, 36 insertions(+), 25 deletions(-) diff --git a/bin/homesick b/bin/homesick index 711405d..aef6100 100755 --- a/bin/homesick +++ b/bin/homesick @@ -2,7 +2,7 @@ require 'pathname' lib = Pathname.new(__FILE__).dirname.join('..', 'lib').expand_path -$LOAD_PATH.unshift lib.to_s +$LOAD_PATH.unshift lib.to_s require 'homesick' diff --git a/lib/homesick.rb b/lib/homesick.rb index 3a0eebb..e7c0f03 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -13,7 +13,7 @@ class Homesick < Thor GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/ SUBDIR_FILENAME = '.homesick_subdir' - def initialize(args=[], options={}, config={}) + def initialize(args = [], options = {}, config = {}) super self.shell = Homesick::Shell.new end @@ -34,7 +34,7 @@ class Homesick < Thor elsif uri =~ GITHUB_NAME_REPO_PATTERN destination = Pathname.new($1) git_clone "git://github.com/#{$1}.git", :destination => destination - elsif uri =~ /\/([^\/]*?)(\.git)?\Z/ + elsif uri =~ /%r([^%r]*?)(\.git)?\Z/ destination = Pathname.new($1) git_clone uri elsif uri =~ /[^:]+:([^:]+)(\.git)?\Z/ @@ -68,7 +68,7 @@ class Homesick < Thor desc 'pull CASTLE', 'Update the specified castle' method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles' - def pull(name='') + def pull(name = '') if options[:all] inside_each_castle do |castle| shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':' @@ -150,9 +150,7 @@ class Homesick < Thor end # are we tracking something nested? Add the parent dir to the manifest - unless relative_dir.eql?(Pathname.new('.')) - subdir_add(castle, relative_dir) - end + subdir_add(castle, relative_dir) unless relative_dir.eql?(Pathname.new('.')) end desc 'list', 'List cloned castles' @@ -226,7 +224,9 @@ class Homesick < Thor dirs = Pathname.glob("#{repos_dir}/**/.git", File::FNM_DOTMATCH) # reject paths that lie inside another castle, like git submodules return dirs.reject do |dir| - dirs.any? {|other| dir != other && dir.fnmatch(other.parent.join('*').to_s) } + dirs.any? do |other| + dir != other && dir.fnmatch(other.parent.join('*').to_s) + end end end @@ -280,7 +280,9 @@ class Homesick < Thor def subdir_add(castle, path) subdir_filepath = subdir_file(castle) File.open(subdir_filepath, 'a+') do |subdir| - subdir.puts path unless subdir.readlines.inject(false) { |memo, line| line.eql?("#{path.to_s}\n") || memo } + subdir.puts path unless subdir.readlines.reduce(false) do |memo, line| + line.eql?("#{path.to_s}\n") || memo + end end inside castle_dir(castle) do @@ -326,7 +328,7 @@ class Homesick < Thor def symlink_each(castle, basedir, subdirs) absolute_basedir = Pathname.new(basedir).expand_path inside basedir do - files = Pathname.glob('{.*,*}').reject{|a| ['.', '..'].include?(a.to_s)} + files = Pathname.glob('{.*,*}').reject{ |a| ['.', '..'].include?(a.to_s) } files.each do |path| absolute_path = path.expand_path castle_home = castle_dir(castle) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index d0f7639..26eb45d 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -21,7 +21,7 @@ class Homesick path = Pathname.new(path) inside path do - unless path.join('.git').exist? + if !path.join('.git').exist? say_status 'git init', '' unless options[:quiet] system 'git init >/dev/null' unless options[:pretend] else @@ -34,7 +34,7 @@ class Homesick existing_remote = `git config remote.#{name}.url`.chomp existing_remote = nil if existing_remote == '' - unless existing_remote + if !existing_remote say_status 'git remote', "add #{name} #{url}" unless options[:quiet] system "git remote add #{name} #{url}" unless options[:pretend] else diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index f0308c6..b07af15 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -31,7 +31,12 @@ describe 'homesick' do it 'should not symlink' do homesick.should_not_receive(:git_clone) - homesick.clone @existing_dir.to_s rescue nil + begin + homesick.clone @existing_dir.to_s + fail 'homesick.clone should raise' + rescue => e + e.message.should match 'Castle already cloned to' + end end it 'should raise an error' do @@ -81,7 +86,12 @@ describe 'homesick' do it 'should not try to clone a malformed uri like malformed' do homesick.should_not_receive(:git_clone) - homesick.clone 'malformed' rescue nil + begin + homesick.clone 'malformed' + fail 'homesick.clone should raise' + rescue => e + e.message.should match 'Unknown URI format: malformed' + end end it 'should throw an exception when trying to clone a malformed uri like malformed' do @@ -130,7 +140,6 @@ describe 'homesick' do end it 'can override existing directory' do - somewhere_else = create_construct existing_dotdir = home.directory('.vim') dotdir = castle.directory('.vim') @@ -169,22 +178,22 @@ describe 'homesick' do end end - context "with '.config' and '.config/appA' in .homesick_subdir" do - let(:castle) { given_castle('glencairn', ['.config', '.config/appA']) } - it 'can symlink under both of .config and .config/appA' do + context "with '.config' and '.config/someapp' in .homesick_subdir" do + let(:castle) { given_castle('glencairn', ['.config', '.config/someapp']) } + it 'can symlink under both of .config and .config/someapp' do config_dir = castle.directory('.config') config_dotfile = config_dir.file('.some_dotfile') - appA_dir = config_dir.directory('appA') - appA_dotfile = appA_dir.file('.some_appfile') + someapp_dir = config_dir.directory('someapp') + someapp_dotfile = someapp_dir.file('.some_appfile') homesick.symlink('glencairn') home_config_dir = home.join('.config') - home_appA_dir = home_config_dir.join('appA') + home_someapp_dir = home_config_dir.join('someapp') home_config_dir.symlink?.should be == false home_config_dir.join('.some_dotfile').readlink.should be == config_dotfile - home_appA_dir.symlink?.should be == false - home_appA_dir.join('.some_appfile').readlink.should == appA_dotfile + home_someapp_dir.symlink?.should be == false + home_someapp_dir.join('.some_appfile').readlink.should == someapp_dotfile end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 97110d7..d231ec8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,13 +16,13 @@ RSpec.configure do |config| homesick.stub(:say_status) end - def given_castle(path, subdirs=[]) + def given_castle(path, subdirs = []) name = Pathname.new(path).basename castles.directory(path) do |castle| Dir.chdir(castle) do system 'git init >/dev/null 2>&1' system "git remote add origin git://github.com/technicalpickles/#{name}.git >/dev/null 2>&1" - if subdirs then + if subdirs subdir_file = castle.join(Homesick::SUBDIR_FILENAME) subdirs.each do |subdir| system "echo #{subdir} >> #{subdir_file}" From 8f2a9e67035ff6b9226c8bc1e00424421f1f4df3 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 19 Jun 2013 17:42:16 +0000 Subject: [PATCH 51/97] remove duplicate spec --- spec/homesick_spec.rb | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index b07af15..1d70369 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -28,18 +28,8 @@ describe 'homesick' do @existing_dir = existing_castle.parent end - it 'should not symlink' do - homesick.should_not_receive(:git_clone) - - begin - homesick.clone @existing_dir.to_s - fail 'homesick.clone should raise' - rescue => e - e.message.should match 'Castle already cloned to' - end - end - it 'should raise an error' do + homesick.should_not_receive(:git_clone) expect { homesick.clone @existing_dir.to_s }.to raise_error(/already cloned/i) end end @@ -83,18 +73,8 @@ describe 'homesick' do homesick.clone 'gitolite:pickled-vim.git' end - it 'should not try to clone a malformed uri like malformed' do - homesick.should_not_receive(:git_clone) - - begin - homesick.clone 'malformed' - fail 'homesick.clone should raise' - rescue => e - e.message.should match 'Unknown URI format: malformed' - end - end - it 'should throw an exception when trying to clone a malformed uri like malformed' do + homesick.should_not_receive(:git_clone) expect { homesick.clone 'malformed' }.to raise_error end From 8ee5165ccf387ee1f1a871e3a72c37c99e585588 Mon Sep 17 00:00:00 2001 From: akahige Date: Fri, 21 Jun 2013 14:02:50 +0900 Subject: [PATCH 52/97] set default castle name: 'dotfiles' for some commands --- lib/homesick.rb | 10 +++++----- spec/homesick_spec.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index e7c0f03..3488c2e 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -68,7 +68,7 @@ class Homesick < Thor desc 'pull CASTLE', 'Update the specified castle' method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles' - def pull(name = '') + def pull(name = 'dotfiles') if options[:all] inside_each_castle do |castle| shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':' @@ -81,20 +81,20 @@ class Homesick < Thor end desc 'commit CASTLE', "Commit the specified castle's changes" - def commit(name) + def commit(name = 'dotfiles') commit_castle name end desc 'push CASTLE', 'Push the specified castle' - def push(name) + def push(name = 'dotfiles') push_castle name end desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle' method_option :force, :default => false, :desc => 'Overwrite existing conflicting symlinks without prompting.' - def symlink(name) + def symlink(name = 'dotfiles') check_castle_existance(name, 'symlink') inside castle_dir(name) do @@ -111,7 +111,7 @@ class Homesick < Thor end desc 'track FILE CASTLE', 'add a file to a castle' - def track(file, castle) + def track(file, castle = 'dotfiles') castle = Pathname.new(castle) file = Pathname.new(file.chomp('/')) check_castle_existance(castle, 'track') diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 1d70369..f4037b5 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -176,6 +176,17 @@ describe 'homesick' do home_someapp_dir.join('.some_appfile').readlink.should == someapp_dotfile end end + + context "when call with no castle name" do + let(:castle) { given_castle('dotfiles') } + it 'using default castle name: "dotfiles"' do + dotfile = castle.file('.some_dotfile') + + homesick.symlink + + home.join('.some_dotfile').readlink.should == dotfile + end + end end describe 'list' do @@ -248,6 +259,21 @@ describe 'homesick' do some_nested_dir.realpath.should == tracked_file.realpath end + context "when call with no castle name" do + it 'using default castle name: "dotfiles"' do + castle = given_castle('dotfiles') + + some_rc_file = home.file '.some_rc_file' + + homesick.track(some_rc_file.to_s) + + tracked_file = castle.join('.some_rc_file') + tracked_file.should exist + + some_rc_file.readlink.should == tracked_file + end + end + describe 'subdir_file' do it 'should add the nested files parent to the subdir_file' do From 314e2932fb48b96c6e8c5b16eadb5bda1d72eda6 Mon Sep 17 00:00:00 2001 From: John Bellone Date: Fri, 21 Jun 2013 09:45:26 -0300 Subject: [PATCH 53/97] Update homesick.rb to make https default for GitHub clones. If we use HTTPS it is a lot easier for corporate worlds to manage proxies since its usually already done for us. Also HTTPS cloning is just as fast as the git protocol as of more recent versions. --- lib/homesick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 3488c2e..1edcc45 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -33,7 +33,7 @@ class Homesick < Thor ln_s uri, destination elsif uri =~ GITHUB_NAME_REPO_PATTERN destination = Pathname.new($1) - git_clone "git://github.com/#{$1}.git", :destination => destination + git_clone "https://github.com/#{$1}.git", :destination => destination elsif uri =~ /%r([^%r]*?)(\.git)?\Z/ destination = Pathname.new($1) git_clone uri From d3cb45f879b7368edbf141c39a1342fa8df5601c Mon Sep 17 00:00:00 2001 From: akahige Date: Mon, 24 Jun 2013 00:44:17 +0900 Subject: [PATCH 54/97] default castle name to constant --- lib/homesick.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 1edcc45..a6480a6 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -13,6 +13,8 @@ class Homesick < Thor GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/ SUBDIR_FILENAME = '.homesick_subdir' + DEFAULT_CASTLE_NAME = 'dotfiles' + def initialize(args = [], options = {}, config = {}) super self.shell = Homesick::Shell.new @@ -68,7 +70,7 @@ class Homesick < Thor desc 'pull CASTLE', 'Update the specified castle' method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles' - def pull(name = 'dotfiles') + def pull(name = DEFAULT_CASTLE_NAME) if options[:all] inside_each_castle do |castle| shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':' @@ -81,20 +83,20 @@ class Homesick < Thor end desc 'commit CASTLE', "Commit the specified castle's changes" - def commit(name = 'dotfiles') + def commit(name = DEFAULT_CASTLE_NAME) commit_castle name end desc 'push CASTLE', 'Push the specified castle' - def push(name = 'dotfiles') + def push(name = DEFAULT_CASTLE_NAME) push_castle name end desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle' method_option :force, :default => false, :desc => 'Overwrite existing conflicting symlinks without prompting.' - def symlink(name = 'dotfiles') + def symlink(name = DEFAULT_CASTLE_NAME) check_castle_existance(name, 'symlink') inside castle_dir(name) do @@ -111,7 +113,7 @@ class Homesick < Thor end desc 'track FILE CASTLE', 'add a file to a castle' - def track(file, castle = 'dotfiles') + def track(file, castle = DEFAULT_CASTLE_NAME) castle = Pathname.new(castle) file = Pathname.new(file.chomp('/')) check_castle_existance(castle, 'track') From 92c61f928e55f3457b0849a78cbbfeb8f1c9d7ad Mon Sep 17 00:00:00 2001 From: David Simon Date: Tue, 25 Jun 2013 16:11:08 -0400 Subject: [PATCH 55/97] Added three commands: show_path, status, diff --- lib/homesick.rb | 22 ++++++++++++++++++++++ lib/homesick/actions.rb | 10 ++++++++++ spec/homesick_spec.rb | 22 ++++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/lib/homesick.rb b/lib/homesick.rb index a6480a6..2b7b306 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -162,6 +162,28 @@ class Homesick < Thor end end + desc 'status CASTLE', 'Shows the git status of a castle' + def status(castle) + check_castle_existance(castle, 'status') + inside repos_dir.join(castle) do + git_status + end + end + + desc 'diff CASTLE', 'Shows the git diff of a castle' + def diff(castle) + check_castle_existance(castle, 'diff') + inside repos_dir.join(castle) do + git_diff + end + end + + desc 'show_path CASTLE', 'Prints the path of a castle' + def show_path(castle) + check_castle_existance(castle, 'show_path') + say repos_dir.join(castle) + end + desc 'generate PATH', 'generate a homesick-ready git repo at PATH' def generate(castle) castle = Pathname.new(castle).expand_path diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 26eb45d..1a6a406 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -72,6 +72,16 @@ class Homesick system "git add #{file}" unless options[:pretend] end + def git_status(config = {}) + say_status 'git status', '', :green unless options[:quiet] + system "git status" unless options[:pretend] + end + + def git_diff(config = {}) + say_status 'git diff', '', :green unless options[:quiet] + system "git diff" unless options[:pretend] + end + def mv(source, destination, config = {}) source = Pathname.new(source) destination = Pathname.new(destination + source.basename) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index f4037b5..fdea672 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -201,6 +201,28 @@ describe 'homesick' do end end + describe 'status' do + + xit 'needs testing' + + end + + describe 'diff' do + + xit 'needs testing' + + end + + describe 'show_path' do + it 'should say the path of a castle' do + castle = given_castle('castle_repo') + + homesick.should_receive(:say).with(castle.dirname) + + homesick.show_path('castle_repo') + end + end + describe 'pull' do xit 'needs testing' From 6f3186df2f329ca2e232bca0fd176bbebfb512cb Mon Sep 17 00:00:00 2001 From: David Simon Date: Wed, 26 Jun 2013 14:29:45 -0400 Subject: [PATCH 56/97] Using DEFAULT_CASTLE_NAME in show_path, diff, status --- lib/homesick.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 2b7b306..de364e5 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -163,15 +163,15 @@ class Homesick < Thor end desc 'status CASTLE', 'Shows the git status of a castle' - def status(castle) + def status(castle = DEFAULT_CASTLE_NAME) check_castle_existance(castle, 'status') inside repos_dir.join(castle) do git_status end end - desc 'diff CASTLE', 'Shows the git diff of a castle' - def diff(castle) + desc 'diff CASTLE', 'Shows the git diff of uncommitted changes in a castle' + def diff(castle = DEFAULT_CASTLE_NAME) check_castle_existance(castle, 'diff') inside repos_dir.join(castle) do git_diff @@ -179,7 +179,7 @@ class Homesick < Thor end desc 'show_path CASTLE', 'Prints the path of a castle' - def show_path(castle) + def show_path(castle = DEFAULT_CASTLE_DAME) check_castle_existance(castle, 'show_path') say repos_dir.join(castle) end From 651e028d5b66b92b7d4bb371e1a72e210587e424 Mon Sep 17 00:00:00 2001 From: David Simon Date: Wed, 26 Jun 2013 14:34:43 -0400 Subject: [PATCH 57/97] Whoops, fixed typo --- lib/homesick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index de364e5..623aa49 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -179,7 +179,7 @@ class Homesick < Thor end desc 'show_path CASTLE', 'Prints the path of a castle' - def show_path(castle = DEFAULT_CASTLE_DAME) + def show_path(castle = DEFAULT_CASTLE_NAME) check_castle_existance(castle, 'show_path') say repos_dir.join(castle) end From 44080829e3b0fa2a1151b80b1aa8d1e6bbf5b100 Mon Sep 17 00:00:00 2001 From: Austin Lin Date: Thu, 27 Jun 2013 12:06:54 -0400 Subject: [PATCH 58/97] Update readme with correct file path for .homesick_subdir per technicalpickles/homesick@360e8185f75244b87d1a4f9191057616987097f7 --- README.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 2ba35c8..e025dda 100644 --- a/README.markdown +++ b/README.markdown @@ -77,9 +77,9 @@ and have home like this: |-- elisp `-- inits -You may want to symlink only to `castle/home/.config/fooapp` instead of `castle/home/.config` because you already have `~/.config/barapp`. In this case, you can use .homesick_subdir. Please write "directories you want to look up sub direcoties (instead of just first depth)" in this file. +You may want to symlink only to `castle/home/.config/fooapp` instead of `castle/home/.config` because you already have `~/.config/barapp`. In this case, you can use .homesick_subdir. Please write "directories you want to look up sub directories (instead of just first depth)" in this file. -castle/home/.homesick_subdir +castle/.homesick_subdir .config @@ -100,7 +100,7 @@ Or `homesick track NESTED_FILE CASTLE` adds a line automatically. For example: homesick track .emacs.d/elisp castle -castle/home/.homesick_subdir +castle/.homesick_subdir .config .emacs.d From 6fca06d341c86ee2124a8238345aac288d71c003 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 27 Jun 2013 17:08:33 +0000 Subject: [PATCH 59/97] bump up version --- ChangeLog.markdown | 7 +++++++ Rakefile | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index edda6f7..efefb23 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,10 @@ +# 0.9.2 + * Set "dotfiles" as default castle name + * Introduce new commands + * `homesick show_path` + * `homesick status` + * `homesick diff` + # 0.9.1 * Fixed small bugs: #35, #40 diff --git a/Rakefile b/Rakefile index fc4e5b8..69e5af2 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem| gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" gem.authors = ["Joshua Nichols", "Yusuke Murata"] - gem.version = "0.9.1" + gem.version = "0.9.2" gem.license = "MIT" # Have dependencies? Add them to Gemfile From d8b5d8163b8d3ce84e0ea64c3cd130574591ee0b Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 27 Jun 2013 17:11:56 +0000 Subject: [PATCH 60/97] remove Gemfile.lock from repository --- .gitignore | 2 ++ Gemfile.lock | 52 ---------------------------------------------------- 2 files changed, 2 insertions(+), 52 deletions(-) delete mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index e605e1e..e16687e 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,5 @@ pkg # For IDEA: .idea/ *.iml + +Gemfile.lock \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 6a55be8..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,52 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - ast (1.1.0) - diff-lcs (1.2.4) - git (1.2.5) - jeweler (1.8.4) - bundler (~> 1.0) - git (>= 1.2.5) - rake - rdoc - json (1.8.0) - multi_json (1.7.3) - parser (2.0.0.beta5) - ast (~> 1.0) - slop (~> 3.4) - rainbow (1.1.4) - rake (10.0.4) - rcov (1.0.0) - rdoc (4.0.1) - json (~> 1.4) - rspec (2.13.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - rspec-core (2.13.1) - rspec-expectations (2.13.0) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.13.1) - rubocop (0.8.3) - parser (= 2.0.0.beta5) - rainbow (>= 1.1.4) - simplecov (0.7.1) - multi_json (~> 1.0) - simplecov-html (~> 0.7.1) - simplecov-html (0.7.1) - slop (3.4.5) - test-construct (1.2.0) - thor (0.18.1) - -PLATFORMS - ruby - -DEPENDENCIES - jeweler (>= 1.6.2) - rake (>= 0.8.7) - rcov - rspec (~> 2.10) - rubocop - simplecov - test-construct - thor (>= 0.14.0) From a91ce82d77ca1a9d5310b7a4e6a05a9ee018eb87 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Thu, 27 Jun 2013 17:19:32 +0000 Subject: [PATCH 61/97] Regenerate gemspec for version 0.9.2 --- homesick.gemspec | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homesick.gemspec b/homesick.gemspec index 07823ec..d35fea6 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = %q{homesick} - s.version = "0.9.1" + s.version = "0.9.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = [%q{Joshua Nichols}, %q{Yusuke Murata}] - s.date = %q{2013-06-17} + s.date = %q{2013-06-27} s.description = %q{ A man's home (directory) is his castle, so don't leave home with out it. @@ -29,7 +29,6 @@ Gem::Specification.new do |s| ".travis.yml", "ChangeLog.markdown", "Gemfile", - "Gemfile.lock", "LICENSE", "README.markdown", "Rakefile", From f9d0b69bcebba76b2dc5c126c591e673c1f63e63 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Mon, 1 Jul 2013 16:35:19 +0000 Subject: [PATCH 62/97] add recursive option to 'homesick clone' --- lib/homesick/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 1a6a406..03ba481 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -11,7 +11,7 @@ class Homesick if ! destination.directory? say_status 'git clone', "#{repo} to #{destination.expand_path}", :green unless options[:quiet] - system "git clone -q #{repo} #{destination}" unless options[:pretend] + system "git clone -q --recursive #{repo} #{destination}" unless options[:pretend] else say_status :exist, destination.expand_path, :blue unless options[:quiet] end From 27ac1c7782743805da92821facc36090a4d26c7f Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Sun, 7 Jul 2013 03:26:34 +0900 Subject: [PATCH 63/97] bump up version --- ChangeLog.markdown | 3 +++ Rakefile | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index efefb23..7a0b662 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,6 @@ +# 0.9.3 + * Add recursive option to `homesick clone` + # 0.9.2 * Set "dotfiles" as default castle name * Introduce new commands diff --git a/Rakefile b/Rakefile index 69e5af2..cbd555b 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem| gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" gem.authors = ["Joshua Nichols", "Yusuke Murata"] - gem.version = "0.9.2" + gem.version = "0.9.3" gem.license = "MIT" # Have dependencies? Add them to Gemfile From 9551b3acb4cb1a6a0215e9ec53353ef248483081 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Sun, 7 Jul 2013 03:36:51 +0900 Subject: [PATCH 64/97] Regenerate gemspec for version 0.9.3 --- homesick.gemspec | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/homesick.gemspec b/homesick.gemspec index d35fea6..73e0901 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -4,20 +4,15 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = %q{homesick} - s.version = "0.9.2" + s.name = "homesick" + s.version = "0.9.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = [%q{Joshua Nichols}, %q{Yusuke Murata}] - s.date = %q{2013-06-27} - s.description = %q{ - A man's home (directory) is his castle, so don't leave home with out it. - - Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. - - } - s.email = [%q{josh@technicalpickles.com}, %q{info@muratayusuke.com}] - s.executables = [%q{homesick}] + s.authors = ["Joshua Nichols", "Yusuke Murata"] + s.date = "2013-07-06" + s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n " + s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] + s.executables = ["homesick"] s.extra_rdoc_files = [ "ChangeLog.markdown", "LICENSE", @@ -41,14 +36,14 @@ Gem::Specification.new do |s| "spec/spec.opts", "spec/spec_helper.rb" ] - s.homepage = %q{http://github.com/technicalpickles/homesick} - s.licenses = [%q{MIT}] - s.require_paths = [%q{lib}] - s.rubygems_version = %q{1.8.5} - s.summary = %q{A man's home is his castle. Never leave your dotfiles behind.} + s.homepage = "http://github.com/technicalpickles/homesick" + s.licenses = ["MIT"] + s.require_paths = ["lib"] + s.rubygems_version = "2.0.3" + s.summary = "A man's home is his castle. Never leave your dotfiles behind." if s.respond_to? :specification_version then - s.specification_version = 3 + s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0.14.0"]) @@ -58,6 +53,7 @@ Gem::Specification.new do |s| s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0.14.0"]) s.add_dependency(%q, [">= 0.8.7"]) @@ -66,6 +62,7 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0.14.0"]) @@ -75,6 +72,7 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end end From 965b35b78c2dd90d697502beb13969d7b480f104 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Tue, 16 Jul 2013 20:49:40 -0700 Subject: [PATCH 65/97] Ignore vendor dir --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e16687e..6fccad9 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,5 @@ pkg .idea/ *.iml -Gemfile.lock \ No newline at end of file +Gemfile.lock +vendor/ From b596e063f59dce144f9ddcb35a500282e9e2a225 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Tue, 16 Jul 2013 20:50:36 -0700 Subject: [PATCH 66/97] Add unlink functionality --- lib/homesick.rb | 33 +++++++++++++++- lib/homesick/actions.rb | 11 ++++++ spec/homesick_spec.rb | 88 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 2 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 623aa49..9af78eb 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -91,7 +91,23 @@ class Homesick < Thor desc 'push CASTLE', 'Push the specified castle' def push(name = DEFAULT_CASTLE_NAME) push_castle name + end + desc 'unlink CASTLE', 'Unsymlinks all dotfiles from the specified castle' + def unlink(name = DEFAULT_CASTLE_NAME) + check_castle_existance(name, 'symlink') + + inside castle_dir(name) do + subdirs = subdirs(name) + + # unlink files + unsymlink_each(name, castle_dir(name), subdirs) + + # unlink files in subdirs + subdirs.each do |subdir| + unsymlink_each(name, subdir, subdirs) + end + end end desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle' @@ -349,7 +365,7 @@ class Homesick < Thor first_p.mtime > second_p.mtime && !first_p.symlink? end - def symlink_each(castle, basedir, subdirs) + def each_file(castle, basedir, subdirs) absolute_basedir = Pathname.new(basedir).expand_path inside basedir do files = Pathname.glob('{.*,*}').reject{ |a| ['.', '..'].include?(a.to_s) } @@ -378,8 +394,21 @@ class Homesick < Thor relative_dir = absolute_basedir.relative_path_from(castle_home) home_path = home_dir.join(relative_dir).join(path) - ln_s absolute_path, home_path + + yield(absolute_path, home_path) end end end + + def unsymlink_each(castle, basedir, subdirs) + each_file(castle, basedir, subdirs) do |absolute_path, home_path| + rm_link home_path + end + end + + def symlink_each(castle, basedir, subdirs) + each_file(castle, basedir, subdirs) do |absolute_path, home_path| + ln_s absolute_path, home_path + end + end end diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 03ba481..8ee4cbb 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -108,6 +108,17 @@ class Homesick system "rm -rf #{dir}" end + def rm_link(target) + target = Pathname.new(target) + + if target.symlink? + say_status :unlink, "#{target.expand_path}", :green unless options[:quiet] + FileUtils.rm_rf target + else + say_status :conflict, "#{target} is not a symlink", :red unless options[:quiet] + end + end + def ln_s(source, destination, config = {}) source = Pathname.new(source) destination = Pathname.new(destination) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index fdea672..35932e3 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -189,6 +189,94 @@ describe 'homesick' do end end + describe 'unlink' do + let(:castle) { given_castle('glencairn') } + + it 'unlinks dotfiles in the home folder' do + dotfile = castle.file('.some_dotfile') + + homesick.symlink('glencairn') + homesick.unlink('glencairn') + + home.join('.some_dotfile').should_not exist + end + + it 'unlinks non-dotfiles from the home folder' do + dotfile = castle.file('bin') + + homesick.symlink('glencairn') + homesick.unlink('glencairn') + + home.join('bin').should_not exist + end + + context "with '.config' in .homesick_subdir" do + let(:castle) { given_castle('glencairn', ['.config']) } + + it 'can unlink sub directories' do + dotdir = castle.directory('.config') + dotfile = dotdir.file('.some_dotfile') + + homesick.symlink('glencairn') + homesick.unlink('glencairn') + + home_dotdir = home.join('.config') + home_dotdir.should exist + home_dotdir.join('.some_dotfile').should_not exist + end + end + + context "with '.config/appA' in .homesick_subdir" do + let(:castle) { given_castle('glencairn', ['.config/appA']) } + + it 'can unsymlink in nested sub directory' do + dotdir = castle.directory('.config').directory('appA') + dotfile = dotdir.file('.some_dotfile') + + homesick.symlink('glencairn') + homesick.unlink('glencairn') + + home_dotdir = home.join('.config').join('appA') + home_dotdir.should exist + home_dotdir.join('.some_dotfile').should_not exist + end + end + + context "with '.config' and '.config/someapp' in .homesick_subdir" do + let(:castle) { given_castle('glencairn', ['.config', '.config/someapp']) } + + it 'can unsymlink under both of .config and .config/someapp' do + config_dir = castle.directory('.config') + config_dotfile = config_dir.file('.some_dotfile') + someapp_dir = config_dir.directory('someapp') + someapp_dotfile = someapp_dir.file('.some_appfile') + + homesick.symlink('glencairn') + homesick.unlink('glencairn') + + home_config_dir = home.join('.config') + home_someapp_dir = home_config_dir.join('someapp') + home_config_dir.should exist + home_config_dir.join('.some_dotfile').should_not exist + home_someapp_dir.should exist + home_someapp_dir.join('.some_appfile').should_not exist + end + end + + context "when call with no castle name" do + let(:castle) { given_castle('dotfiles') } + + it 'using default castle name: "dotfiles"' do + dotfile = castle.file('.some_dotfile') + + homesick.symlink + homesick.unlink + + home.join('.some_dotfile').should_not exist + end + end + end + describe 'list' do it 'should say each castle in the castle directory' do given_castle('zomg') From 5b954b93e3bd65e9505b3694eb8f188c3d120dbe Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Tue, 16 Jul 2013 21:13:03 -0700 Subject: [PATCH 67/97] Fix #19 homesickrc pathname needs a to_s to eval Also, moved the file evaluation into a new function so the script can be ran manually which should make testing these scripts easier. --- lib/homesick.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 9af78eb..7fe7842 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -53,13 +53,21 @@ class Homesick < Thor end end + rc(destination) + end + end + + desc 'rc CASTLE', 'Run the .homesickrc for the specified castle' + def rc(name = DEFAULT_CASTLE_NAME) + inside repos_dir do + destination = Pathname.new(name) homesickrc = destination.join('.homesickrc').expand_path if homesickrc.exist? - proceed = shell.yes?("#{uri} has a .homesickrc. Proceed with evaling it? (This could be destructive)") + proceed = shell.yes?("#{name} has a .homesickrc. Proceed with evaling it? (This could be destructive)") if proceed shell.say_status 'eval', homesickrc inside destination do - eval homesickrc.read, binding, homesickrc.expand_path + eval homesickrc.read, binding, homesickrc.expand_path.to_s end else shell.say_status 'eval skip', "not evaling #{homesickrc}, #{destination} may need manual configuration", :blue From 9c52108035ab51112f12eb075f11a1c329e3b1ed Mon Sep 17 00:00:00 2001 From: John Bellone Date: Wed, 17 Jul 2013 07:28:39 -0400 Subject: [PATCH 68/97] Update specs to for change to https vs. git protocol. --- spec/homesick_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 35932e3..715a2b3 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -79,7 +79,7 @@ describe 'homesick' do end it 'should clone a github repo' do - homesick.should_receive(:git_clone).with('git://github.com/wfarr/dotfiles.git', :destination => Pathname.new('wfarr/dotfiles')) + homesick.should_receive(:git_clone).with('https://github.com/wfarr/dotfiles.git', :destination => Pathname.new('wfarr/dotfiles')) homesick.clone 'wfarr/dotfiles' end From 342da7e250865913ae2e9f332d705cbc790c8eef Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Wed, 17 Jul 2013 07:23:35 -0700 Subject: [PATCH 69/97] Adding test for clone running homesickrc --- spec/homesick_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 715a2b3..98cd2f8 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -12,6 +12,22 @@ describe 'homesick' do before { homesick.stub!(:repos_dir).and_return(castles) } describe 'clone' do + context 'has a .homesickrc' do + it 'should run the .homesickrc' do + somewhere = create_construct + local_repo = somewhere.directory('some_repo') + local_repo.file('.homesickrc') do |file| + file << "File.open(Dir.pwd + '/testing', 'w') { |f| f.print 'testing' }" + end + + expect($stdout).to receive(:print) + expect($stdin).to receive(:gets).and_return('y') + homesick.clone local_repo + + castles.join('some_repo').join('testing').should exist + end + end + context 'of a file' do it 'should symlink existing directories' do somewhere = create_construct From 294fb3d4ce6388f6847e7c7aa1146cb671eee898 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Wed, 17 Jul 2013 08:04:34 -0700 Subject: [PATCH 70/97] Add tests for the rc command --- spec/homesick_spec.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 98cd2f8..6520642 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -101,6 +101,44 @@ describe 'homesick' do end end + describe 'rc' do + let(:castle) { given_castle('glencairn') } + + context 'when told to do so' do + before do + expect($stdout).to receive(:print) + expect($stdin).to receive(:gets).and_return('y') + end + + it 'executes the .homesickrc' do + castle.file('.homesickrc') do |file| + file << "File.open(Dir.pwd + '/testing', 'w') { |f| f.print 'testing' }" + end + + homesick.rc castle + + castle.join('testing').should exist + end + end + + context 'when told not to do so' do + before do + expect($stdout).to receive(:print) + expect($stdin).to receive(:gets).and_return('n') + end + + it 'does not execute the .homesickrc' do + castle.file('.homesickrc') do |file| + file << "File.open(Dir.pwd + '/testing', 'w') { |f| f.print 'testing' }" + end + + homesick.rc castle + + castle.join('testing').should_not exist + end + end + end + describe 'symlink' do let(:castle) { given_castle('glencairn') } From 2a361d86e067085a92fd7b0b2834299ebc757532 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 31 Jul 2013 23:14:51 +0900 Subject: [PATCH 71/97] fix deprecated method: stub! -> stub --- spec/homesick_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 6520642..be588c8 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -9,7 +9,7 @@ describe 'homesick' do let(:homesick) { Homesick.new } - before { homesick.stub!(:repos_dir).and_return(castles) } + before { homesick.stub(:repos_dir).and_return(castles) } describe 'clone' do context 'has a .homesickrc' do From 238658cf69c4342f3f0e96e42babfd5f9595b11a Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 31 Jul 2013 23:21:46 +0900 Subject: [PATCH 72/97] remove unused variables --- spec/homesick_spec.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index be588c8..e8331f5 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -247,7 +247,7 @@ describe 'homesick' do let(:castle) { given_castle('glencairn') } it 'unlinks dotfiles in the home folder' do - dotfile = castle.file('.some_dotfile') + castle.file('.some_dotfile') homesick.symlink('glencairn') homesick.unlink('glencairn') @@ -256,7 +256,7 @@ describe 'homesick' do end it 'unlinks non-dotfiles from the home folder' do - dotfile = castle.file('bin') + castle.file('bin') homesick.symlink('glencairn') homesick.unlink('glencairn') @@ -268,8 +268,7 @@ describe 'homesick' do let(:castle) { given_castle('glencairn', ['.config']) } it 'can unlink sub directories' do - dotdir = castle.directory('.config') - dotfile = dotdir.file('.some_dotfile') + castle.directory('.config').file('.some_dotfile') homesick.symlink('glencairn') homesick.unlink('glencairn') @@ -284,8 +283,7 @@ describe 'homesick' do let(:castle) { given_castle('glencairn', ['.config/appA']) } it 'can unsymlink in nested sub directory' do - dotdir = castle.directory('.config').directory('appA') - dotfile = dotdir.file('.some_dotfile') + castle.directory('.config').directory('appA').file('.some_dotfile') homesick.symlink('glencairn') homesick.unlink('glencairn') @@ -301,9 +299,8 @@ describe 'homesick' do it 'can unsymlink under both of .config and .config/someapp' do config_dir = castle.directory('.config') - config_dotfile = config_dir.file('.some_dotfile') - someapp_dir = config_dir.directory('someapp') - someapp_dotfile = someapp_dir.file('.some_appfile') + config_dir.file('.some_dotfile') + config_dir.directory('someapp').file('.some_appfile') homesick.symlink('glencairn') homesick.unlink('glencairn') @@ -321,7 +318,7 @@ describe 'homesick' do let(:castle) { given_castle('dotfiles') } it 'using default castle name: "dotfiles"' do - dotfile = castle.file('.some_dotfile') + castle.file('.some_dotfile') homesick.symlink homesick.unlink From e21e608cca9ccecfe9b581fd58baf341cbd4cf40 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 31 Jul 2013 23:38:37 +0900 Subject: [PATCH 73/97] bump up version --- ChangeLog.markdown | 6 ++++++ README.markdown | 4 ++++ homesick.gemspec | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 7a0b662..c8cd98a 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,9 @@ +# 0.9.4 + * Use https protocol instead of git protocol + * Introduce new commands + * `homesick unlink` + * `homesick rc` + # 0.9.3 * Add recursive option to `homesick clone` diff --git a/README.markdown b/README.markdown index e025dda..cbbfb5b 100644 --- a/README.markdown +++ b/README.markdown @@ -31,6 +31,10 @@ If you use the shorthand syntax for GitHub repositories in your clone, please no homesick symlink technicalpickles/pickled-vim +You can remove symlinks anytime when you don't need them anymore + + homesick unlink pickled-vim + If you're not sure what castles you have around, you can easily list them: homesick list diff --git a/homesick.gemspec b/homesick.gemspec index 73e0901..6a59406 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.9.3" + s.version = "0.9.4" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] From d22361f2ac1963a5593747bd1d8781cac0e58fc1 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 31 Jul 2013 23:40:22 +0900 Subject: [PATCH 74/97] Regenerate gemspec for version 0.9.3 --- homesick.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homesick.gemspec b/homesick.gemspec index 6a59406..efe69d9 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.9.4" + s.version = "0.9.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] - s.date = "2013-07-06" + s.date = "2013-07-31" s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n " s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] s.executables = ["homesick"] From 6ae0aaa6f9c710da7054c043b71ae9d50b921592 Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 31 Jul 2013 23:41:36 +0900 Subject: [PATCH 75/97] bump up version --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index cbd555b..2916f19 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem| gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" gem.authors = ["Joshua Nichols", "Yusuke Murata"] - gem.version = "0.9.3" + gem.version = "0.9.4" gem.license = "MIT" # Have dependencies? Add them to Gemfile From 04c4a4c059c44863ca36e4e0bf62f105c914161b Mon Sep 17 00:00:00 2001 From: muratayusuke Date: Wed, 31 Jul 2013 23:41:49 +0900 Subject: [PATCH 76/97] Regenerate gemspec for version 0.9.4 --- homesick.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homesick.gemspec b/homesick.gemspec index efe69d9..eaad5fe 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.9.3" + s.version = "0.9.4" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] From 17426583e0e664fbd288868cefd2018d1c2ecb16 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Wed, 18 Sep 2013 09:25:09 -0700 Subject: [PATCH 77/97] Add test for parens in filenames, and fixed --- lib/homesick/actions.rb | 14 +++++++------- spec/homesick_spec.rb | 13 +++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 8ee4cbb..076a1b5 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -69,7 +69,7 @@ class Homesick def git_add(file, config = {}) say_status 'git add file', '', :green unless options[:quiet] - system "git add #{file}" unless options[:pretend] + system "git add '#{file}'" unless options[:pretend] end def git_status(config = {}) @@ -90,11 +90,11 @@ class Homesick say_status :conflict, "#{destination} exists", :red unless options[:quiet] if options[:force] || shell.file_collision(destination) { source } - system "mv #{source} #{destination}" unless options[:pretend] + system "mv '#{source}' '#{destination}'" unless options[:pretend] end else # this needs some sort of message here. - system "mv #{source} #{destination}" unless options[:pretend] + system "mv '#{source}' '#{destination}'" unless options[:pretend] end end @@ -131,19 +131,19 @@ class Homesick say_status :conflict, "#{destination} exists and points to #{destination.readlink}", :red unless options[:quiet] if options[:force] || shell.file_collision(destination) { source } - system "ln -nsf #{source} #{destination}" unless options[:pretend] + system "ln -nsf '#{source}' '#{destination}'" unless options[:pretend] end end elsif destination.exist? say_status :conflict, "#{destination} exists", :red unless options[:quiet] if options[:force] || shell.file_collision(destination) { source } - system "rm -rf #{destination}" unless options[:pretend] - system "ln -sf #{source} #{destination}" unless options[:pretend] + system "rm -rf '#{destination}'" unless options[:pretend] + system "ln -sf '#{source}' '#{destination}'" unless options[:pretend] end else say_status :symlink, "#{source.expand_path} to #{destination.expand_path}", :green unless options[:quiet] - system "ln -s #{source} #{destination}" unless options[:pretend] + system "ln -s '#{source}' '#{destination}'" unless options[:pretend] end end end diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index e8331f5..7c0d752 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -398,6 +398,19 @@ describe 'homesick' do some_rc_file.readlink.should == tracked_file end + it 'should handle files with parens' do + castle = given_castle('castle_repo') + + some_rc_file = home.file 'Default (Linux).sublime-keymap' + + homesick.track(some_rc_file.to_s, 'castle_repo') + + tracked_file = castle.join('Default (Linux).sublime-keymap') + tracked_file.should exist + + some_rc_file.readlink.should == tracked_file + end + it 'should track a file in nested folder structure' do castle = given_castle('castle_repo') From d3025a34ca3df45546677935198aa93868293db1 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Wed, 18 Sep 2013 09:47:36 -0700 Subject: [PATCH 78/97] Bump version --- homesick.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homesick.gemspec b/homesick.gemspec index eaad5fe..c689f3b 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.9.4" + s.version = "0.9.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] From c8451c7d3f00b3b63bc5fcf05e6c08d8ab4a747b Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Wed, 18 Sep 2013 09:47:46 -0700 Subject: [PATCH 79/97] Regenerate gemspec for version 0.9.4 --- homesick.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homesick.gemspec b/homesick.gemspec index c689f3b..0c5dcfd 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.9.5" + s.version = "0.9.4" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] - s.date = "2013-07-31" + s.date = "2013-09-18" s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n " s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] s.executables = ["homesick"] @@ -39,11 +39,11 @@ Gem::Specification.new do |s| s.homepage = "http://github.com/technicalpickles/homesick" s.licenses = ["MIT"] s.require_paths = ["lib"] - s.rubygems_version = "2.0.3" + s.rubygems_version = "1.8.23" s.summary = "A man's home is his castle. Never leave your dotfiles behind." if s.respond_to? :specification_version then - s.specification_version = 4 + s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0.14.0"]) From f2469ecaaf1e1967293bfce1389bd150ab195d0a Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Wed, 18 Sep 2013 09:48:26 -0700 Subject: [PATCH 80/97] Bump version the right way --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 2916f19..c29d4cf 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem| gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" gem.authors = ["Joshua Nichols", "Yusuke Murata"] - gem.version = "0.9.4" + gem.version = "0.9.5" gem.license = "MIT" # Have dependencies? Add them to Gemfile From 0d48e517f81702e6fcb31d16d04c7fb79dd9e178 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Wed, 18 Sep 2013 09:48:33 -0700 Subject: [PATCH 81/97] Regenerate gemspec for version 0.9.5 --- homesick.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homesick.gemspec b/homesick.gemspec index 0c5dcfd..1d82e25 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.9.4" + s.version = "0.9.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] From 0e6915b8601dd0475f23275d41d57e3468f61c49 Mon Sep 17 00:00:00 2001 From: bcd87 Date: Mon, 23 Sep 2013 20:30:10 +0200 Subject: [PATCH 82/97] Using the homesick clone github shortcut now clones to ~/.homesick/repos/repo/, in stead of ~/.homesick/repos/username/repo/ --- lib/homesick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 7fe7842..4620765 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -34,7 +34,7 @@ class Homesick < Thor ln_s uri, destination elsif uri =~ GITHUB_NAME_REPO_PATTERN - destination = Pathname.new($1) + destination = Pathname.new($1.split("/")[1]) git_clone "https://github.com/#{$1}.git", :destination => destination elsif uri =~ /%r([^%r]*?)(\.git)?\Z/ destination = Pathname.new($1) From e8b471ac97e292b483df4997c0dea55e56b9435c Mon Sep 17 00:00:00 2001 From: bcd87 Date: Mon, 23 Sep 2013 20:58:16 +0200 Subject: [PATCH 83/97] Changed the spec, bundle exec rake works --- spec/homesick_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 7c0d752..29ac597 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -95,7 +95,7 @@ describe 'homesick' do end it 'should clone a github repo' do - homesick.should_receive(:git_clone).with('https://github.com/wfarr/dotfiles.git', :destination => Pathname.new('wfarr/dotfiles')) + homesick.should_receive(:git_clone).with('https://github.com/wfarr/dotfiles.git', :destination => Pathname.new('dotfiles')) homesick.clone 'wfarr/dotfiles' end From 3d47cc44affc9936f70a15825ed45a8729f4086e Mon Sep 17 00:00:00 2001 From: bcd87 Date: Tue, 24 Sep 2013 08:15:56 +0200 Subject: [PATCH 84/97] Rake now passes on Ruby 1.8.7 on my machine --- lib/homesick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 4620765..5f6650e 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -34,7 +34,7 @@ class Homesick < Thor ln_s uri, destination elsif uri =~ GITHUB_NAME_REPO_PATTERN - destination = Pathname.new($1.split("/")[1]) + destination = Pathname.new(uri).basename git_clone "https://github.com/#{$1}.git", :destination => destination elsif uri =~ /%r([^%r]*?)(\.git)?\Z/ destination = Pathname.new($1) From 6ca49327c36808d0e626ec62170d04e0e0b5f897 Mon Sep 17 00:00:00 2001 From: mingkai Date: Fri, 18 Oct 2013 14:35:56 +0200 Subject: [PATCH 85/97] Change github-repo pattern to allow numbers for usernames/repos --- lib/homesick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 5f6650e..467fbc6 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -10,7 +10,7 @@ class Homesick < Thor add_runtime_options! - GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/ + GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z0-9_-]+\/[A-Za-z0-9_-]+)\Z/ SUBDIR_FILENAME = '.homesick_subdir' DEFAULT_CASTLE_NAME = 'dotfiles' From b672b4c52614ae150e2c7ab1dbafe89dd717e43c Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Fri, 18 Oct 2013 07:17:39 -0700 Subject: [PATCH 86/97] Regenerate gemspec for version 0.9.5 --- homesick.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homesick.gemspec b/homesick.gemspec index 1d82e25..c7a466d 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] - s.date = "2013-09-18" + s.date = "2013-10-18" s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n " s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] s.executables = ["homesick"] From 09890e8048366a6c74ca24bc7762e0db33728561 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Fri, 18 Oct 2013 07:18:07 -0700 Subject: [PATCH 87/97] Bump version --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index c29d4cf..05d3de5 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem| gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" gem.authors = ["Joshua Nichols", "Yusuke Murata"] - gem.version = "0.9.5" + gem.version = "0.9.6" gem.license = "MIT" # Have dependencies? Add them to Gemfile From 9656be1dde0e61a8b52f45b4800b51ff381cbe4c Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Fri, 18 Oct 2013 07:18:15 -0700 Subject: [PATCH 88/97] Regenerate gemspec for version 0.9.6 --- homesick.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homesick.gemspec b/homesick.gemspec index c7a466d..45f2dc5 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.9.5" + s.version = "0.9.6" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] From 5108de20c3298d1720d3f2039d2de06180f83773 Mon Sep 17 00:00:00 2001 From: Chris Ball Date: Wed, 30 Oct 2013 14:01:40 -0400 Subject: [PATCH 89/97] Remove symlink shorthand note in README Seems that using `homesick symlink /` after a clone does not locate the directory properly. `homesick symlink ` works in both cases regardless if the shorthand or full git url was used to clone. --- README.markdown | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.markdown b/README.markdown index cbbfb5b..f76d46a 100644 --- a/README.markdown +++ b/README.markdown @@ -27,9 +27,6 @@ With the castle cloned, you can now link its contents into your home dir: homesick symlink pickled-vim -If you use the shorthand syntax for GitHub repositories in your clone, please note you will instead need to run: - - homesick symlink technicalpickles/pickled-vim You can remove symlinks anytime when you don't need them anymore From 545f5fc3e9c7d6e34c8ea54351ae3ca48271afb8 Mon Sep 17 00:00:00 2001 From: bcd Date: Sat, 2 Nov 2013 21:15:51 +0100 Subject: [PATCH 90/97] Git clone now uses config push.default upstream --- lib/homesick/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 076a1b5..51bb4ce 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -11,7 +11,7 @@ class Homesick if ! destination.directory? say_status 'git clone', "#{repo} to #{destination.expand_path}", :green unless options[:quiet] - system "git clone -q --recursive #{repo} #{destination}" unless options[:pretend] + system "git clone -q --config push.default=upstream --recursive #{repo} #{destination}" unless options[:pretend] else say_status :exist, destination.expand_path, :blue unless options[:quiet] end From 0019e8c61cc72eb904524d283e3ec63a64445a6c Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Sat, 2 Nov 2013 16:03:51 -0700 Subject: [PATCH 91/97] Bump version --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 05d3de5..b7c02d3 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem| gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] gem.homepage = "http://github.com/technicalpickles/homesick" gem.authors = ["Joshua Nichols", "Yusuke Murata"] - gem.version = "0.9.6" + gem.version = "0.9.7" gem.license = "MIT" # Have dependencies? Add them to Gemfile From 8d96b2c31fcd7ead18fa18d0059caa2091b6de86 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Sat, 2 Nov 2013 16:03:57 -0700 Subject: [PATCH 92/97] Regenerate gemspec for version 0.9.7 --- homesick.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homesick.gemspec b/homesick.gemspec index 45f2dc5..dd5f45f 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = "homesick" - s.version = "0.9.6" + s.version = "0.9.7" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Joshua Nichols", "Yusuke Murata"] - s.date = "2013-10-18" + s.date = "2013-11-02" s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n " s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"] s.executables = ["homesick"] From 44527850f67a31a0201abf82bcb399a17a2224e2 Mon Sep 17 00:00:00 2001 From: Thilko Richter Date: Thu, 6 Sep 2012 07:38:54 +0200 Subject: [PATCH 93/97] destroy action implemented --- lib/homesick/actions.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 51bb4ce..edbc5f3 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -105,7 +105,6 @@ class Homesick def rm_rf(dir) say_status "rm -rf #{dir}", '', :green unless options[:quiet] - system "rm -rf #{dir}" end def rm_link(target) @@ -119,6 +118,16 @@ class Homesick end end + def rm(file) + say_status "rm #{file}", '', :green unless options[:quiet] + system "rm #{file}" + end + + def rm_r(dir) + say_status "rm -r #{dir}", '', :green unless options[:quiet] + system "rm -r #{dir}" + end + def ln_s(source, destination, config = {}) source = Pathname.new(source) destination = Pathname.new(destination) From 69c38774fed137ff0c80184979b7bff6d96cddac Mon Sep 17 00:00:00 2001 From: thilko Date: Sat, 23 Nov 2013 21:01:53 +0100 Subject: [PATCH 94/97] ask user before start destroying --- lib/homesick.rb | 16 +++++++++------- spec/homesick_spec.rb | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 467fbc6..31119de 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -232,16 +232,18 @@ class Homesick < Thor def destroy(name) check_castle_existance name, "destroy" - inside castle_dir(name) do - files = Pathname.glob('{.*,*}').reject{|a| [".",".."].include?(a.to_s)} - files.each do |path| + if shell.yes?("This will destroy your castle irreversible! Are you sure?") + inside castle_dir(name) do + files = Pathname.glob('{.*,*}').reject{|a| [".",".."].include?(a.to_s)} + files.each do |path| - inside home_dir do - adjusted_path = (home_dir + path).basename - rm adjusted_path + inside home_dir do + adjusted_path = (home_dir + path).basename + rm adjusted_path + end end + rm_r castle_dir(name) end - rm_rf repos_dir + name end end diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 29ac597..d05d735 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -494,6 +494,7 @@ describe 'homesick' do describe "destroy" do it "removes the symlink files" do + expect_any_instance_of(Thor::Shell::Basic).to receive(:yes?).and_return('y') given_castle("stronghold") some_rc_file = home.file '.some_rc_file' homesick.track(some_rc_file.to_s, "stronghold") @@ -503,6 +504,7 @@ describe 'homesick' do end it "deletes the cloned repository" do + expect_any_instance_of(Thor::Shell::Basic).to receive(:yes?).and_return('y') castle = given_castle("stronghold") some_rc_file = home.file '.some_rc_file' homesick.track(some_rc_file.to_s, "stronghold") From 640da07089c3f03e9d39097aab1575e6be7c8d22 Mon Sep 17 00:00:00 2001 From: thilko Date: Sat, 23 Nov 2013 21:06:41 +0100 Subject: [PATCH 95/97] call unlink before removing the castle repo --- lib/homesick.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 31119de..1049dca 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -233,17 +233,8 @@ class Homesick < Thor check_castle_existance name, "destroy" if shell.yes?("This will destroy your castle irreversible! Are you sure?") - inside castle_dir(name) do - files = Pathname.glob('{.*,*}').reject{|a| [".",".."].include?(a.to_s)} - files.each do |path| - - inside home_dir do - adjusted_path = (home_dir + path).basename - rm adjusted_path - end - end - rm_r castle_dir(name) - end + unlink(name) + rm_r castle_dir(name) end end From 243ba70b33b5a570b9d350b7abd6c924599e0f63 Mon Sep 17 00:00:00 2001 From: thilko Date: Sat, 23 Nov 2013 21:54:40 +0100 Subject: [PATCH 96/97] using rm_rf to avoid confirmations on delete --- lib/homesick.rb | 2 +- lib/homesick/actions.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 1049dca..b417c31 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -234,7 +234,7 @@ class Homesick < Thor if shell.yes?("This will destroy your castle irreversible! Are you sure?") unlink(name) - rm_r castle_dir(name) + rm_rf castle_dir(name) end end diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index edbc5f3..35e3633 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -105,6 +105,7 @@ class Homesick def rm_rf(dir) say_status "rm -rf #{dir}", '', :green unless options[:quiet] + system "rm -rf #{dir}" end def rm_link(target) From 357e2f60f259d742811157eaba89d009daf7c405 Mon Sep 17 00:00:00 2001 From: thilko Date: Sat, 23 Nov 2013 22:05:07 +0100 Subject: [PATCH 97/97] delete repo dir --- lib/homesick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index b417c31..0616354 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -234,7 +234,7 @@ class Homesick < Thor if shell.yes?("This will destroy your castle irreversible! Are you sure?") unlink(name) - rm_rf castle_dir(name) + rm_rf repos_dir.join(name) end end