homesick 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,16 @@
1
- # 3.0.0
1
+ # 0.4.0
2
+
3
+ * `homesick clone` can now take a path to a directory on the filesystem, which will be symlinked into place
4
+ * `homesick clone` now tries to `git submodule init` and `git submodule update` if git submodules are defined for a cloned repo
5
+ * Fixed missing dependency on thor and others
6
+ * Use HOME environment variable for where to store files, instead of assuming ~
7
+
8
+ # 0.3.0
2
9
 
3
10
  * Renamed 'link' to 'symlink'
4
11
  * Fixed conflict resolution when symlink destination exists and is a normal file
5
12
 
6
- # 2.0.0
13
+ # 0.2.0
7
14
 
8
15
  * Better support for recognizing git urls (thanks jacobat!)
9
16
  * if it looks like a github user/repo, do that
data/Gemfile CHANGED
@@ -12,5 +12,5 @@ group :development do
12
12
  gem "bundler", ">= 0.9.5"
13
13
  gem "jeweler", ">= 1.4.0"
14
14
  gem "rcov", ">= 0"
15
- gem "devver-construct"
15
+ gem "test-construct"
16
16
  end
data/Rakefile CHANGED
@@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem|
22
22
  gem.email = "josh@technicalpickles.com"
23
23
  gem.homepage = "http://github.com/technicalpickles/homesick"
24
24
  gem.authors = ["Joshua Nichols"]
25
- gem.version = "0.3.0"
25
+ gem.version = "0.4.0"
26
26
  # Have dependencies? Add them to Gemfile
27
27
 
28
28
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{homesick}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joshua Nichols"]
@@ -21,25 +21,25 @@ Gem::Specification.new do |s|
21
21
  s.executables = ["homesick"]
22
22
  s.extra_rdoc_files = [
23
23
  "ChangeLog.markdown",
24
- "LICENSE",
25
- "README.markdown"
24
+ "LICENSE",
25
+ "README.markdown"
26
26
  ]
27
27
  s.files = [
28
28
  ".document",
29
- ".gitignore",
30
- "ChangeLog.markdown",
31
- "Gemfile",
32
- "LICENSE",
33
- "README.markdown",
34
- "Rakefile",
35
- "bin/homesick",
36
- "homesick.gemspec",
37
- "lib/homesick.rb",
38
- "lib/homesick/actions.rb",
39
- "lib/homesick/shell.rb",
40
- "spec/homesick/homesick_spec.rb",
41
- "spec/spec.opts",
42
- "spec/spec_helper.rb"
29
+ ".gitignore",
30
+ "ChangeLog.markdown",
31
+ "Gemfile",
32
+ "LICENSE",
33
+ "README.markdown",
34
+ "Rakefile",
35
+ "bin/homesick",
36
+ "homesick.gemspec",
37
+ "lib/homesick.rb",
38
+ "lib/homesick/actions.rb",
39
+ "lib/homesick/shell.rb",
40
+ "spec/homesick_spec.rb",
41
+ "spec/spec.opts",
42
+ "spec/spec_helper.rb"
43
43
  ]
44
44
  s.homepage = %q{http://github.com/technicalpickles/homesick}
45
45
  s.rdoc_options = ["--charset=UTF-8"]
@@ -47,8 +47,8 @@ Gem::Specification.new do |s|
47
47
  s.rubygems_version = %q{1.3.6}
48
48
  s.summary = %q{A man's home is his castle. Never leave your dotfiles behind.}
49
49
  s.test_files = [
50
- "spec/homesick/homesick_spec.rb",
51
- "spec/spec_helper.rb"
50
+ "spec/homesick_spec.rb",
51
+ "spec/spec_helper.rb"
52
52
  ]
53
53
 
54
54
  if s.respond_to? :specification_version then
@@ -56,9 +56,30 @@ Gem::Specification.new do |s|
56
56
  s.specification_version = 3
57
57
 
58
58
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
59
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
60
+ s.add_development_dependency(%q<rake>, [">= 0"])
61
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
62
+ s.add_development_dependency(%q<bundler>, [">= 0.9.5"])
63
+ s.add_development_dependency(%q<jeweler>, [">= 1.4.0"])
64
+ s.add_development_dependency(%q<rcov>, [">= 0"])
65
+ s.add_development_dependency(%q<test-construct>, [">= 0"])
59
66
  else
67
+ s.add_dependency(%q<thor>, [">= 0"])
68
+ s.add_dependency(%q<rake>, [">= 0"])
69
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
70
+ s.add_dependency(%q<bundler>, [">= 0.9.5"])
71
+ s.add_dependency(%q<jeweler>, [">= 1.4.0"])
72
+ s.add_dependency(%q<rcov>, [">= 0"])
73
+ s.add_dependency(%q<test-construct>, [">= 0"])
60
74
  end
61
75
  else
76
+ s.add_dependency(%q<thor>, [">= 0"])
77
+ s.add_dependency(%q<rake>, [">= 0"])
78
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
79
+ s.add_dependency(%q<bundler>, [">= 0.9.5"])
80
+ s.add_dependency(%q<jeweler>, [">= 1.4.0"])
81
+ s.add_dependency(%q<rcov>, [">= 0"])
82
+ s.add_dependency(%q<test-construct>, [">= 0"])
62
83
  end
63
84
  end
64
85
 
@@ -9,7 +9,7 @@ class Homesick < Thor
9
9
 
10
10
  add_runtime_options!
11
11
 
12
- GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+)\/([A-Za-z_-]+)\Z/
12
+ GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/
13
13
 
14
14
  def initialize(args=[], options={}, config={})
15
15
  super
@@ -18,13 +18,29 @@ class Homesick < Thor
18
18
 
19
19
  desc "clone URI", "Clone +uri+ as a castle for homesick"
20
20
  def clone(uri)
21
- empty_directory repos_dir, :verbose => false
22
21
  inside repos_dir do
23
- if uri =~ GITHUB_NAME_REPO_PATTERN
24
- git_clone "git://github.com/#{$1}/#{$2}.git", :destination => "#{$1}_#{$2}"
22
+ destination = nil
23
+ if File.exist?(uri)
24
+ destination = Pathname.new(uri).basename
25
+
26
+ ln_s uri, destination
27
+ elsif uri =~ GITHUB_NAME_REPO_PATTERN
28
+ destination = Pathname.new($1)
29
+ git_clone "git://github.com/#{$1}.git", :destination => destination
25
30
  else
31
+ if uri =~ /\/([^\/]*).git\Z/
32
+ destination = Pathname.new($1)
33
+ end
34
+
26
35
  git_clone uri
27
36
  end
37
+
38
+ if destination.join('.gitmodules').exist?
39
+ inside destination do
40
+ git_submodule_init
41
+ git_submodule_update
42
+ end
43
+ end
28
44
  end
29
45
  end
30
46
 
@@ -41,8 +57,8 @@ class Homesick < Thor
41
57
  files.each do |path|
42
58
  absolute_path = path.expand_path
43
59
 
44
- inside user_dir do
45
- adjusted_path = (user_dir + path).basename
60
+ inside home_dir do
61
+ adjusted_path = (home_dir + path).basename
46
62
 
47
63
  ln_s absolute_path, adjusted_path
48
64
  end
@@ -54,37 +70,24 @@ class Homesick < Thor
54
70
 
55
71
  desc "list", "List cloned castles"
56
72
  def list
57
- inside repos_dir do
58
- Pathname.glob('*') do |home|
59
- inside home do
60
- say_status home, `git config remote.origin.url`, :cyan
61
- end
73
+ Pathname.glob(repos_dir + "*") do |castle|
74
+ Dir.chdir castle do # so we can call git config from the right contxt
75
+ say_status castle.basename.to_s, `git config remote.origin.url`.chomp, :cyan
62
76
  end
63
77
  end
64
78
  end
65
79
 
80
+ protected
66
81
 
67
- no_tasks do
68
- # class method, so it's convenient to stub out during tests
69
- def self.user_dir
70
- @user_dir ||= Pathname.new('~').expand_path
71
- end
72
-
73
- def self.repos_dir
74
- @repos_dir ||= Pathname.new('~/.homesick/repos').expand_path
75
- end
76
-
77
- def repos_dir
78
- self.class.repos_dir
79
- end
82
+ def home_dir
83
+ @home_dir ||= Pathname.new(ENV['HOME'] || '~').expand_path
80
84
  end
81
85
 
82
- protected
83
-
84
- def user_dir
85
- self.class.user_dir
86
+ def repos_dir
87
+ @repos_dir ||= home_dir.join('.homesick', 'repos').expand_path
86
88
  end
87
89
 
90
+
88
91
  def castle_dir(name)
89
92
  repos_dir.join(name, 'home')
90
93
  end
@@ -5,10 +5,11 @@ class Homesick
5
5
  config ||= {}
6
6
  destination = config[:destination] || begin
7
7
  repo =~ /([^\/]+)\.git$/
8
- $1
8
+ $1
9
9
  end
10
10
 
11
11
  destination = Pathname.new(destination) unless destination.kind_of?(Pathname)
12
+ FileUtils.mkdir_p destination.dirname
12
13
 
13
14
  if ! destination.directory?
14
15
  say_status 'git clone', "#{repo} to #{destination.expand_path}", :green unless options[:quiet]
@@ -18,7 +19,18 @@ class Homesick
18
19
  end
19
20
  end
20
21
 
22
+ def git_submodule_init(config = {})
23
+ say_status 'git submodule', 'init', :green unless options[:quiet]
24
+ system "git submodule --quiet init" unless options[:pretend]
25
+ end
26
+
27
+ def git_submodule_update(config = {})
28
+ say_status 'git submodule', 'update', :green unless options[:quiet]
29
+ system "git submodule --quiet update >/dev/null 2>&1" unless options[:pretend]
30
+ end
31
+
21
32
  def ln_s(source, destination, config = {})
33
+ source = Pathname.new(source)
22
34
  destination = Pathname.new(destination)
23
35
 
24
36
  if destination.symlink?
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe Homesick do
4
+ before do
5
+ @homesick = Homesick.new
6
+ end
7
+
8
+ describe "clone" do
9
+ it "should symlink existing directories" do
10
+ somewhere = create_construct
11
+ somewhere.directory('wtf')
12
+ wtf = somewhere + 'wtf'
13
+
14
+ @homesick.should_receive(:ln_s).with(wtf.to_s, wtf.basename.to_s)
15
+
16
+ @homesick.clone wtf.to_s
17
+ end
18
+ it "should clone git repo like git://host/path/to.git" do
19
+ @homesick.should_receive(:git_clone).with('git://github.com/technicalpickles/pickled-vim.git')
20
+
21
+ @homesick.clone "git://github.com/technicalpickles/pickled-vim.git"
22
+ end
23
+
24
+ it "should clone git repo like git@host:path/to.git" do
25
+ @homesick.should_receive(:git_clone).with('git@github.com:technicalpickles/pickled-vim.git')
26
+
27
+ @homesick.clone 'git@github.com:technicalpickles/pickled-vim.git'
28
+ end
29
+
30
+ it "should clone git repo like http://host/path/to.git" do
31
+ @homesick.should_receive(:git_clone).with('http://github.com/technicalpickles/pickled-vim.git')
32
+
33
+ @homesick.clone 'http://github.com/technicalpickles/pickled-vim.git'
34
+ end
35
+
36
+ it "should clone a github repo" do
37
+ @homesick.should_receive(:git_clone).with('git://github.com/wfarr/dotfiles.git', :destination => 'wfarr/dotfiles')
38
+
39
+ @homesick.clone "wfarr/dotfiles"
40
+ end
41
+ end
42
+
43
+ describe "list" do
44
+
45
+ # FIXME only passes in isolation. need to setup data a bit better
46
+ xit "should say each castle in the castle directory" do
47
+ @user_dir.directory '.homesick/repos' do |repos_dir|
48
+ repos_dir.directory 'zomg' do |zomg|
49
+ Dir.chdir do
50
+ system "git init >/dev/null 2>&1"
51
+ system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1"
52
+ end
53
+ end
54
+ end
55
+
56
+ @homesick.should_receive(:say_status).with("zomg", "git://github.com/technicalpickles/zomg.git", :cyan)
57
+
58
+ @homesick.list
59
+ end
60
+
61
+ end
62
+ end
@@ -10,7 +10,7 @@ Spec::Runner.configure do |config|
10
10
 
11
11
  config.before do
12
12
  @user_dir = create_construct
13
- Homesick.stub!(:user_dir).and_return(@user_dir)
13
+ ENV['HOME'] = @user_dir.to_s
14
14
  end
15
15
 
16
16
  config.after do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
7
+ - 4
8
8
  - 0
9
- version: 0.3.0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joshua Nichols
@@ -16,8 +16,97 @@ cert_chain: []
16
16
 
17
17
  date: 2010-04-01 00:00:00 -04:00
18
18
  default_executable: homesick
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: thor
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: rake
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :development
43
+ version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: rspec
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 1
53
+ - 2
54
+ - 9
55
+ version: 1.2.9
56
+ type: :development
57
+ version_requirements: *id003
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ prerelease: false
61
+ requirement: &id004 !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
67
+ - 9
68
+ - 5
69
+ version: 0.9.5
70
+ type: :development
71
+ version_requirements: *id004
72
+ - !ruby/object:Gem::Dependency
73
+ name: jeweler
74
+ prerelease: false
75
+ requirement: &id005 !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ segments:
80
+ - 1
81
+ - 4
82
+ - 0
83
+ version: 1.4.0
84
+ type: :development
85
+ version_requirements: *id005
86
+ - !ruby/object:Gem::Dependency
87
+ name: rcov
88
+ prerelease: false
89
+ requirement: &id006 !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ type: :development
97
+ version_requirements: *id006
98
+ - !ruby/object:Gem::Dependency
99
+ name: test-construct
100
+ prerelease: false
101
+ requirement: &id007 !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ segments:
106
+ - 0
107
+ version: "0"
108
+ type: :development
109
+ version_requirements: *id007
21
110
  description: "\n A man\xE2\x80\x99s home (directory) is his castle, so don\xE2\x80\x99t 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 "
22
111
  email: josh@technicalpickles.com
23
112
  executables:
@@ -41,7 +130,7 @@ files:
41
130
  - lib/homesick.rb
42
131
  - lib/homesick/actions.rb
43
132
  - lib/homesick/shell.rb
44
- - spec/homesick/homesick_spec.rb
133
+ - spec/homesick_spec.rb
45
134
  - spec/spec.opts
46
135
  - spec/spec_helper.rb
47
136
  has_rdoc: true
@@ -75,5 +164,5 @@ signing_key:
75
164
  specification_version: 3
76
165
  summary: A man's home is his castle. Never leave your dotfiles behind.
77
166
  test_files:
78
- - spec/homesick/homesick_spec.rb
167
+ - spec/homesick_spec.rb
79
168
  - spec/spec_helper.rb
@@ -1,19 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe "Homesick" do
4
- before do
5
- @homesick = Homesick.new
6
- end
7
-
8
- it "should clone any git repo" do
9
- @homesick.should_receive(:git_clone).with('git://github.com/technicalpickles/pickled-vim.git')
10
-
11
- @homesick.clone "git://github.com/technicalpickles/pickled-vim.git"
12
- end
13
-
14
- it "should clone a github repo" do
15
- @homesick.should_receive(:git_clone).with('git://github.com/wfarr/dotfiles.git', 'wfarr_dotfiles')
16
-
17
- @homesick.clone "wfarr/dotfiles"
18
- end
19
- end