dotty 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -2
- data/Rakefile +4 -0
- data/lib/dotty/app.rb +8 -6
- data/lib/dotty/repository_actions.rb +3 -4
- data/lib/dotty/version.rb +1 -1
- data/spec/app_spec.rb +20 -19
- data/spec/repository_actions_spec.rb +22 -6
- metadata +2 -2
data/README.md
CHANGED
@@ -24,7 +24,6 @@ You can symlink stuff to sub directories of ~ by using the in+subdir directory n
|
|
24
24
|
dotfiles/in+.ssh/config => ~/.ssh/config
|
25
25
|
dotfiles/in+a/in+b/c => ~/a/b/c
|
26
26
|
|
27
|
-
|
28
27
|
### dotty-symlinks.yml
|
29
28
|
|
30
29
|
If you want more control over the symlinking, you can create a dotty-symlink.yml in the repo root.
|
@@ -62,6 +61,8 @@ The class must be named "DottyRepository".
|
|
62
61
|
* ruby (tested on 1.9.2) and rubygems
|
63
62
|
* git (the git executable must be in your $PATH)
|
64
63
|
|
64
|
+
### Commands
|
65
|
+
|
65
66
|
$ dotty (or dottie if you have graphviz installed which has a dotty executable)
|
66
67
|
|
67
68
|
Tasks:
|
@@ -69,7 +70,7 @@ The class must be named "DottyRepository".
|
|
69
70
|
dotty bootstrap [name] # Bootstrap specified or all dotty repositories. Usually involves making symlinks in your home dir.
|
70
71
|
dotty create <name> <git repo url> # Create a new git repository with the specified git repo url as origin
|
71
72
|
dotty create_profile <profile name> # Create a new profile
|
72
|
-
dotty execute
|
73
|
+
dotty execute <command to run> [repo name] # For specified or all repositories, run given command
|
73
74
|
dotty help [TASK] # Describe available tasks or one specific task
|
74
75
|
dotty implode [name] # Opposite of bootstrap
|
75
76
|
dotty import_repos <yaml_file_location> # Imports dotty repositories from the specified yaml file location (http works)
|
@@ -109,3 +110,4 @@ The class must be named "DottyRepository".
|
|
109
110
|
|
110
111
|
Released under the LGPL License. See the LICENSE file for further details.
|
111
112
|
|
113
|
+
|
data/Rakefile
CHANGED
data/lib/dotty/app.rb
CHANGED
@@ -62,17 +62,18 @@ module Dotty
|
|
62
62
|
end
|
63
63
|
|
64
64
|
desc "update_submodules [name]", "For specified or all repositories, for submodules and pull"
|
65
|
-
method_options :push => false
|
66
|
-
method_options :commit => true
|
67
65
|
method_options :ignoredirty => false
|
66
|
+
method_options %w(commit_message -m) => "Updated submodules"
|
67
|
+
method_options :commit => true
|
68
|
+
method_options :push => true
|
68
69
|
def update_submodules(repo_name=nil)
|
69
70
|
for_specified_or_all_repos(repo_name) do |repo|
|
70
71
|
actions.invoke :update_submodules, [repo], options
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
74
|
-
desc "execute
|
75
|
-
def execute(repo_name=nil
|
75
|
+
desc "execute <command to run> [repo name]", "For specified or all repositories, run given command"
|
76
|
+
def execute(command, repo_name=nil)
|
76
77
|
for_specified_or_all_repos(repo_name) do |repo|
|
77
78
|
inside repo.local_path do
|
78
79
|
run command
|
@@ -130,11 +131,12 @@ module Dotty
|
|
130
131
|
protected
|
131
132
|
|
132
133
|
def find_repo!(name)
|
133
|
-
|
134
|
+
name.downcase!
|
135
|
+
Repository.find(name) || raise(RepositoryNotFoundError, "Repository '#{name}' does not exist")
|
134
136
|
end
|
135
137
|
|
136
138
|
def actions
|
137
|
-
|
139
|
+
RepositoryActions.new
|
138
140
|
end
|
139
141
|
|
140
142
|
def for_specified_or_all_repos(repo_name=nil)
|
@@ -84,10 +84,9 @@ module Dotty
|
|
84
84
|
method_options :ignoredirty => false
|
85
85
|
method_options %w(commit_message -m) => "Updated submodules"
|
86
86
|
method_options :commit => true
|
87
|
-
method_options :push =>
|
87
|
+
method_options :push => true
|
88
88
|
def update_submodules(repo)
|
89
|
-
|
90
|
-
|
89
|
+
say_status "update submodules", repo.name, :blue
|
91
90
|
inside repo.local_path do
|
92
91
|
cmd = []
|
93
92
|
cmd << "git submodule update --init"
|
@@ -99,8 +98,8 @@ module Dotty
|
|
99
98
|
else
|
100
99
|
raise Dotty::Error, "Repository '#{repo.name}' is not in a clean state - cannot commit updated submodules"
|
101
100
|
end
|
101
|
+
options[:push] && cmd << "git push"
|
102
102
|
end
|
103
|
-
options[:push] && cmd << "git push"
|
104
103
|
run cmd.join(" && ")
|
105
104
|
end
|
106
105
|
end
|
data/lib/dotty/version.rb
CHANGED
data/spec/app_spec.rb
CHANGED
@@ -2,6 +2,12 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
|
4
4
|
describe Dotty::App do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@actions = Dotty::RepositoryActions.new
|
8
|
+
subject.stub(:actions).and_return(@actions)
|
9
|
+
end
|
10
|
+
|
5
11
|
describe "#add" do
|
6
12
|
it "should invoke Dotty::Repository.add" do
|
7
13
|
name = 'repo'
|
@@ -53,19 +59,19 @@ describe Dotty::App do
|
|
53
59
|
include_context "two in memory repositories"
|
54
60
|
|
55
61
|
before do
|
56
|
-
|
62
|
+
@actions.stub!(:update)
|
57
63
|
end
|
58
64
|
|
59
65
|
it "should invoke update action with the specified repo" do
|
60
|
-
|
66
|
+
@actions.should_receive(:update).with(@repo1).once
|
61
67
|
suppress_output do
|
62
68
|
subject.update 'repo1name'
|
63
69
|
end
|
64
70
|
end
|
65
71
|
|
66
72
|
it "should invoke update action for all repos if no repo is specified" do
|
67
|
-
|
68
|
-
|
73
|
+
@actions.should_receive(:update).with(@repo1).once
|
74
|
+
@actions.should_receive(:update).with(@repo2).once
|
69
75
|
suppress_output do
|
70
76
|
subject.update
|
71
77
|
end
|
@@ -76,19 +82,19 @@ describe Dotty::App do
|
|
76
82
|
include_context "two in memory repositories"
|
77
83
|
|
78
84
|
before do
|
79
|
-
|
85
|
+
@actions.stub!(:bootstrap)
|
80
86
|
end
|
81
87
|
|
82
88
|
it "should invoke bootstrap action with the specified repo" do
|
83
|
-
|
89
|
+
@actions.should_receive(:bootstrap).with(@repo1).once
|
84
90
|
suppress_output do
|
85
91
|
subject.bootstrap 'repo1name'
|
86
92
|
end
|
87
93
|
end
|
88
94
|
|
89
95
|
it "should invoke bootstrap action for all repos if no repo is specified" do
|
90
|
-
|
91
|
-
|
96
|
+
@actions.should_receive(:bootstrap).with(@repo1).once
|
97
|
+
@actions.should_receive(:bootstrap).with(@repo2).once
|
92
98
|
suppress_output do
|
93
99
|
subject.bootstrap
|
94
100
|
end
|
@@ -99,19 +105,19 @@ describe Dotty::App do
|
|
99
105
|
include_context "two in memory repositories"
|
100
106
|
|
101
107
|
before do
|
102
|
-
|
108
|
+
@actions.stub!(:implode)
|
103
109
|
end
|
104
110
|
|
105
111
|
it "should invoke implode action with the specified repo" do
|
106
|
-
|
112
|
+
@actions.should_receive(:implode).with(@repo1).once
|
107
113
|
suppress_output do
|
108
114
|
subject.implode 'repo1name'
|
109
115
|
end
|
110
116
|
end
|
111
117
|
|
112
118
|
it "should invoke implode action for all repos if no repo is specified" do
|
113
|
-
|
114
|
-
|
119
|
+
@actions.should_receive(:implode).with(@repo1).once
|
120
|
+
@actions.should_receive(:implode).with(@repo2).once
|
115
121
|
suppress_output do
|
116
122
|
subject.implode
|
117
123
|
end
|
@@ -131,7 +137,7 @@ describe Dotty::App do
|
|
131
137
|
end
|
132
138
|
subject.should_receive(:run).once.with('ls')
|
133
139
|
suppress_output do
|
134
|
-
subject.execute @repo1.name
|
140
|
+
subject.execute 'ls', @repo1.name
|
135
141
|
end
|
136
142
|
end
|
137
143
|
|
@@ -169,7 +175,7 @@ describe Dotty::App do
|
|
169
175
|
it "should raise an exception when the given repository does not exist" do
|
170
176
|
expect {
|
171
177
|
subject.send(:find_repo!, 'nonexistant')
|
172
|
-
}.to raise_error Dotty::RepositoryNotFoundError, "
|
178
|
+
}.to raise_error Dotty::RepositoryNotFoundError, "Repository 'nonexistant' does not exist"
|
173
179
|
end
|
174
180
|
end
|
175
181
|
|
@@ -177,11 +183,6 @@ describe Dotty::App do
|
|
177
183
|
it "should return an instance of Dotty::RepositoryActions" do
|
178
184
|
subject.send(:actions).should be_kind_of Dotty::RepositoryActions
|
179
185
|
end
|
180
|
-
|
181
|
-
it "should cache it" do
|
182
|
-
app = subject
|
183
|
-
app.send(:actions).should == app.send(:actions)
|
184
|
-
end
|
185
186
|
end
|
186
187
|
|
187
188
|
describe "#for_specified_or_all_repos" do
|
@@ -148,19 +148,27 @@ describe Dotty::RepositoryActions do
|
|
148
148
|
|
149
149
|
before do
|
150
150
|
# TODO: Find a better way of testing thor invocations with options
|
151
|
-
@default_method_options = { :commit => true, :commit_message => 'Updated submodules' }
|
151
|
+
@default_method_options = { :commit => true, :commit_message => 'Updated submodules', :push => true }
|
152
152
|
@actions.stub!(:options).and_return(@default_method_options)
|
153
153
|
@actions.stub!(:run).and_return("")
|
154
154
|
end
|
155
155
|
|
156
|
-
it "should by default update pull submodules and commit changes to the dotty repository" do
|
157
|
-
@actions.should_receive(:run).once.with("git submodule update --init && git submodule foreach git pull origin master && git commit -am 'Updated submodules'")
|
156
|
+
it "should by default update pull submodules and commit+push changes to the dotty repository" do
|
157
|
+
@actions.should_receive(:run).once.with("git submodule update --init && git submodule foreach git pull origin master && git commit -am 'Updated submodules' && git push")
|
158
158
|
suppress_output do
|
159
159
|
@actions.update_submodules @repo
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
-
it "should
|
163
|
+
it "should use the specified commit message" do
|
164
|
+
@actions.stub!(:options).and_return @default_method_options.merge(:push => true, :commit_message => 'My message')
|
165
|
+
@actions.should_receive(:run).once.with(/git commit -am 'My message'/)
|
166
|
+
suppress_output do
|
167
|
+
@actions.update_submodules @repo
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should not commit or push if commit option is false" do
|
164
172
|
@actions.stub!(:options).and_return @default_method_options.merge(:commit => false)
|
165
173
|
@actions.should_receive(:run).once.with('git submodule update --init && git submodule foreach git pull origin master')
|
166
174
|
suppress_output do
|
@@ -168,14 +176,22 @@ describe Dotty::RepositoryActions do
|
|
168
176
|
end
|
169
177
|
end
|
170
178
|
|
171
|
-
it "should push
|
172
|
-
@actions.stub!(:options).and_return @default_method_options
|
179
|
+
it "should push by default" do
|
180
|
+
@actions.stub!(:options).and_return @default_method_options
|
173
181
|
@actions.should_receive(:run).once.with(/git push/)
|
174
182
|
suppress_output do
|
175
183
|
@actions.update_submodules @repo
|
176
184
|
end
|
177
185
|
end
|
178
186
|
|
187
|
+
it "should not push if push option is false" do
|
188
|
+
@actions.stub!(:options).and_return @default_method_options.merge(:push => false)
|
189
|
+
@actions.should_not_receive(:run).with(/git push/)
|
190
|
+
suppress_output do
|
191
|
+
@actions.update_submodules @repo
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
179
195
|
it "should raise error if the repository is not in a clean state" do
|
180
196
|
@actions.stub!(:run).and_return("?? dirty")
|
181
197
|
expect {
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dotty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Trym Skaar
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-11 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|