homesick 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.markdown +7 -0
- data/Gemfile +3 -0
- data/README.markdown +3 -3
- data/Rakefile +12 -2
- data/bin/homesick +1 -1
- data/homesick.gemspec +2 -3
- data/lib/homesick.rb +58 -32
- data/lib/homesick/actions.rb +19 -9
- data/spec/homesick_spec.rb +136 -99
- data/spec/spec_helper.rb +4 -4
- metadata +4 -5
- data/Gemfile.lock +0 -42
data/ChangeLog.markdown
CHANGED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -77,9 +77,9 @@ and have home like this:
|
|
77
77
|
|-- elisp
|
78
78
|
`-- inits
|
79
79
|
|
80
|
-
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
|
80
|
+
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.
|
81
81
|
|
82
|
-
castle
|
82
|
+
castle/.homesick_subdir
|
83
83
|
|
84
84
|
.config
|
85
85
|
|
@@ -100,7 +100,7 @@ Or `homesick track NESTED_FILE CASTLE` adds a line automatically. For example:
|
|
100
100
|
|
101
101
|
homesick track .emacs.d/elisp castle
|
102
102
|
|
103
|
-
castle
|
103
|
+
castle/.homesick_subdir
|
104
104
|
|
105
105
|
.config
|
106
106
|
.emacs.d
|
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem|
|
|
22
22
|
gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"]
|
23
23
|
gem.homepage = "http://github.com/technicalpickles/homesick"
|
24
24
|
gem.authors = ["Joshua Nichols", "Yusuke Murata"]
|
25
|
-
gem.version = "0.9.
|
25
|
+
gem.version = "0.9.2"
|
26
26
|
gem.license = "MIT"
|
27
27
|
# Have dependencies? Add them to Gemfile
|
28
28
|
|
@@ -41,8 +41,18 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
41
41
|
spec.rcov = true
|
42
42
|
end
|
43
43
|
|
44
|
+
task :rubocop do
|
45
|
+
if RUBY_VERSION >= '1.9.2'
|
46
|
+
system('rubocop')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
task :test do
|
51
|
+
Rake::Task['spec'].execute
|
52
|
+
Rake::Task['rubocop'].execute
|
53
|
+
end
|
44
54
|
|
45
|
-
task :default => :
|
55
|
+
task :default => :test
|
46
56
|
|
47
57
|
require 'rdoc/task'
|
48
58
|
Rake::RDocTask.new do |rdoc|
|
data/bin/homesick
CHANGED
data/homesick.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{homesick}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Joshua Nichols}, %q{Yusuke Murata}]
|
12
|
-
s.date = %q{2013-06-
|
12
|
+
s.date = %q{2013-06-27}
|
13
13
|
s.description = %q{
|
14
14
|
A man's home (directory) is his castle, so don't leave home with out it.
|
15
15
|
|
@@ -29,7 +29,6 @@ Gem::Specification.new do |s|
|
|
29
29
|
".travis.yml",
|
30
30
|
"ChangeLog.markdown",
|
31
31
|
"Gemfile",
|
32
|
-
"Gemfile.lock",
|
33
32
|
"LICENSE",
|
34
33
|
"README.markdown",
|
35
34
|
"Rakefile",
|
data/lib/homesick.rb
CHANGED
@@ -10,14 +10,16 @@ class Homesick < Thor
|
|
10
10
|
add_runtime_options!
|
11
11
|
|
12
12
|
GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/
|
13
|
-
SUBDIR_FILENAME =
|
13
|
+
SUBDIR_FILENAME = '.homesick_subdir'
|
14
14
|
|
15
|
-
|
15
|
+
DEFAULT_CASTLE_NAME = 'dotfiles'
|
16
|
+
|
17
|
+
def initialize(args = [], options = {}, config = {})
|
16
18
|
super
|
17
19
|
self.shell = Homesick::Shell.new
|
18
20
|
end
|
19
21
|
|
20
|
-
desc
|
22
|
+
desc 'clone URI', 'Clone +uri+ as a castle for homesick'
|
21
23
|
def clone(uri)
|
22
24
|
inside repos_dir do
|
23
25
|
destination = nil
|
@@ -33,7 +35,7 @@ class Homesick < Thor
|
|
33
35
|
elsif uri =~ GITHUB_NAME_REPO_PATTERN
|
34
36
|
destination = Pathname.new($1)
|
35
37
|
git_clone "git://github.com/#{$1}.git", :destination => destination
|
36
|
-
elsif uri =~
|
38
|
+
elsif uri =~ /%r([^%r]*?)(\.git)?\Z/
|
37
39
|
destination = Pathname.new($1)
|
38
40
|
git_clone uri
|
39
41
|
elsif uri =~ /[^:]+:([^:]+)(\.git)?\Z/
|
@@ -54,20 +56,20 @@ class Homesick < Thor
|
|
54
56
|
if homesickrc.exist?
|
55
57
|
proceed = shell.yes?("#{uri} has a .homesickrc. Proceed with evaling it? (This could be destructive)")
|
56
58
|
if proceed
|
57
|
-
shell.say_status
|
59
|
+
shell.say_status 'eval', homesickrc
|
58
60
|
inside destination do
|
59
61
|
eval homesickrc.read, binding, homesickrc.expand_path
|
60
62
|
end
|
61
63
|
else
|
62
|
-
shell.say_status
|
64
|
+
shell.say_status 'eval skip', "not evaling #{homesickrc}, #{destination} may need manual configuration", :blue
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
|
-
desc
|
69
|
-
method_option :all, :type => :boolean, :default => false, :required => false, :desc =>
|
70
|
-
def pull(name=
|
70
|
+
desc 'pull CASTLE', 'Update the specified castle'
|
71
|
+
method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles'
|
72
|
+
def pull(name = DEFAULT_CASTLE_NAME)
|
71
73
|
if options[:all]
|
72
74
|
inside_each_castle do |castle|
|
73
75
|
shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':'
|
@@ -79,22 +81,22 @@ class Homesick < Thor
|
|
79
81
|
|
80
82
|
end
|
81
83
|
|
82
|
-
desc
|
83
|
-
def commit(name)
|
84
|
+
desc 'commit CASTLE', "Commit the specified castle's changes"
|
85
|
+
def commit(name = DEFAULT_CASTLE_NAME)
|
84
86
|
commit_castle name
|
85
87
|
|
86
88
|
end
|
87
89
|
|
88
|
-
desc
|
89
|
-
def push(name)
|
90
|
+
desc 'push CASTLE', 'Push the specified castle'
|
91
|
+
def push(name = DEFAULT_CASTLE_NAME)
|
90
92
|
push_castle name
|
91
93
|
|
92
94
|
end
|
93
95
|
|
94
|
-
desc
|
95
|
-
method_option :force, :default => false, :desc =>
|
96
|
-
def symlink(name)
|
97
|
-
check_castle_existance(name,
|
96
|
+
desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle'
|
97
|
+
method_option :force, :default => false, :desc => 'Overwrite existing conflicting symlinks without prompting.'
|
98
|
+
def symlink(name = DEFAULT_CASTLE_NAME)
|
99
|
+
check_castle_existance(name, 'symlink')
|
98
100
|
|
99
101
|
inside castle_dir(name) do
|
100
102
|
subdirs = subdirs(name)
|
@@ -109,8 +111,8 @@ class Homesick < Thor
|
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
112
|
-
desc
|
113
|
-
def track(file, castle)
|
114
|
+
desc 'track FILE CASTLE', 'add a file to a castle'
|
115
|
+
def track(file, castle = DEFAULT_CASTLE_NAME)
|
114
116
|
castle = Pathname.new(castle)
|
115
117
|
file = Pathname.new(file.chomp('/'))
|
116
118
|
check_castle_existance(castle, 'track')
|
@@ -149,24 +151,44 @@ class Homesick < Thor
|
|
149
151
|
end
|
150
152
|
|
151
153
|
# are we tracking something nested? Add the parent dir to the manifest
|
152
|
-
unless relative_dir.eql?(Pathname.new('.'))
|
153
|
-
subdir_add(castle, relative_dir)
|
154
|
-
end
|
154
|
+
subdir_add(castle, relative_dir) unless relative_dir.eql?(Pathname.new('.'))
|
155
155
|
end
|
156
156
|
|
157
|
-
desc
|
157
|
+
desc 'list', 'List cloned castles'
|
158
158
|
def list
|
159
159
|
inside_each_castle do |castle|
|
160
160
|
say_status castle.relative_path_from(repos_dir).to_s, `git config remote.origin.url`.chomp, :cyan
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
-
desc
|
164
|
+
desc 'status CASTLE', 'Shows the git status of a castle'
|
165
|
+
def status(castle = DEFAULT_CASTLE_NAME)
|
166
|
+
check_castle_existance(castle, 'status')
|
167
|
+
inside repos_dir.join(castle) do
|
168
|
+
git_status
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
desc 'diff CASTLE', 'Shows the git diff of uncommitted changes in a castle'
|
173
|
+
def diff(castle = DEFAULT_CASTLE_NAME)
|
174
|
+
check_castle_existance(castle, 'diff')
|
175
|
+
inside repos_dir.join(castle) do
|
176
|
+
git_diff
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
desc 'show_path CASTLE', 'Prints the path of a castle'
|
181
|
+
def show_path(castle = DEFAULT_CASTLE_NAME)
|
182
|
+
check_castle_existance(castle, 'show_path')
|
183
|
+
say repos_dir.join(castle)
|
184
|
+
end
|
185
|
+
|
186
|
+
desc 'generate PATH', 'generate a homesick-ready git repo at PATH'
|
165
187
|
def generate(castle)
|
166
188
|
castle = Pathname.new(castle).expand_path
|
167
189
|
|
168
190
|
github_user = `git config github.user`.chomp
|
169
|
-
github_user = nil if github_user ==
|
191
|
+
github_user = nil if github_user == ''
|
170
192
|
github_repo = castle.basename
|
171
193
|
|
172
194
|
empty_directory castle
|
@@ -177,7 +199,7 @@ class Homesick < Thor
|
|
177
199
|
git_remote_add 'origin', url
|
178
200
|
end
|
179
201
|
|
180
|
-
empty_directory
|
202
|
+
empty_directory 'home'
|
181
203
|
end
|
182
204
|
end
|
183
205
|
|
@@ -208,7 +230,9 @@ class Homesick < Thor
|
|
208
230
|
dirs = Pathname.glob("#{repos_dir}/**/.git", File::FNM_DOTMATCH)
|
209
231
|
# reject paths that lie inside another castle, like git submodules
|
210
232
|
return dirs.reject do |dir|
|
211
|
-
dirs.any?
|
233
|
+
dirs.any? do |other|
|
234
|
+
dir != other && dir.fnmatch(other.parent.join('*').to_s)
|
235
|
+
end
|
212
236
|
end
|
213
237
|
end
|
214
238
|
|
@@ -222,7 +246,7 @@ class Homesick < Thor
|
|
222
246
|
end
|
223
247
|
|
224
248
|
def update_castle(castle)
|
225
|
-
check_castle_existance(castle,
|
249
|
+
check_castle_existance(castle, 'pull')
|
226
250
|
inside repos_dir.join(castle) do
|
227
251
|
git_pull
|
228
252
|
git_submodule_init
|
@@ -231,14 +255,14 @@ class Homesick < Thor
|
|
231
255
|
end
|
232
256
|
|
233
257
|
def commit_castle(castle)
|
234
|
-
check_castle_existance(castle,
|
258
|
+
check_castle_existance(castle, 'commit')
|
235
259
|
inside repos_dir.join(castle) do
|
236
260
|
git_commit_all
|
237
261
|
end
|
238
262
|
end
|
239
263
|
|
240
264
|
def push_castle(castle)
|
241
|
-
check_castle_existance(castle,
|
265
|
+
check_castle_existance(castle, 'push')
|
242
266
|
inside repos_dir.join(castle) do
|
243
267
|
git_push
|
244
268
|
end
|
@@ -262,7 +286,9 @@ class Homesick < Thor
|
|
262
286
|
def subdir_add(castle, path)
|
263
287
|
subdir_filepath = subdir_file(castle)
|
264
288
|
File.open(subdir_filepath, 'a+') do |subdir|
|
265
|
-
subdir.puts path unless subdir.readlines.
|
289
|
+
subdir.puts path unless subdir.readlines.reduce(false) do |memo, line|
|
290
|
+
line.eql?("#{path.to_s}\n") || memo
|
291
|
+
end
|
266
292
|
end
|
267
293
|
|
268
294
|
inside castle_dir(castle) do
|
@@ -308,7 +334,7 @@ class Homesick < Thor
|
|
308
334
|
def symlink_each(castle, basedir, subdirs)
|
309
335
|
absolute_basedir = Pathname.new(basedir).expand_path
|
310
336
|
inside basedir do
|
311
|
-
files = Pathname.glob('{.*,*}').reject{|a| [
|
337
|
+
files = Pathname.glob('{.*,*}').reject{ |a| ['.', '..'].include?(a.to_s) }
|
312
338
|
files.each do |path|
|
313
339
|
absolute_path = path.expand_path
|
314
340
|
castle_home = castle_dir(castle)
|
data/lib/homesick/actions.rb
CHANGED
@@ -16,13 +16,13 @@ class Homesick
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def git_init(path =
|
19
|
+
def git_init(path = '.')
|
20
20
|
path = Pathname.new(path)
|
21
21
|
|
22
22
|
inside path do
|
23
|
-
|
23
|
+
if !path.join('.git').exist?
|
24
24
|
say_status 'git init', '' unless options[:quiet]
|
25
|
-
system
|
25
|
+
system 'git init >/dev/null' unless options[:pretend]
|
26
26
|
else
|
27
27
|
say_status 'git init', 'already initialized', :blue unless options[:quiet]
|
28
28
|
end
|
@@ -33,7 +33,7 @@ class Homesick
|
|
33
33
|
existing_remote = `git config remote.#{name}.url`.chomp
|
34
34
|
existing_remote = nil if existing_remote == ''
|
35
35
|
|
36
|
-
|
36
|
+
if !existing_remote
|
37
37
|
say_status 'git remote', "add #{name} #{url}" unless options[:quiet]
|
38
38
|
system "git remote add #{name} #{url}" unless options[:pretend]
|
39
39
|
else
|
@@ -43,27 +43,27 @@ class Homesick
|
|
43
43
|
|
44
44
|
def git_submodule_init(config = {})
|
45
45
|
say_status 'git submodule', 'init', :green unless options[:quiet]
|
46
|
-
system
|
46
|
+
system 'git submodule --quiet init' unless options[:pretend]
|
47
47
|
end
|
48
48
|
|
49
49
|
def git_submodule_update(config = {})
|
50
50
|
say_status 'git submodule', 'update', :green unless options[:quiet]
|
51
|
-
system
|
51
|
+
system 'git submodule --quiet update --init --recursive >/dev/null 2>&1' unless options[:pretend]
|
52
52
|
end
|
53
53
|
|
54
54
|
def git_pull(config = {})
|
55
55
|
say_status 'git pull', '', :green unless options[:quiet]
|
56
|
-
system
|
56
|
+
system 'git pull --quiet' unless options[:pretend]
|
57
57
|
end
|
58
58
|
|
59
59
|
def git_push(config = {})
|
60
60
|
say_status 'git push', '', :green unless options[:quiet]
|
61
|
-
system
|
61
|
+
system 'git push' unless options[:pretend]
|
62
62
|
end
|
63
63
|
|
64
64
|
def git_commit_all(config = {})
|
65
65
|
say_status 'git commit all', '', :green unless options[:quiet]
|
66
|
-
system
|
66
|
+
system 'git commit -v -a' unless options[:pretend]
|
67
67
|
end
|
68
68
|
|
69
69
|
def git_add(file, config = {})
|
@@ -71,6 +71,16 @@ class Homesick
|
|
71
71
|
system "git add #{file}" unless options[:pretend]
|
72
72
|
end
|
73
73
|
|
74
|
+
def git_status(config = {})
|
75
|
+
say_status 'git status', '', :green unless options[:quiet]
|
76
|
+
system "git status" unless options[:pretend]
|
77
|
+
end
|
78
|
+
|
79
|
+
def git_diff(config = {})
|
80
|
+
say_status 'git diff', '', :green unless options[:quiet]
|
81
|
+
system "git diff" unless options[:pretend]
|
82
|
+
end
|
83
|
+
|
74
84
|
def mv(source, destination, config = {})
|
75
85
|
source = Pathname.new(source)
|
76
86
|
destination = Pathname.new(destination + source.basename)
|
data/spec/homesick_spec.rb
CHANGED
@@ -1,236 +1,258 @@
|
|
1
|
-
require 'spec_helper'
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'homesick' do
|
4
4
|
let(:home) { create_construct }
|
5
5
|
after { home.destroy! }
|
6
6
|
|
7
|
-
let(:castles) { home.directory(
|
7
|
+
let(:castles) { home.directory('.homesick/repos') }
|
8
8
|
|
9
9
|
let(:homesick) { Homesick.new }
|
10
10
|
|
11
11
|
before { homesick.stub!(:repos_dir).and_return(castles) }
|
12
12
|
|
13
|
-
describe
|
14
|
-
context
|
15
|
-
it
|
13
|
+
describe 'clone' do
|
14
|
+
context 'of a file' do
|
15
|
+
it 'should symlink existing directories' do
|
16
16
|
somewhere = create_construct
|
17
17
|
local_repo = somewhere.directory('wtf')
|
18
18
|
|
19
19
|
homesick.clone local_repo
|
20
20
|
|
21
|
-
castles.join(
|
21
|
+
castles.join('wtf').readlink.should == local_repo
|
22
22
|
end
|
23
23
|
|
24
|
-
context
|
24
|
+
context 'when it exists in a repo directory' do
|
25
25
|
before do
|
26
|
-
existing_castle = given_castle(
|
26
|
+
existing_castle = given_castle('existing_castle')
|
27
27
|
@existing_dir = existing_castle.parent
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
30
|
+
it 'should raise an error' do
|
31
31
|
homesick.should_not_receive(:git_clone)
|
32
|
-
|
33
|
-
homesick.clone @existing_dir.to_s rescue nil
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should raise an error" do
|
37
32
|
expect { homesick.clone @existing_dir.to_s }.to raise_error(/already cloned/i)
|
38
33
|
end
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
42
|
-
it
|
43
|
-
bare_repo = File.join(create_construct.to_s,
|
37
|
+
it 'should clone git repo like file:///path/to.git' do
|
38
|
+
bare_repo = File.join(create_construct.to_s, 'dotfiles.git')
|
44
39
|
system "git init --bare #{bare_repo} >/dev/null 2>&1"
|
45
40
|
|
46
41
|
homesick.clone "file://#{bare_repo}"
|
47
42
|
File.directory?(File.join(home.to_s, '.homesick/repos/dotfiles')).should be_true
|
48
43
|
end
|
49
44
|
|
50
|
-
it
|
45
|
+
it 'should clone git repo like git://host/path/to.git' do
|
51
46
|
homesick.should_receive(:git_clone).with('git://github.com/technicalpickles/pickled-vim.git')
|
52
47
|
|
53
|
-
homesick.clone
|
48
|
+
homesick.clone 'git://github.com/technicalpickles/pickled-vim.git'
|
54
49
|
end
|
55
50
|
|
56
|
-
it
|
51
|
+
it 'should clone git repo like git@host:path/to.git' do
|
57
52
|
homesick.should_receive(:git_clone).with('git@github.com:technicalpickles/pickled-vim.git')
|
58
53
|
|
59
54
|
homesick.clone 'git@github.com:technicalpickles/pickled-vim.git'
|
60
55
|
end
|
61
56
|
|
62
|
-
it
|
57
|
+
it 'should clone git repo like http://host/path/to.git' do
|
63
58
|
homesick.should_receive(:git_clone).with('http://github.com/technicalpickles/pickled-vim.git')
|
64
59
|
|
65
60
|
homesick.clone 'http://github.com/technicalpickles/pickled-vim.git'
|
66
61
|
end
|
67
62
|
|
68
|
-
it
|
63
|
+
it 'should clone git repo like http://host/path/to' do
|
69
64
|
homesick.should_receive(:git_clone).with('http://github.com/technicalpickles/pickled-vim')
|
70
65
|
|
71
66
|
homesick.clone 'http://github.com/technicalpickles/pickled-vim'
|
72
67
|
end
|
73
68
|
|
74
|
-
it
|
69
|
+
it 'should clone git repo like host-alias:repos.git' do
|
75
70
|
homesick.should_receive(:git_clone).with('gitolite:pickled-vim.git')
|
76
71
|
|
77
72
|
homesick.clone 'gitolite:pickled-vim.git'
|
78
73
|
end
|
79
74
|
|
80
|
-
it
|
75
|
+
it 'should throw an exception when trying to clone a malformed uri like malformed' do
|
81
76
|
homesick.should_not_receive(:git_clone)
|
82
|
-
|
83
|
-
homesick.clone 'malformed' rescue nil
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should throw an exception when trying to clone a malformed uri like malformed" do
|
87
77
|
expect { homesick.clone 'malformed' }.to raise_error
|
88
78
|
end
|
89
79
|
|
90
|
-
it
|
80
|
+
it 'should clone a github repo' do
|
91
81
|
homesick.should_receive(:git_clone).with('git://github.com/wfarr/dotfiles.git', :destination => Pathname.new('wfarr/dotfiles'))
|
92
82
|
|
93
|
-
homesick.clone
|
83
|
+
homesick.clone 'wfarr/dotfiles'
|
94
84
|
end
|
95
85
|
end
|
96
86
|
|
97
|
-
describe
|
98
|
-
let(:castle) { given_castle(
|
87
|
+
describe 'symlink' do
|
88
|
+
let(:castle) { given_castle('glencairn') }
|
99
89
|
|
100
|
-
it
|
101
|
-
dotfile = castle.file(
|
90
|
+
it 'links dotfiles from a castle to the home folder' do
|
91
|
+
dotfile = castle.file('.some_dotfile')
|
102
92
|
|
103
|
-
homesick.symlink(
|
93
|
+
homesick.symlink('glencairn')
|
104
94
|
|
105
|
-
home.join(
|
95
|
+
home.join('.some_dotfile').readlink.should == dotfile
|
106
96
|
end
|
107
97
|
|
108
|
-
it
|
109
|
-
dotfile = castle.file(
|
98
|
+
it 'links non-dotfiles from a castle to the home folder' do
|
99
|
+
dotfile = castle.file('bin')
|
110
100
|
|
111
|
-
homesick.symlink(
|
101
|
+
homesick.symlink('glencairn')
|
112
102
|
|
113
|
-
home.join(
|
103
|
+
home.join('bin').readlink.should == dotfile
|
114
104
|
end
|
115
105
|
|
116
|
-
context
|
106
|
+
context 'when forced' do
|
117
107
|
let(:homesick) { Homesick.new [], :force => true }
|
118
108
|
|
119
|
-
it
|
109
|
+
it 'can override symlinks to directories' do
|
120
110
|
somewhere_else = create_construct
|
121
|
-
existing_dotdir_link = home.join(
|
111
|
+
existing_dotdir_link = home.join('.vim')
|
122
112
|
FileUtils.ln_s somewhere_else, existing_dotdir_link
|
123
113
|
|
124
|
-
dotdir = castle.directory(
|
114
|
+
dotdir = castle.directory('.vim')
|
125
115
|
|
126
|
-
homesick.symlink(
|
116
|
+
homesick.symlink('glencairn')
|
127
117
|
|
128
118
|
existing_dotdir_link.readlink.should == dotdir
|
129
119
|
end
|
130
120
|
|
131
|
-
it
|
132
|
-
|
133
|
-
existing_dotdir = home.directory(".vim")
|
121
|
+
it 'can override existing directory' do
|
122
|
+
existing_dotdir = home.directory('.vim')
|
134
123
|
|
135
|
-
dotdir = castle.directory(
|
124
|
+
dotdir = castle.directory('.vim')
|
136
125
|
|
137
|
-
homesick.symlink(
|
126
|
+
homesick.symlink('glencairn')
|
138
127
|
|
139
128
|
existing_dotdir.readlink.should == dotdir
|
140
129
|
end
|
141
130
|
end
|
142
131
|
|
143
132
|
context "with '.config' in .homesick_subdir" do
|
144
|
-
let(:castle) { given_castle(
|
145
|
-
it
|
146
|
-
dotdir = castle.directory(
|
147
|
-
dotfile = dotdir.file(
|
133
|
+
let(:castle) { given_castle('glencairn', ['.config']) }
|
134
|
+
it 'can symlink in sub directory' do
|
135
|
+
dotdir = castle.directory('.config')
|
136
|
+
dotfile = dotdir.file('.some_dotfile')
|
148
137
|
|
149
|
-
homesick.symlink(
|
138
|
+
homesick.symlink('glencairn')
|
150
139
|
|
151
|
-
home_dotdir = home.join(
|
152
|
-
home_dotdir.symlink?.should == false
|
153
|
-
home_dotdir.join(
|
140
|
+
home_dotdir = home.join('.config')
|
141
|
+
home_dotdir.symlink?.should be == false
|
142
|
+
home_dotdir.join('.some_dotfile').readlink.should == dotfile
|
154
143
|
end
|
155
144
|
end
|
156
145
|
|
157
146
|
context "with '.config/appA' in .homesick_subdir" do
|
158
|
-
let(:castle) { given_castle(
|
159
|
-
it
|
160
|
-
dotdir = castle.directory(
|
161
|
-
dotfile = dotdir.file(
|
147
|
+
let(:castle) { given_castle('glencairn', ['.config/appA']) }
|
148
|
+
it 'can symlink in nested sub directory' do
|
149
|
+
dotdir = castle.directory('.config').directory('appA')
|
150
|
+
dotfile = dotdir.file('.some_dotfile')
|
162
151
|
|
163
|
-
homesick.symlink(
|
152
|
+
homesick.symlink('glencairn')
|
164
153
|
|
165
|
-
home_dotdir = home.join(
|
166
|
-
home_dotdir.symlink?.should == false
|
167
|
-
home_dotdir.join(
|
154
|
+
home_dotdir = home.join('.config').join('appA')
|
155
|
+
home_dotdir.symlink?.should be == false
|
156
|
+
home_dotdir.join('.some_dotfile').readlink.should == dotfile
|
168
157
|
end
|
169
158
|
end
|
170
159
|
|
171
|
-
context "with '.config' and '.config/
|
172
|
-
let(:castle) { given_castle(
|
173
|
-
it
|
174
|
-
config_dir = castle.directory(
|
175
|
-
config_dotfile = config_dir.file(
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
homesick.symlink(
|
180
|
-
|
181
|
-
home_config_dir = home.join(
|
182
|
-
|
183
|
-
home_config_dir.symlink?.should == false
|
184
|
-
home_config_dir.join(
|
185
|
-
|
186
|
-
|
160
|
+
context "with '.config' and '.config/someapp' in .homesick_subdir" do
|
161
|
+
let(:castle) { given_castle('glencairn', ['.config', '.config/someapp']) }
|
162
|
+
it 'can symlink under both of .config and .config/someapp' do
|
163
|
+
config_dir = castle.directory('.config')
|
164
|
+
config_dotfile = config_dir.file('.some_dotfile')
|
165
|
+
someapp_dir = config_dir.directory('someapp')
|
166
|
+
someapp_dotfile = someapp_dir.file('.some_appfile')
|
167
|
+
|
168
|
+
homesick.symlink('glencairn')
|
169
|
+
|
170
|
+
home_config_dir = home.join('.config')
|
171
|
+
home_someapp_dir = home_config_dir.join('someapp')
|
172
|
+
home_config_dir.symlink?.should be == false
|
173
|
+
home_config_dir.join('.some_dotfile').readlink.should be == config_dotfile
|
174
|
+
home_someapp_dir.symlink?.should be == false
|
175
|
+
home_someapp_dir.join('.some_appfile').readlink.should == someapp_dotfile
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context "when call with no castle name" do
|
180
|
+
let(:castle) { given_castle('dotfiles') }
|
181
|
+
it 'using default castle name: "dotfiles"' do
|
182
|
+
dotfile = castle.file('.some_dotfile')
|
183
|
+
|
184
|
+
homesick.symlink
|
185
|
+
|
186
|
+
home.join('.some_dotfile').readlink.should == dotfile
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
describe
|
192
|
-
it
|
191
|
+
describe 'list' do
|
192
|
+
it 'should say each castle in the castle directory' do
|
193
193
|
given_castle('zomg')
|
194
194
|
given_castle('wtf/zomg')
|
195
195
|
|
196
|
-
homesick.should_receive(:say_status).with(
|
197
|
-
homesick.should_receive(:say_status).with(
|
196
|
+
homesick.should_receive(:say_status).with('zomg', 'git://github.com/technicalpickles/zomg.git', :cyan)
|
197
|
+
homesick.should_receive(:say_status).with('wtf/zomg', 'git://github.com/technicalpickles/zomg.git', :cyan)
|
198
198
|
|
199
199
|
homesick.list
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
203
|
-
describe
|
203
|
+
describe 'status' do
|
204
|
+
|
205
|
+
xit 'needs testing'
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
describe 'diff' do
|
204
210
|
|
205
|
-
xit
|
211
|
+
xit 'needs testing'
|
206
212
|
|
207
|
-
|
208
|
-
|
213
|
+
end
|
214
|
+
|
215
|
+
describe 'show_path' do
|
216
|
+
it 'should say the path of a castle' do
|
217
|
+
castle = given_castle('castle_repo')
|
218
|
+
|
219
|
+
homesick.should_receive(:say).with(castle.dirname)
|
220
|
+
|
221
|
+
homesick.show_path('castle_repo')
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
describe 'pull' do
|
226
|
+
|
227
|
+
xit 'needs testing'
|
228
|
+
|
229
|
+
describe '--all' do
|
230
|
+
xit 'needs testing'
|
209
231
|
end
|
210
232
|
|
211
233
|
end
|
212
234
|
|
213
|
-
describe
|
235
|
+
describe 'commit' do
|
214
236
|
|
215
|
-
xit
|
237
|
+
xit 'needs testing'
|
216
238
|
|
217
239
|
end
|
218
240
|
|
219
|
-
describe
|
241
|
+
describe 'push' do
|
220
242
|
|
221
|
-
xit
|
243
|
+
xit 'needs testing'
|
222
244
|
|
223
245
|
end
|
224
246
|
|
225
|
-
describe
|
226
|
-
it
|
247
|
+
describe 'track' do
|
248
|
+
it 'should move the tracked file into the castle' do
|
227
249
|
castle = given_castle('castle_repo')
|
228
250
|
|
229
251
|
some_rc_file = home.file '.some_rc_file'
|
230
252
|
|
231
253
|
homesick.track(some_rc_file.to_s, 'castle_repo')
|
232
254
|
|
233
|
-
tracked_file = castle.join(
|
255
|
+
tracked_file = castle.join('.some_rc_file')
|
234
256
|
tracked_file.should exist
|
235
257
|
|
236
258
|
some_rc_file.readlink.should == tracked_file
|
@@ -258,7 +280,22 @@ describe "homesick" do
|
|
258
280
|
some_nested_dir.realpath.should == tracked_file.realpath
|
259
281
|
end
|
260
282
|
|
261
|
-
|
283
|
+
context "when call with no castle name" do
|
284
|
+
it 'using default castle name: "dotfiles"' do
|
285
|
+
castle = given_castle('dotfiles')
|
286
|
+
|
287
|
+
some_rc_file = home.file '.some_rc_file'
|
288
|
+
|
289
|
+
homesick.track(some_rc_file.to_s)
|
290
|
+
|
291
|
+
tracked_file = castle.join('.some_rc_file')
|
292
|
+
tracked_file.should exist
|
293
|
+
|
294
|
+
some_rc_file.readlink.should == tracked_file
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
describe 'subdir_file' do
|
262
299
|
|
263
300
|
it 'should add the nested files parent to the subdir_file' do
|
264
301
|
castle = given_castle('castle_repo')
|
data/spec/spec_helper.rb
CHANGED
@@ -16,19 +16,19 @@ RSpec.configure do |config|
|
|
16
16
|
homesick.stub(:say_status)
|
17
17
|
end
|
18
18
|
|
19
|
-
def given_castle(path, subdirs=[])
|
19
|
+
def given_castle(path, subdirs = [])
|
20
20
|
name = Pathname.new(path).basename
|
21
21
|
castles.directory(path) do |castle|
|
22
22
|
Dir.chdir(castle) do
|
23
|
-
system
|
23
|
+
system 'git init >/dev/null 2>&1'
|
24
24
|
system "git remote add origin git://github.com/technicalpickles/#{name}.git >/dev/null 2>&1"
|
25
|
-
if subdirs
|
25
|
+
if subdirs
|
26
26
|
subdir_file = castle.join(Homesick::SUBDIR_FILENAME)
|
27
27
|
subdirs.each do |subdir|
|
28
28
|
system "echo #{subdir} >> #{subdir_file}"
|
29
29
|
end
|
30
30
|
end
|
31
|
-
return castle.directory(
|
31
|
+
return castle.directory('home')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: homesick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 2
|
10
|
+
version: 0.9.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Nichols
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-06-
|
19
|
+
date: 2013-06-27 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
prerelease: false
|
@@ -141,7 +141,6 @@ files:
|
|
141
141
|
- .travis.yml
|
142
142
|
- ChangeLog.markdown
|
143
143
|
- Gemfile
|
144
|
-
- Gemfile.lock
|
145
144
|
- LICENSE
|
146
145
|
- README.markdown
|
147
146
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.2.4)
|
5
|
-
git (1.2.5)
|
6
|
-
jeweler (1.8.4)
|
7
|
-
bundler (~> 1.0)
|
8
|
-
git (>= 1.2.5)
|
9
|
-
rake
|
10
|
-
rdoc
|
11
|
-
json (1.8.0)
|
12
|
-
multi_json (1.7.3)
|
13
|
-
rake (10.0.4)
|
14
|
-
rcov (1.0.0)
|
15
|
-
rdoc (4.0.1)
|
16
|
-
json (~> 1.4)
|
17
|
-
rspec (2.13.0)
|
18
|
-
rspec-core (~> 2.13.0)
|
19
|
-
rspec-expectations (~> 2.13.0)
|
20
|
-
rspec-mocks (~> 2.13.0)
|
21
|
-
rspec-core (2.13.1)
|
22
|
-
rspec-expectations (2.13.0)
|
23
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
24
|
-
rspec-mocks (2.13.1)
|
25
|
-
simplecov (0.7.1)
|
26
|
-
multi_json (~> 1.0)
|
27
|
-
simplecov-html (~> 0.7.1)
|
28
|
-
simplecov-html (0.7.1)
|
29
|
-
test-construct (1.2.0)
|
30
|
-
thor (0.18.1)
|
31
|
-
|
32
|
-
PLATFORMS
|
33
|
-
ruby
|
34
|
-
|
35
|
-
DEPENDENCIES
|
36
|
-
jeweler (>= 1.6.2)
|
37
|
-
rake (>= 0.8.7)
|
38
|
-
rcov
|
39
|
-
rspec (~> 2.10)
|
40
|
-
simplecov
|
41
|
-
test-construct
|
42
|
-
thor (>= 0.14.0)
|