40 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
Josh Nichols
a03e580b36 Regenerate gemspec for version 0.7.0 2012-05-28 15:02:10 -04:00
Josh Nichols
79e982d198 Update jeweler to a non-prelease 2012-05-28 15:01:25 -04:00
Josh Nichols
453bd8fc04 Add link to homeshick. 2012-05-28 15:58:08 -03: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
Josh Nichols
f0c947a50b Version bump to 0.7.0, and catch up on ChangeLog. 2011-05-30 21:22:21 -04:00
Josh Nichols
e19617be2f Don't try to symlink a castle to itself. Fixes #14 2011-05-30 21:04:41 -04:00
Josh Nichols
54697866f5 Add ruby-debug as a development dependency. 2011-05-30 21:03:34 -04:00
Josh Nichols
8c1f0bd05c Add placeholder specs to fill out eventually. 2011-05-30 20:14:04 -04:00
Ilkka Laukkanen
c3999f92b1 Print each castle's name when pulling all castles 2011-04-27 21:51:08 +03:00
Ilkka Laukkanen
c3f6bef152 Don't treat git repos in other repos as castles
Further abstracted locating castles into Homesick.all_castles which globs as
before, but after that rejects any paths that lie in other paths. This way
castles that have submodules don't cause extra output in e.g. list.
2011-04-27 21:39:02 +03:00
Ilkka Laukkanen
c870bfe442 Add --all option to pull to update all castles
Abstracted the logic for doing some operation for all castles into
Homesick.inside_each_castle() which takes a block argument. Homesick.list() is
also reimplemented to use this new method, because that's where the logic was
stolen from. The actual updating is also moved to the private method
update_castle() to make pull() shorter.
2011-04-27 21:01:29 +03:00
Sam Whitlock
06846afa77 Fixed minor spelling error in README 2011-03-02 08:22:21 -05: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 335 additions and 148 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,26 @@
# 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
* pulls each castle, instead of just one
# 0.6.1
* Add a license
# 0.6.0
* Introduce .homesickrc
* Castles can now have a .homesickrc inside them
* On clone, this is eval'd inside the destination directory
* Introduce track command
* Allows easily moving an existing file into a castle, and symlinking it back
# 0.5.0
* Fixed listing of castles cloned using `homesick clone <github-user>/<github-repo>` (issue 3)

10
Gemfile
View File

@@ -6,10 +6,10 @@ 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"
gem "rspec", "~> 2.1.0"
gem "bundler", "~> 1.0.0"
gem "jeweler", ">= 1.5.0.pre6"
gem "rcov", ">= 0"
gem "rake", "~> 0.8.7"
gem "rspec", "~> 2.10"
gem "jeweler", ">= 1.6.2"
gem "rcov", :platforms => :mri_18
gem "simplecov", :platforms => :mri_19
gem "test-construct"
end

View File

@@ -1,33 +1,42 @@
GEM
remote: http://rubygems.org/
specs:
diff-lcs (1.1.2)
diff-lcs (1.1.3)
git (1.2.5)
jeweler (1.5.0.pre6)
bundler (~> 1.0.0)
jeweler (1.8.3)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.7.3)
multi_json (1.3.6)
rake (0.8.7)
rcov (0.9.8)
rspec (2.1.0)
rspec-core (~> 2.1.0)
rspec-expectations (~> 2.1.0)
rspec-mocks (~> 2.1.0)
rspec-core (2.1.0)
rspec-expectations (2.1.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.1.0)
rcov (1.0.0)
rdoc (3.12)
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)
multi_json (~> 1.0)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
test-construct (1.2.0)
thor (0.14.0)
thor (0.15.2)
PLATFORMS
ruby
DEPENDENCIES
bundler (~> 1.0.0)
jeweler (>= 1.5.0.pre6)
rake
jeweler (>= 1.6.2)
rake (~> 0.8.7)
rcov
rspec (~> 2.1.0)
rspec (~> 2.10)
simplecov
test-construct
thor (>= 0.14.0)

View File

@@ -25,7 +25,7 @@ With the castle cloned, you can now link its contents into your home dir:
homesick symlink pickled-vim
If uou use the shorthand syntax for GitHub repositories in your clone, please note you will instead need to run:
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
@@ -33,6 +33,18 @@ If you're not sure what castles you have around, you can easily list them:
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:
homesick help
@@ -45,6 +57,10 @@ Not sure what else homesick has up its sleeve? There's always the built in help:
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.
## Need homesick without the ruby dependency?
Check out [homeshick](https://github.com/andsens/homeshick).
## Copyright
Copyright (c) 2010 Joshua Nichols. See LICENSE for details.

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.
}
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.6.1"
gem.authors = ["Joshua Nichols", "Yusuke Murata"]
gem.version = "0.8.0"
gem.license = "MIT"
# Have dependencies? Add them to Gemfile

View File

@@ -1,23 +1,17 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{homesick}
s.version = "0.6.1"
s.name = "homesick"
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 = %q{2010-11-13}
s.default_executable = %q{homesick}
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}
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", "info@muratayusuke.com"]
s.executables = ["homesick"]
s.extra_rdoc_files = [
"ChangeLog.markdown",
@@ -27,6 +21,7 @@ Gem::Specification.new do |s|
s.files = [
".document",
".rspec",
".travis.yml",
"ChangeLog.markdown",
"Gemfile",
"Gemfile.lock",
@@ -42,44 +37,39 @@ Gem::Specification.new do |s|
"spec/spec.opts",
"spec/spec_helper.rb"
]
s.homepage = %q{http://github.com/technicalpickles/homesick}
s.homepage = "http://github.com/technicalpickles/homesick"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
s.summary = %q{A man's home is his castle. Never leave your dotfiles behind.}
s.test_files = [
"spec/homesick_spec.rb",
"spec/spec_helper.rb"
]
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
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<thor>, [">= 0.14.0"])
s.add_development_dependency(%q<rake>, [">= 0"])
s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_development_dependency(%q<jeweler>, [">= 1.5.0.pre6"])
s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
s.add_development_dependency(%q<rspec>, ["~> 2.10"])
s.add_development_dependency(%q<jeweler>, [">= 1.6.2"])
s.add_development_dependency(%q<rcov>, [">= 0"])
s.add_development_dependency(%q<simplecov>, [">= 0"])
s.add_development_dependency(%q<test-construct>, [">= 0"])
else
s.add_dependency(%q<thor>, [">= 0.14.0"])
s.add_dependency(%q<rake>, [">= 0"])
s.add_dependency(%q<rspec>, ["~> 2.1.0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, [">= 1.5.0.pre6"])
s.add_dependency(%q<rake>, ["~> 0.8.7"])
s.add_dependency(%q<rspec>, ["~> 2.10"])
s.add_dependency(%q<jeweler>, [">= 1.6.2"])
s.add_dependency(%q<rcov>, [">= 0"])
s.add_dependency(%q<simplecov>, [">= 0"])
s.add_dependency(%q<test-construct>, [">= 0"])
end
else
s.add_dependency(%q<thor>, [">= 0.14.0"])
s.add_dependency(%q<rake>, [">= 0"])
s.add_dependency(%q<rspec>, ["~> 2.1.0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, [">= 1.5.0.pre6"])
s.add_dependency(%q<rake>, ["~> 0.8.7"])
s.add_dependency(%q<rspec>, ["~> 2.10"])
s.add_dependency(%q<jeweler>, [">= 1.6.2"])
s.add_dependency(%q<rcov>, [">= 0"])
s.add_dependency(%q<simplecov>, [">= 0"])
s.add_dependency(%q<test-construct>, [">= 0"])
end
end

View File

@@ -21,13 +21,18 @@ class Homesick < Thor
inside repos_dir do
destination = nil
if File.exist?(uri)
destination = Pathname.new(uri).basename
uri = Pathname.new(uri).expand_path
if uri.to_s.start_with?(repos_dir.to_s)
raise "Castle already cloned to #{uri}"
end
destination = uri.basename
ln_s uri, destination
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/
@@ -59,23 +64,39 @@ class Homesick < Thor
end
end
desc "pull NAME", "Update the specified castle"
def pull(name)
check_castle_existance(name, "pull")
inside repos_dir.join(name) do
git_pull
git_submodule_init
git_submodule_update
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 + '/', '') + ':'
update_castle castle
end
else
update_castle name
end
desc "symlink NAME", "Symlinks all dotfiles from the specified castle"
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
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)
check_castle_existance(name, "symlink")
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|
absolute_path = path.expand_path
@@ -103,15 +124,16 @@ 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"
def list
Pathname.glob("#{repos_dir}/**/*/.git") do |git_dir|
castle = git_dir.dirname
Dir.chdir castle do # so we can call git config from the right contxt
say_status castle.relative_path_from(repos_dir), `git config remote.origin.url`.chomp, :cyan
end
inside_each_castle do |castle|
say_status castle.relative_path_from(repos_dir).to_s, `git config remote.origin.url`.chomp, :cyan
end
end
@@ -158,4 +180,43 @@ class Homesick < Thor
end
end
def all_castles
dirs = Pathname.glob("#{repos_dir}/**/*/.git")
# 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) }
end
end
def inside_each_castle(&block)
all_castles.each do |git_dir|
castle = git_dir.dirname
Dir.chdir castle do # so we can call git config from the right contxt
yield castle
end
end
end
def update_castle(castle)
check_castle_existance(castle, "pull")
inside repos_dir.join(castle) do
git_pull
git_submodule_init
git_submodule_update
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

View File

@@ -4,7 +4,7 @@ class Homesick
def git_clone(repo, config = {})
config ||= {}
destination = config[:destination] || begin
repo =~ /([^\/]+)\.git$/
repo =~ /([^\/]+)(?:\.git)?$/
$1
end
@@ -51,7 +51,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 = {})
@@ -59,6 +59,21 @@ 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 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)
@@ -86,7 +101,7 @@ 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 -sf #{source} #{destination}" unless options[:pretend]
system "ln -nsf #{source} #{destination}" unless options[:pretend]
end
end
elsif destination.exist?

View File

@@ -1,113 +1,173 @@
require 'spec_helper'
describe Homesick do
before do
@homesick = Homesick.new
end
describe "homesick" do
let(:home) { create_construct }
after { home.destroy! }
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
somewhere = create_construct
somewhere.directory('wtf')
wtf = somewhere + 'wtf'
local_repo = somewhere.directory('wtf')
@homesick.should_receive(:ln_s).with(wtf.to_s, wtf.basename)
homesick.clone local_repo
@homesick.clone wtf.to_s
castles.join("wtf").readlink.should == local_repo
end
context "when it exists in a repo directory" do
before do
existing_castle = given_castle("existing_castle")
@existing_dir = existing_castle.parent
end
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
expect { homesick.clone @existing_dir.to_s }.to raise_error(/already cloned/i)
end
end
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')
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
@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
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
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
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
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
it "should throw an exception when trying to clone a malformed uri like malformed" do
lambda {
@homesick.clone 'malformed'
}.should raise_error
expect { homesick.clone 'malformed' }.to raise_error
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('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
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
xit "should say each castle in the castle directory" do
@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"
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
repos_dir.directory 'wtf/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
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)
describe "pull" do
@homesick.list
xit "needs testing"
describe "--all" do
xit "needs testing"
end
end
describe "commit" do
xit "needs testing"
end
describe "push" do
xit "needs testing"
end
describe "track" do
it "should move the tracked file into the castle" do
some_rc_file = @user_dir.file '.some_rc_file'
homesickrepo = @user_dir.directory('.homesick').directory('repos').directory('castle_repo')
castle_path = homesickrepo.directory 'home'
castle = given_castle('castle_repo')
# There is some hideous thing going on with construct; rming the file I'm moving works on this test.
# 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
some_rc_file = home.file '.some_rc_file'
@homesick.should_receive(:mv).with(some_rc_file, castle_path)
@homesick.should_receive(:ln_s).with(castle_path + some_rc_file.basename, some_rc_file)
@homesick.track(some_rc_file.to_s, 'castle_repo')
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

View File

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