29 Commits

Author SHA1 Message Date
muratayusuke
e7d251f8a1 prepare for release 0.8.0 2013-04-06 03:07:11 +09:00
muratayusuke
af950d042a fix merge miss 2013-03-29 01:58:35 +09:00
muratayusuke
23ae908e7d Merge remote-tracking branch 'jbuckner/track-git_add' into local
Conflicts:
	lib/homesick/actions.rb
2013-03-29 01:57:07 +09:00
Yusuke Murata
38ffaca8cc Merge pull request #11 from diasjorge/master
Fixing issues with uris that contain  and submodules
2013-03-28 08:48:18 -07:00
Yusuke Murata
b0bde0eb44 Merge pull request #26 from jbuckner/castle_push
Castle Commit & Push
2013-03-28 08:23:45 -07:00
Yusuke Murata
763cf8aa0a Merge pull request #28 from muratayusuke/enable_recursive_submodule
yeah merged :)
2013-03-28 08:01:24 -07:00
Josh Nichols
9f0d3e0f3c Merge pull request #30 from wjbuys/master
Build with Travis CI
2013-03-26 16:51:46 -07:00
Jacob Buys
937bb65a14 Build with Travis CI 2013-03-18 23:03:44 +02:00
Josh Nichols
376fd88fc9 Fix git_clone to work with github URLs like https://github.com/technicalpickles/dotpickles 2012-12-09 15:33:15 -05:00
muratayusuke
fca23274bf enable recursive submodule 2012-12-06 20:10:18 +09:00
Jason Buckner
27d038512c perform a git add when doing a homesick track 2012-11-24 23:56:12 -08:00
Jason Buckner
d8291edae0 splits up castle commit from castle push for more fine-grained control 2012-11-24 23:18:48 -08:00
Jason Buckner
e6c0ac91cd update documentation for naming consistency 2012-11-24 22:56:17 -08:00
Jason Buckner
74713f8b7c fix homesick pull documentation 2012-11-24 22:36:45 -08:00
Jason Buckner
38a43ba7ff add homesick push to readme, a placeholder test, and removed the all option from git push 2012-11-24 21:24:41 -08:00
Jason Buckner
ca832a38e2 start adding git push functionality 2012-11-24 21:01:37 -08:00
Jacob Buys
d084128297 Add support for Ruby 1.9.
Some dependencies needed updating, and String#start_with? behaves
slightly differently.
2012-05-30 22:54:18 +02:00
Jacob Buys
a141f9cbbd Fix test that fails on 1.9 due to behaviour of String#start_with?
On ruby 1.9, the argument of String#start_with? does not automatically
get coerced into a string. In Homesick#clone, we use start_with? with a
Pathname instance, which now always returns false.
2012-05-30 22:53:00 +02:00
Jacob Buys
e415da13e4 Fix dependencies that break with ruby 1.9.3
Ruby 1.9.3 requires a recent version of RSpec 2, and simplecov
supercedes rcov on ruby 1.9+.
2012-05-30 22:51:40 +02:00
Jacob Buys
10d65abf47 Merge remote-tracking branch 'technicalpickles/master' 2012-05-30 22:39:51 +02:00
Jacob Buys
9ced2921d9 Fix overriding existing symlinks that point to directories. 2011-08-23 22:04:00 +02:00
Jacob Buys
fa99a89bbf Use RSpec's let feature instead of instance variables. 2011-08-21 22:36:50 +02:00
Jacob Buys
f1a02b8afa Added support for linking non-dotfiles. 2011-08-21 22:22:23 +02:00
Jacob Buys
6e4e60fc64 Silence thor output during tests. 2011-08-21 22:19:06 +02:00
Jacob Buys
4f5e77d189 Refactored tests to use given_castle and fewer mocks. 2011-08-21 22:18:55 +02:00
Jacob Buys
4fa7ce416b Made specs for list pass, refactored track to use given_castle. 2011-08-21 22:04:57 +02:00
Jacob Buys
4d9f75b7b0 Extract common setup into spec_helper, add given_castle helper. 2011-08-21 21:54:25 +02:00
Jorge Dias
bfd83f2e87 Merge branch 'master' of git://github.com/technicalpickles/homesick 2011-05-31 14:09:35 +02:00
Jorge
38b40c0f50 Making git repos uri non greedy so it works with uris with / 2010-10-30 21:31:59 +02:00
11 changed files with 235 additions and 128 deletions

4
.travis.yml Normal file
View File

@@ -0,0 +1,4 @@
language: ruby
rvm:
- 1.9.3
- 1.8.7

View File

@@ -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 # 0.7.0
* Fixed double-cloning #14 * Fixed double-cloning #14
* New option for pull command: --all * New option for pull command: --all

View File

@@ -6,10 +6,10 @@ gem "thor", ">= 0.14.0"
# Add dependencies to develop your gem here. # Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc. # Include everything needed to run rake, tests, features, etc.
group :development do group :development do
gem "rake" gem "rake", "~> 0.8.7"
gem "rspec", "~> 2.1.0" gem "rspec", "~> 2.10"
gem "jeweler", ">= 1.6.2" gem "jeweler", ">= 1.6.2"
gem "rcov", ">= 0" gem "rcov", :platforms => :mri_18
gem "simplecov", :platforms => :mri_19
gem "test-construct" gem "test-construct"
gem "ruby-debug"
end end

View File

@@ -1,40 +1,42 @@
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
columnize (0.3.2) diff-lcs (1.1.3)
diff-lcs (1.1.2)
git (1.2.5) git (1.2.5)
jeweler (1.6.2) jeweler (1.8.3)
bundler (~> 1.0) bundler (~> 1.0)
git (>= 1.2.5) git (>= 1.2.5)
rake rake
linecache (0.43) rdoc
rake (0.9.2) json (1.7.3)
rcov (0.9.9) multi_json (1.3.6)
rspec (2.1.0) rake (0.8.7)
rspec-core (~> 2.1.0) rcov (1.0.0)
rspec-expectations (~> 2.1.0) rdoc (3.12)
rspec-mocks (~> 2.1.0) json (~> 1.4)
rspec-core (2.1.0) rspec (2.10.0)
rspec-expectations (2.1.0) rspec-core (~> 2.10.0)
diff-lcs (~> 1.1.2) rspec-expectations (~> 2.10.0)
rspec-mocks (2.1.0) rspec-mocks (~> 2.10.0)
ruby-debug (0.10.4) rspec-core (2.10.1)
columnize (>= 0.1) rspec-expectations (2.10.0)
ruby-debug-base (~> 0.10.4.0) diff-lcs (~> 1.1.3)
ruby-debug-base (0.10.4) rspec-mocks (2.10.1)
linecache (>= 0.3) simplecov (0.6.4)
multi_json (~> 1.0)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
test-construct (1.2.0) test-construct (1.2.0)
thor (0.14.6) thor (0.15.2)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
jeweler (>= 1.6.2) jeweler (>= 1.6.2)
rake rake (~> 0.8.7)
rcov rcov
rspec (~> 2.1.0) rspec (~> 2.10)
ruby-debug simplecov
test-construct test-construct
thor (>= 0.14.0) thor (>= 0.14.0)

View File

@@ -33,6 +33,18 @@ If you're not sure what castles you have around, you can easily list them:
homesick list homesick list
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
Not sure what else homesick has up its sleeve? There's always the built in help: Not sure what else homesick has up its sleeve? There's always the built in help:
homesick help homesick help

View File

@@ -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. 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.homepage = "http://github.com/technicalpickles/homesick"
gem.authors = ["Joshua Nichols"] gem.authors = ["Joshua Nichols", "Yusuke Murata"]
gem.version = "0.7.0" gem.version = "0.8.0"
gem.license = "MIT" gem.license = "MIT"
# Have dependencies? Add them to Gemfile # Have dependencies? Add them to Gemfile

View File

@@ -5,13 +5,13 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "homesick" 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.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Joshua Nichols"] s.authors = ["Joshua Nichols", "Yusuke Murata"]
s.date = "2012-05-28" 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.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.executables = ["homesick"]
s.extra_rdoc_files = [ s.extra_rdoc_files = [
"ChangeLog.markdown", "ChangeLog.markdown",
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
s.files = [ s.files = [
".document", ".document",
".rspec", ".rspec",
".travis.yml",
"ChangeLog.markdown", "ChangeLog.markdown",
"Gemfile", "Gemfile",
"Gemfile.lock", "Gemfile.lock",
@@ -39,7 +40,7 @@ Gem::Specification.new do |s|
s.homepage = "http://github.com/technicalpickles/homesick" s.homepage = "http://github.com/technicalpickles/homesick"
s.licenses = ["MIT"] s.licenses = ["MIT"]
s.require_paths = ["lib"] 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." s.summary = "A man's home is his castle. Never leave your dotfiles behind."
if s.respond_to? :specification_version then 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 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<thor>, [">= 0.14.0"]) s.add_runtime_dependency(%q<thor>, [">= 0.14.0"])
s.add_development_dependency(%q<rake>, [">= 0"]) s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
s.add_development_dependency(%q<rspec>, ["~> 2.1.0"]) s.add_development_dependency(%q<rspec>, ["~> 2.10"])
s.add_development_dependency(%q<jeweler>, [">= 1.6.2"]) s.add_development_dependency(%q<jeweler>, [">= 1.6.2"])
s.add_development_dependency(%q<rcov>, [">= 0"]) s.add_development_dependency(%q<rcov>, [">= 0"])
s.add_development_dependency(%q<simplecov>, [">= 0"])
s.add_development_dependency(%q<test-construct>, [">= 0"]) s.add_development_dependency(%q<test-construct>, [">= 0"])
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
else else
s.add_dependency(%q<thor>, [">= 0.14.0"]) s.add_dependency(%q<thor>, [">= 0.14.0"])
s.add_dependency(%q<rake>, [">= 0"]) s.add_dependency(%q<rake>, ["~> 0.8.7"])
s.add_dependency(%q<rspec>, ["~> 2.1.0"]) s.add_dependency(%q<rspec>, ["~> 2.10"])
s.add_dependency(%q<jeweler>, [">= 1.6.2"]) s.add_dependency(%q<jeweler>, [">= 1.6.2"])
s.add_dependency(%q<rcov>, [">= 0"]) s.add_dependency(%q<rcov>, [">= 0"])
s.add_dependency(%q<simplecov>, [">= 0"])
s.add_dependency(%q<test-construct>, [">= 0"]) s.add_dependency(%q<test-construct>, [">= 0"])
s.add_dependency(%q<ruby-debug>, [">= 0"])
end end
else else
s.add_dependency(%q<thor>, [">= 0.14.0"]) s.add_dependency(%q<thor>, [">= 0.14.0"])
s.add_dependency(%q<rake>, [">= 0"]) s.add_dependency(%q<rake>, ["~> 0.8.7"])
s.add_dependency(%q<rspec>, ["~> 2.1.0"]) s.add_dependency(%q<rspec>, ["~> 2.10"])
s.add_dependency(%q<jeweler>, [">= 1.6.2"]) s.add_dependency(%q<jeweler>, [">= 1.6.2"])
s.add_dependency(%q<rcov>, [">= 0"]) s.add_dependency(%q<rcov>, [">= 0"])
s.add_dependency(%q<simplecov>, [">= 0"])
s.add_dependency(%q<test-construct>, [">= 0"]) s.add_dependency(%q<test-construct>, [">= 0"])
s.add_dependency(%q<ruby-debug>, [">= 0"])
end end
end end

View File

@@ -22,7 +22,7 @@ class Homesick < Thor
destination = nil destination = nil
if File.exist?(uri) if File.exist?(uri)
uri = Pathname.new(uri).expand_path uri = Pathname.new(uri).expand_path
if uri.to_s.start_with?(repos_dir) if uri.to_s.start_with?(repos_dir.to_s)
raise "Castle already cloned to #{uri}" raise "Castle already cloned to #{uri}"
end end
@@ -32,7 +32,7 @@ class Homesick < Thor
elsif uri =~ GITHUB_NAME_REPO_PATTERN elsif uri =~ GITHUB_NAME_REPO_PATTERN
destination = Pathname.new($1) destination = Pathname.new($1)
git_clone "git://github.com/#{$1}.git", :destination => destination git_clone "git://github.com/#{$1}.git", :destination => destination
elsif uri =~ /\/([^\/]*)(\.git)?\Z/ elsif uri =~ /\/([^\/]*?)(\.git)?\Z/
destination = Pathname.new($1) destination = Pathname.new($1)
git_clone uri git_clone uri
elsif uri =~ /[^:]+:([^:]+)(\.git)?\Z/ elsif uri =~ /[^:]+:([^:]+)(\.git)?\Z/
@@ -64,7 +64,7 @@ class Homesick < Thor
end end
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" method_option :all, :type => :boolean, :default => false, :required => false, :desc => "Update all cloned castles"
def pull(name="") def pull(name="")
if options[:all] if options[:all]
@@ -78,12 +78,25 @@ class Homesick < Thor
end end
desc "symlink NAME", "Symlinks all dotfiles from the specified castle" 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
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)
check_castle_existance(name, "symlink") check_castle_existance(name, "symlink")
inside castle_dir(name) do inside castle_dir(name) do
files = Pathname.glob('.*').reject{|a| [".",".."].include?(a.to_s)} files = Pathname.glob('{.*,*}').reject{|a| [".",".."].include?(a.to_s)}
files.each do |path| files.each do |path|
absolute_path = path.expand_path absolute_path = path.expand_path
@@ -111,12 +124,16 @@ class Homesick < Thor
home_path = home_dir + file home_path = home_dir + file
ln_s absolute_path, home_path ln_s absolute_path, home_path
end end
inside castle_path do
git_add absolute_path
end
end end
desc "list", "List cloned castles" desc "list", "List cloned castles"
def list def list
inside_each_castle do |castle| inside_each_castle do |castle|
say_status castle.relative_path_from(repos_dir), `git config remote.origin.url`.chomp, :cyan say_status castle.relative_path_from(repos_dir).to_s, `git config remote.origin.url`.chomp, :cyan
end end
end end
@@ -188,4 +205,18 @@ class Homesick < Thor
git_submodule_update git_submodule_update
end end
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_push
end
end
end end

View File

@@ -4,7 +4,7 @@ class Homesick
def git_clone(repo, config = {}) def git_clone(repo, config = {})
config ||= {} config ||= {}
destination = config[:destination] || begin destination = config[:destination] || begin
repo =~ /([^\/]+)\.git$/ repo =~ /([^\/]+)(?:\.git)?$/
$1 $1
end end
@@ -51,7 +51,7 @@ class Homesick
def git_submodule_update(config = {}) def git_submodule_update(config = {})
say_status 'git submodule', 'update', :green unless options[:quiet] 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 end
def git_pull(config = {}) def git_pull(config = {})
@@ -59,6 +59,21 @@ class Homesick
system "git pull --quiet" unless options[:pretend] system "git pull --quiet" unless options[:pretend]
end 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 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 = {}) def mv(source, destination, config = {})
source = Pathname.new(source) source = Pathname.new(source)
destination = Pathname.new(destination + source.basename) destination = Pathname.new(destination + source.basename)
@@ -86,7 +101,7 @@ class Homesick
say_status :conflict, "#{destination} exists and points to #{destination.readlink}", :red unless options[:quiet] say_status :conflict, "#{destination} exists and points to #{destination.readlink}", :red unless options[:quiet]
if options[:force] || shell.file_collision(destination) { source } if options[:force] || shell.file_collision(destination) { source }
system "ln -sf #{source} #{destination}" unless options[:pretend] system "ln -nsf #{source} #{destination}" unless options[:pretend]
end end
end end
elsif destination.exist? elsif destination.exist?

View File

@@ -1,116 +1,136 @@
require 'spec_helper' require 'spec_helper'
describe "homesick" do describe "homesick" do
before do let(:home) { create_construct }
@homesick = Homesick.new after { home.destroy! }
end
let(:castles) { home.directory(".homesick/repos") }
let(:homesick) { Homesick.new }
before { homesick.stub!(:repos_dir).and_return(castles) }
describe "clone" do describe "clone" do
context "of a file" do context "of a file" do
it "should symlink existing directories" do it "should symlink existing directories" do
somewhere = create_construct somewhere = create_construct
somewhere.directory('wtf') local_repo = somewhere.directory('wtf')
wtf = somewhere + 'wtf'
@homesick.should_receive(:ln_s).with(wtf, wtf.basename) homesick.clone local_repo
@homesick.clone wtf castles.join("wtf").readlink.should == local_repo
end end
context "when it exists in a repo directory" do context "when it exists in a repo directory" do
before do before do
@repos_dir = create_construct existing_castle = given_castle("existing_castle")
@existing_dir = @repos_dir.directory('existing_castle') @existing_dir = existing_castle.parent
@homesick.stub!(:repos_dir).and_return(@repos_dir)
end end
it "should not symlink" do it "should not symlink" do
@homesick.should_not_receive(:git_clone) homesick.should_not_receive(:git_clone)
@homesick.clone @existing_dir.to_s rescue nil homesick.clone @existing_dir.to_s rescue nil
end end
it "should raise an error" do it "should raise an error" do
@existing_castle = @homesick.send(:repos_dir) + 'existing_castle' expect { homesick.clone @existing_dir.to_s }.to raise_error(/already cloned/i)
lambda {
@homesick.clone @existing_castle.to_s
}.should raise_error(/already cloned/i)
end end
end end
end end
it "should clone git repo like git://host/path/to.git" do it "should clone git repo like git://host/path/to.git" do
@homesick.should_receive(:git_clone).with('git://github.com/technicalpickles/pickled-vim.git') homesick.should_receive(:git_clone).with('git://github.com/technicalpickles/pickled-vim.git')
@homesick.clone "git://github.com/technicalpickles/pickled-vim.git" homesick.clone "git://github.com/technicalpickles/pickled-vim.git"
end end
it "should clone git repo like git@host:path/to.git" do it "should clone git repo like git@host:path/to.git" do
@homesick.should_receive(:git_clone).with('git@github.com:technicalpickles/pickled-vim.git') homesick.should_receive(:git_clone).with('git@github.com:technicalpickles/pickled-vim.git')
@homesick.clone 'git@github.com:technicalpickles/pickled-vim.git' homesick.clone 'git@github.com:technicalpickles/pickled-vim.git'
end 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.should_receive(:git_clone).with('http://github.com/technicalpickles/pickled-vim.git')
@homesick.clone 'http://github.com/technicalpickles/pickled-vim.git' homesick.clone 'http://github.com/technicalpickles/pickled-vim.git'
end 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.should_receive(:git_clone).with('http://github.com/technicalpickles/pickled-vim')
@homesick.clone 'http://github.com/technicalpickles/pickled-vim' homesick.clone 'http://github.com/technicalpickles/pickled-vim'
end 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.should_receive(:git_clone).with('gitolite:pickled-vim.git')
@homesick.clone 'gitolite:pickled-vim.git' homesick.clone 'gitolite:pickled-vim.git'
end 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.should_not_receive(:git_clone)
@homesick.clone 'malformed' rescue nil homesick.clone 'malformed' rescue nil
end 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
lambda { expect { homesick.clone 'malformed' }.to raise_error
@homesick.clone 'malformed'
}.should raise_error
end 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.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") }
it "links dotfiles from a castle to the home folder" do
dotfile = castle.file(".some_dotfile")
homesick.symlink("glencairn")
home.join(".some_dotfile").readlink.should == dotfile
end
it "links non-dotfiles from a castle to the home folder" do
dotfile = castle.file("bin")
homesick.symlink("glencairn")
home.join("bin").readlink.should == dotfile
end
context "when forced" do
let(:homesick) { Homesick.new [], :force => true }
it "can override symlinks to directories" do
somewhere_else = create_construct
existing_dotdir_link = home.join(".vim")
FileUtils.ln_s somewhere_else, existing_dotdir_link
dotdir = castle.directory(".vim")
homesick.symlink("glencairn")
existing_dotdir_link.readlink.should == dotdir
end
end end
end end
describe "list" do describe "list" do
it "should say each castle in the castle directory" do
given_castle('zomg')
given_castle('zomg', 'wtf/zomg')
# FIXME only passes in isolation. need to setup data a bit better homesick.should_receive(:say_status).with("zomg", "git://github.com/technicalpickles/zomg.git", :cyan)
xit "should say each castle in the castle directory" do homesick.should_receive(:say_status).with("wtf/zomg", "git://github.com/technicalpickles/zomg.git", :cyan)
@user_dir.directory '.homesick/repos' do |repos_dir|
repos_dir.directory 'zomg' do |zomg|
Dir.chdir do
system "git init >/dev/null 2>&1"
system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1"
end
end
repos_dir.directory 'wtf/zomg' do |zomg| homesick.list
Dir.chdir do
system "git init >/dev/null 2>&1"
system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1"
end
end
end
@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
end end
@@ -124,23 +144,30 @@ describe "homesick" do
end end
describe "commit" do
xit "needs testing"
end
describe "push" do
xit "needs testing"
end
describe "track" do describe "track" do
it "should move the tracked file into the castle" do it "should move the tracked file into the castle" do
some_rc_file = @user_dir.file '.some_rc_file' castle = given_castle('castle_repo')
homesickrepo = @user_dir.directory('.homesick').directory('repos').directory('castle_repo')
castle_path = homesickrepo.directory 'home'
# There is some hideous thing going on with construct; rming the file I'm moving works on this test. some_rc_file = home.file '.some_rc_file'
# Otherwise when track ln_s's it back out, it sees a conflict. Its as if file operations don't
# actually effect this thing, or something.
system "rm #{some_rc_file.to_s}"
Dir.chdir homesickrepo do
system "git init >/dev/null 2>&1"
end
@homesick.should_receive(:mv).with(some_rc_file, castle_path) homesick.track(some_rc_file.to_s, 'castle_repo')
@homesick.should_receive(:ln_s).with(castle_path + some_rc_file.basename, some_rc_file)
@homesick.track(some_rc_file.to_s, 'castle_repo') tracked_file = castle.join(".some_rc_file")
tracked_file.should exist
some_rc_file.readlink.should == tracked_file
end end
end end
end end

View File

@@ -5,15 +5,24 @@ require 'rspec'
require 'rspec/autorun' require 'rspec/autorun'
require 'construct' require 'construct'
Rspec.configure do |config| RSpec.configure do |config|
config.include Construct::Helpers config.include Construct::Helpers
config.before do config.before { ENV['HOME'] = home.to_s }
@user_dir = create_construct
ENV['HOME'] = @user_dir.to_s config.before { silence! }
def silence!
homesick.stub(:say_status)
end end
config.after do def given_castle(name, path=name)
@user_dir.destroy! 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")
end
end
end end
end end