Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
546f078f99 | ||
|
|
b71d75266c | ||
|
|
4a08ce4118 | ||
|
|
c99039da0a | ||
|
|
2dc948d933 | ||
|
|
18e44b663c | ||
|
|
7f3fa403aa | ||
|
|
55d47ea4f5 | ||
|
|
3efee55f03 | ||
|
|
f0c67f9653 | ||
|
|
53ed5697b8 | ||
|
|
94975b49e7 | ||
|
|
95d22951b3 | ||
|
|
c9399064e0 |
@@ -1,3 +1,9 @@
|
|||||||
|
# 0.5.0
|
||||||
|
|
||||||
|
* Fixed listing of castles cloned using `homesick clone <github-user>/<github-repo>` (issue 3)
|
||||||
|
* Added `homesick pull <CASTLE>` for updating castles (thanks Jorge Dias!)
|
||||||
|
* Added a very basic `homesick generate <CASTLE>`
|
||||||
|
|
||||||
# 0.4.1
|
# 0.4.1
|
||||||
|
|
||||||
* Improved error message when a castle's home dir doesn't exist
|
* Improved error message when a castle's home dir doesn't exist
|
||||||
|
|||||||
2
Gemfile
2
Gemfile
@@ -1,7 +1,7 @@
|
|||||||
# Add dependencies required to use your gem here.
|
# Add dependencies required to use your gem here.
|
||||||
group :runtime do
|
group :runtime do
|
||||||
#gem 'bundler', '>= 0.9.5'
|
#gem 'bundler', '>= 0.9.5'
|
||||||
gem "thor"
|
gem "thor", ">= 0.13.6"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add dependencies to develop your gem here.
|
# Add dependencies to develop your gem here.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
A man's home (directory) is his castle, so don't leave home with out it.
|
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.
|
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.
|
||||||
|
|
||||||
We call a repository that is compatible with homesick to be a 'castle'. To act as a castle, a repository must be organized like so:
|
We call a repository that is compatible with homesick to be a 'castle'. To act as a castle, a repository must be organized like so:
|
||||||
|
|
||||||
@@ -25,6 +25,10 @@ With the castle cloned, you can now link its contents into your home dir:
|
|||||||
|
|
||||||
homesick symlink pickled-vim
|
homesick symlink pickled-vim
|
||||||
|
|
||||||
|
If uou use the shorthand syntax for GitHub repositories in your clone, please note you will instead need to run:
|
||||||
|
|
||||||
|
homesick symlink technicalpickles/pickled-vim
|
||||||
|
|
||||||
If you're not sure what castles you have around, you can easily list them:
|
If you're not sure what castles you have around, you can easily list them:
|
||||||
|
|
||||||
homesick list
|
homesick list
|
||||||
|
|||||||
2
Rakefile
2
Rakefile
@@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem|
|
|||||||
gem.email = "josh@technicalpickles.com"
|
gem.email = "josh@technicalpickles.com"
|
||||||
gem.homepage = "http://github.com/technicalpickles/homesick"
|
gem.homepage = "http://github.com/technicalpickles/homesick"
|
||||||
gem.authors = ["Joshua Nichols"]
|
gem.authors = ["Joshua Nichols"]
|
||||||
gem.version = "0.4.1"
|
gem.version = "0.5.2"
|
||||||
# Have dependencies? Add them to Gemfile
|
# Have dependencies? Add them to Gemfile
|
||||||
|
|
||||||
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = %q{homesick}
|
s.name = %q{homesick}
|
||||||
s.version = "0.4.1"
|
s.version = "0.5.2"
|
||||||
|
|
||||||
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"]
|
||||||
s.date = %q{2010-04-02}
|
s.date = %q{2010-07-22}
|
||||||
s.default_executable = %q{homesick}
|
s.default_executable = %q{homesick}
|
||||||
s.description = %q{
|
s.description = %q{
|
||||||
A man’s home (directory) is his castle, so don’t leave home with out it.
|
A man’s home (directory) is his castle, so don’t leave home with out it.
|
||||||
@@ -56,30 +56,9 @@ Gem::Specification.new do |s|
|
|||||||
s.specification_version = 3
|
s.specification_version = 3
|
||||||
|
|
||||||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
||||||
s.add_runtime_dependency(%q<thor>, [">= 0"])
|
|
||||||
s.add_development_dependency(%q<rake>, [">= 0"])
|
|
||||||
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
|
||||||
s.add_development_dependency(%q<bundler>, [">= 0.9.5"])
|
|
||||||
s.add_development_dependency(%q<jeweler>, [">= 1.4.0"])
|
|
||||||
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
||||||
s.add_development_dependency(%q<test-construct>, [">= 0"])
|
|
||||||
else
|
else
|
||||||
s.add_dependency(%q<thor>, [">= 0"])
|
|
||||||
s.add_dependency(%q<rake>, [">= 0"])
|
|
||||||
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
||||||
s.add_dependency(%q<bundler>, [">= 0.9.5"])
|
|
||||||
s.add_dependency(%q<jeweler>, [">= 1.4.0"])
|
|
||||||
s.add_dependency(%q<rcov>, [">= 0"])
|
|
||||||
s.add_dependency(%q<test-construct>, [">= 0"])
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
s.add_dependency(%q<thor>, [">= 0"])
|
|
||||||
s.add_dependency(%q<rake>, [">= 0"])
|
|
||||||
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
||||||
s.add_dependency(%q<bundler>, [">= 0.9.5"])
|
|
||||||
s.add_dependency(%q<jeweler>, [">= 1.4.0"])
|
|
||||||
s.add_dependency(%q<rcov>, [">= 0"])
|
|
||||||
s.add_dependency(%q<test-construct>, [">= 0"])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -44,13 +44,20 @@ class Homesick < Thor
|
|||||||
end
|
end
|
||||||
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
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc "symlink NAME", "Symlinks all dotfiles from the specified castle"
|
desc "symlink NAME", "Symlinks all dotfiles from the specified castle"
|
||||||
def symlink(name)
|
def symlink(name)
|
||||||
unless castle_dir(name).exist?
|
check_castle_existance(name, "symlink")
|
||||||
say_status :error, "Could not symlink #{name}, expected #{castle_dir(name)} exist and contain dotfiles", :red
|
|
||||||
|
|
||||||
exit(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
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)}
|
||||||
@@ -68,13 +75,36 @@ class Homesick < Thor
|
|||||||
|
|
||||||
desc "list", "List cloned castles"
|
desc "list", "List cloned castles"
|
||||||
def list
|
def list
|
||||||
Pathname.glob(repos_dir + "*") do |castle|
|
#require 'ruby-debug'; breakpoint
|
||||||
|
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
|
Dir.chdir castle do # so we can call git config from the right contxt
|
||||||
say_status castle.basename.to_s, `git config remote.origin.url`.chomp, :cyan
|
say_status castle.relative_path_from(repos_dir), `git config remote.origin.url`.chomp, :cyan
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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_repo = castle.basename
|
||||||
|
|
||||||
|
|
||||||
|
empty_directory castle
|
||||||
|
inside castle do
|
||||||
|
git_init
|
||||||
|
if github_user
|
||||||
|
url = "git@github.com:#{github_user}/#{github_repo}.git"
|
||||||
|
git_remote_add 'origin', url
|
||||||
|
end
|
||||||
|
|
||||||
|
empty_directory "home"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def home_dir
|
def home_dir
|
||||||
@@ -85,9 +115,16 @@ class Homesick < Thor
|
|||||||
@repos_dir ||= home_dir.join('.homesick', 'repos').expand_path
|
@repos_dir ||= home_dir.join('.homesick', 'repos').expand_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def castle_dir(name)
|
def castle_dir(name)
|
||||||
repos_dir.join(name, 'home')
|
repos_dir.join(name, 'home')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_castle_existance(name, action)
|
||||||
|
unless castle_dir(name).exist?
|
||||||
|
say_status :error, "Could not #{action} #{name}, expected #{castle_dir(name)} exist and contain dotfiles", :red
|
||||||
|
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,6 +19,31 @@ class Homesick
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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]
|
||||||
|
else
|
||||||
|
say_status 'git init', 'already initialized', :blue unless options[:quiet]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def git_remote_add(name, url)
|
||||||
|
existing_remote = `git config remote.#{name}.url`.chomp
|
||||||
|
existing_remote = nil if existing_remote == ''
|
||||||
|
|
||||||
|
unless existing_remote
|
||||||
|
say_status 'git remote', "add #{name} #{url}" unless options[:quiet]
|
||||||
|
system "git remote add #{name} #{url}" unless options[:pretend]
|
||||||
|
else
|
||||||
|
say_status 'git remote', "#{name} already exists", :blue unless options[:quiet]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def git_submodule_init(config = {})
|
def git_submodule_init(config = {})
|
||||||
say_status 'git submodule', 'init', :green unless options[:quiet]
|
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]
|
||||||
@@ -29,6 +54,11 @@ class Homesick
|
|||||||
system "git submodule --quiet update >/dev/null 2>&1" unless options[:pretend]
|
system "git submodule --quiet update >/dev/null 2>&1" unless options[:pretend]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def git_pull(config = {})
|
||||||
|
say_status 'git pull', '', :green unless options[:quiet]
|
||||||
|
system "git pull --quiet" unless options[:pretend]
|
||||||
|
end
|
||||||
|
|
||||||
def ln_s(source, destination, config = {})
|
def ln_s(source, destination, config = {})
|
||||||
source = Pathname.new(source)
|
source = Pathname.new(source)
|
||||||
destination = Pathname.new(destination)
|
destination = Pathname.new(destination)
|
||||||
|
|||||||
@@ -11,10 +11,11 @@ describe Homesick do
|
|||||||
somewhere.directory('wtf')
|
somewhere.directory('wtf')
|
||||||
wtf = somewhere + 'wtf'
|
wtf = somewhere + 'wtf'
|
||||||
|
|
||||||
@homesick.should_receive(:ln_s).with(wtf.to_s, wtf.basename.to_s)
|
@homesick.should_receive(:ln_s).with(wtf.to_s, wtf.basename)
|
||||||
|
|
||||||
@homesick.clone wtf.to_s
|
@homesick.clone wtf.to_s
|
||||||
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')
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ describe Homesick do
|
|||||||
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 => '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
|
||||||
@@ -51,9 +52,17 @@ describe Homesick do
|
|||||||
system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1"
|
system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1"
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
@homesick.should_receive(:say_status).with("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
|
@homesick.list
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user