yggdrasil 0.0.11 → 0.0.12
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.
- data/lib/yggdrasil/add.rb +6 -2
- data/lib/yggdrasil/check.rb +32 -33
- data/lib/yggdrasil/cleanup.rb +3 -3
- data/lib/yggdrasil/commit.rb +11 -7
- data/lib/yggdrasil/diff.rb +22 -9
- data/lib/yggdrasil/help.rb +9 -38
- data/lib/yggdrasil/init.rb +3 -3
- data/lib/yggdrasil/list.rb +8 -9
- data/lib/yggdrasil/log.rb +20 -21
- data/lib/yggdrasil/update.rb +26 -42
- data/lib/yggdrasil/version.rb +1 -1
- data/lib/yggdrasil.rb +30 -8
- data/lib/yggdrasil_common.rb +13 -4
- data/lib/yggdrasil_server/init.rb +5 -5
- data/lib/yggdrasil_server/results.rb +3 -3
- data/lib/yggdrasil_server/server.rb +3 -3
- data/spec/check_spec.rb +79 -10
- data/spec/commit_spec.rb +4 -4
- data/spec/help_spec.rb +8 -30
- data/spec/list_spec.rb +29 -7
- data/spec/log_spec.rb +4 -0
- data/spec/revert_spec.rb +34 -14
- data/spec/server_results_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +4 -8
- data/lib/yggdrasil/revert.rb +0 -53
- data/lib/yggdrasil/status.rb +0 -28
- data/spec/status_spec.rb +0 -62
@@ -1,9 +1,9 @@
|
|
1
1
|
class YggdrasilServer
|
2
2
|
|
3
3
|
def server(args)
|
4
|
-
|
5
|
-
if
|
6
|
-
error "invalid arguments: #{
|
4
|
+
parse_options(args, {'--debug'=>:debug?})
|
5
|
+
if @arg_options.size+@arg_paths.size != 0
|
6
|
+
error "invalid arguments: #{(@arg_options+@arg_paths).join(', ')}"
|
7
7
|
end
|
8
8
|
|
9
9
|
puts "Start: yggdrasil server (port:#@port)"
|
data/spec/check_spec.rb
CHANGED
@@ -6,6 +6,76 @@ describe Yggdrasil, 'check' do
|
|
6
6
|
puts '-------- check'
|
7
7
|
prepare_environment
|
8
8
|
init_yggdrasil
|
9
|
+
`rm -f /tmp/yggdrasil-test/A`
|
10
|
+
`echo foo >> /tmp/yggdrasil-test/B`
|
11
|
+
`echo bar > /tmp/yggdrasil-test/C`
|
12
|
+
Yggdrasil.command(%w{add /tmp/yggdrasil-test/C})
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should display check result by "check"' do
|
16
|
+
cmd = %w{check --username hoge --password foo}
|
17
|
+
out = catch_out {Yggdrasil.command(cmd, "n\n")}
|
18
|
+
out.should == <<"EOS"
|
19
|
+
|
20
|
+
0:A tmp/yggdrasil-test/C
|
21
|
+
1:D tmp/yggdrasil-test/A
|
22
|
+
2:M tmp/yggdrasil-test/B
|
23
|
+
OK? [Y|n|<num to diff>]:
|
24
|
+
EOS
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should display check result by "c"' do
|
28
|
+
cmd = %w{c --username hoge --password foo}
|
29
|
+
out = catch_out {Yggdrasil.command(cmd, "n\n")}
|
30
|
+
out.should == <<"EOS"
|
31
|
+
|
32
|
+
0:A tmp/yggdrasil-test/C
|
33
|
+
1:D tmp/yggdrasil-test/A
|
34
|
+
2:M tmp/yggdrasil-test/B
|
35
|
+
OK? [Y|n|<num to diff>]:
|
36
|
+
EOS
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should display check result by "status"' do
|
40
|
+
cmd = %w{status --username hoge --password foo}
|
41
|
+
out = catch_out {Yggdrasil.command(cmd, "n\n")}
|
42
|
+
out.should == <<"EOS"
|
43
|
+
|
44
|
+
0:A tmp/yggdrasil-test/C
|
45
|
+
1:D tmp/yggdrasil-test/A
|
46
|
+
2:M tmp/yggdrasil-test/B
|
47
|
+
OK? [Y|n|<num to diff>]:
|
48
|
+
EOS
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should display check result by "stat"' do
|
52
|
+
cmd = %w{stat --username hoge --password foo}
|
53
|
+
out = catch_out {Yggdrasil.command(cmd, "n\n")}
|
54
|
+
out.should == <<"EOS"
|
55
|
+
|
56
|
+
0:A tmp/yggdrasil-test/C
|
57
|
+
1:D tmp/yggdrasil-test/A
|
58
|
+
2:M tmp/yggdrasil-test/B
|
59
|
+
OK? [Y|n|<num to diff>]:
|
60
|
+
EOS
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should display check result by "st"' do
|
64
|
+
cmd = %w{st --username hoge --password foo}
|
65
|
+
out = catch_out {Yggdrasil.command(cmd, "n\n")}
|
66
|
+
out.should == <<"EOS"
|
67
|
+
|
68
|
+
0:A tmp/yggdrasil-test/C
|
69
|
+
1:D tmp/yggdrasil-test/A
|
70
|
+
2:M tmp/yggdrasil-test/B
|
71
|
+
OK? [Y|n|<num to diff>]:
|
72
|
+
EOS
|
73
|
+
|
74
|
+
`echo hoge > /tmp/yggdrasil-test/A`
|
75
|
+
`echo hoge >> /tmp/yggdrasil-test/A`
|
76
|
+
`echo foo > /tmp/yggdrasil-test/B`
|
77
|
+
`echo foo >> /tmp/yggdrasil-test/B`
|
78
|
+
`rm -f /tmp/yggdrasil-test/C`
|
9
79
|
end
|
10
80
|
|
11
81
|
it 'should execute checker and svn add the result' do
|
@@ -14,12 +84,10 @@ describe Yggdrasil, 'check' do
|
|
14
84
|
`echo 'echo hoge' > /tmp/yggdrasil-test/.yggdrasil/checker/hoge`
|
15
85
|
`chmod +x /tmp/yggdrasil-test/.yggdrasil/checker/hoge`
|
16
86
|
|
17
|
-
cmd = %w{check --username hoge --password foo}
|
18
|
-
out = catch_out {Yggdrasil.command(cmd)}
|
87
|
+
cmd = %w{check --username hoge --password foo --non-interactive}
|
88
|
+
out = catch_out {Yggdrasil.command(cmd, "Y\n")}
|
19
89
|
out.should == <<"EOS"
|
20
|
-
A 0 tmp/yggdrasil-test/.yggdrasil/checker_result
|
21
90
|
A 0 tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
|
22
|
-
A 0 tmp/yggdrasil-test/.yggdrasil
|
23
91
|
|
24
92
|
Index: tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
|
25
93
|
===================================================================
|
@@ -36,8 +104,6 @@ EOS
|
|
36
104
|
out = catch_out {Yggdrasil.command cmd}
|
37
105
|
|
38
106
|
out.should == <<"EOS"
|
39
|
-
Adding tmp/yggdrasil-test/.yggdrasil
|
40
|
-
Adding tmp/yggdrasil-test/.yggdrasil/checker_result
|
41
107
|
Adding tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
|
42
108
|
Transmitting file data .
|
43
109
|
Committed revision 4.
|
@@ -48,8 +114,11 @@ EOS
|
|
48
114
|
puts "\n---- should delete result if checker deleted"
|
49
115
|
`rm -f /tmp/yggdrasil-test/.yggdrasil/checker/hoge`
|
50
116
|
cmd = %w{check --username hoge --password foo}
|
51
|
-
out = catch_out {Yggdrasil.command(cmd)}
|
117
|
+
out = catch_out {Yggdrasil.command(cmd, "Y\n")}
|
52
118
|
out.should == <<"EOS"
|
119
|
+
|
120
|
+
0:D tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
|
121
|
+
OK? [Y|n|<num to diff>]:
|
53
122
|
D 4 tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
|
54
123
|
|
55
124
|
Index: tmp/yggdrasil-test/.yggdrasil/checker_result/hoge
|
@@ -103,7 +172,7 @@ EOS
|
|
103
172
|
%w{--username hoge --password foo},
|
104
173
|
"Y\nhoge\nfoo\n"
|
105
174
|
`rm -f /tmp/yggdrasil-test/.yggdrasil/checker/gem_list`
|
106
|
-
Yggdrasil.command %w{check}
|
175
|
+
Yggdrasil.command %w{check --non-interactive}
|
107
176
|
|
108
177
|
sleep 1
|
109
178
|
File.exist?('/tmp/yggdrasil-test/.yggdrasil/results').should be_true
|
@@ -111,10 +180,10 @@ EOS
|
|
111
180
|
result_files = files.select{|file| %r{^#{Socket.gethostname}} =~ file}
|
112
181
|
result_files.size.should == 1
|
113
182
|
`cat /tmp/yggdrasil-test/.yggdrasil/results/#{result_files[0]}`.should == <<"EOS"
|
183
|
+
A 0 tmp
|
114
184
|
A 0 tmp/yggdrasil-test
|
115
185
|
A 0 tmp/yggdrasil-test/.yggdrasil
|
116
186
|
A 0 tmp/yggdrasil-test/.yggdrasil/checker_result
|
117
|
-
A 0 tmp
|
118
187
|
|
119
188
|
EOS
|
120
189
|
|
@@ -124,7 +193,7 @@ EOS
|
|
124
193
|
"Y\nHOGE\n"
|
125
194
|
|
126
195
|
`echo foo >> /tmp/yggdrasil-test/A`
|
127
|
-
Yggdrasil.command %w{check}
|
196
|
+
Yggdrasil.command %w{check}, "Y\n"
|
128
197
|
|
129
198
|
`cat /tmp/yggdrasil-test/.yggdrasil/results/#{result_files[0]}`.should == <<"EOS"
|
130
199
|
M 2 tmp/yggdrasil-test/A
|
data/spec/commit_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe Yggdrasil, 'commit' do
|
|
22
22
|
|
23
23
|
puts '-- commit'
|
24
24
|
FileUtils.cd '/tmp/yggdrasil-test' do
|
25
|
-
Yggdrasil.command %w{commit --username hoge --password foo},
|
25
|
+
Yggdrasil.command %w{commit --username hoge --password foo A B},
|
26
26
|
"0\nY\nadd A and B\n"
|
27
27
|
end
|
28
28
|
|
@@ -105,7 +105,7 @@ describe Yggdrasil, 'commit' do
|
|
105
105
|
puts "\n-- check file exists on repo"
|
106
106
|
res = `svn ls file:///tmp/yggdrasil-test/svn-repo/mng-repo/host-name/tmp/yggdrasil-test`
|
107
107
|
puts res
|
108
|
-
res.should == "
|
108
|
+
res.should == ".yggdrasil/\nA\nB\n"
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'should commit deleted file' do
|
@@ -120,7 +120,7 @@ describe Yggdrasil, 'commit' do
|
|
120
120
|
puts "\n-- check committed delete file"
|
121
121
|
res = `svn ls file:///tmp/yggdrasil-test/svn-repo/mng-repo/host-name/tmp/yggdrasil-test`
|
122
122
|
puts res
|
123
|
-
res.should == "
|
123
|
+
res.should == ".yggdrasil/\nA\n"
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'should commit all files at once' do
|
@@ -139,7 +139,7 @@ describe Yggdrasil, 'commit' do
|
|
139
139
|
puts "\n-- check committed delete file"
|
140
140
|
res = `svn ls file:///tmp/yggdrasil-test/svn-repo/mng-repo/host-name/tmp/yggdrasil-test`
|
141
141
|
puts res
|
142
|
-
res.should == "
|
142
|
+
res.should == ".yggdrasil/\nA\nc/\n"
|
143
143
|
end
|
144
144
|
|
145
145
|
end
|
data/spec/help_spec.rb
CHANGED
@@ -10,7 +10,7 @@ Type '#{File.basename($0)} help <subcommand>' for help on a specific subcommand.
|
|
10
10
|
|
11
11
|
Available subcommands:
|
12
12
|
add
|
13
|
-
check (c)
|
13
|
+
check (c, status, stat, st)
|
14
14
|
cleanup
|
15
15
|
commit (ci)
|
16
16
|
diff (di)
|
@@ -18,9 +18,7 @@ Available subcommands:
|
|
18
18
|
init
|
19
19
|
list (ls)
|
20
20
|
log
|
21
|
-
revert
|
22
|
-
status (stat, st)
|
23
|
-
update
|
21
|
+
update (up, revert)
|
24
22
|
version
|
25
23
|
|
26
24
|
Yggdrasil is a subversion wrapper to manage server configurations and conditions.
|
@@ -215,20 +213,8 @@ Valid options:
|
|
215
213
|
'BASE' base rev of item's working copy
|
216
214
|
'COMMITTED' last commit at or before BASE
|
217
215
|
'PREV' revision just before COMMITTED
|
218
|
-
|
219
|
-
|
220
|
-
end
|
221
|
-
|
222
|
-
it 'should show help of status' do
|
223
|
-
puts '---- should show help of status'
|
224
|
-
out = catch_out{Yggdrasil.command %w{help status}}
|
225
|
-
out.should == <<"EOS"
|
226
|
-
status (stat, st): Print the status of managed files and directories.
|
227
|
-
usage: #{File.basename($0)} status [OPTIONS...] [PATH...]
|
228
|
-
|
229
|
-
Valid options:
|
230
|
-
--username ARG : specify a username ARG
|
231
|
-
--password ARG : specify a password ARG
|
216
|
+
-q [--quiet] : print nothing, or only summary information
|
217
|
+
-v [--verbose] : print extra information
|
232
218
|
|
233
219
|
EOS
|
234
220
|
end
|
@@ -237,20 +223,12 @@ EOS
|
|
237
223
|
puts '---- should show help of update'
|
238
224
|
out = catch_out{Yggdrasil.command %w{help update}}
|
239
225
|
out.should == <<"EOS"
|
240
|
-
update (up):
|
226
|
+
update (up, revert): Set the files to the contents of the newest repository.
|
241
227
|
usage: #{File.basename($0)} update [OPTIONS...] [PATH...]
|
242
228
|
|
243
229
|
Valid options:
|
244
230
|
--username ARG : specify a username ARG
|
245
231
|
--password ARG : specify a password ARG
|
246
|
-
-r [--revision] ARG : ARG (some commands also take ARG1:ARG2 range)
|
247
|
-
A revision argument can be one of:
|
248
|
-
NUMBER revision number
|
249
|
-
'{' DATE '}' revision at start of the date
|
250
|
-
'HEAD' latest in repository
|
251
|
-
'BASE' base rev of item's working copy
|
252
|
-
'COMMITTED' last commit at or before BASE
|
253
|
-
'PREV' revision just before COMMITTED
|
254
232
|
--non-interactive : do no interactive prompting
|
255
233
|
|
256
234
|
EOS
|
@@ -260,8 +238,8 @@ EOS
|
|
260
238
|
puts '---- should show help of revert'
|
261
239
|
out = catch_out{Yggdrasil.command %w{help revert}}
|
262
240
|
out.should == <<"EOS"
|
263
|
-
revert:
|
264
|
-
usage: #{File.basename($0)}
|
241
|
+
update (up, revert): Set the files to the contents of the newest repository.
|
242
|
+
usage: #{File.basename($0)} update [OPTIONS...] [PATH...]
|
265
243
|
|
266
244
|
Valid options:
|
267
245
|
--username ARG : specify a username ARG
|
@@ -275,7 +253,7 @@ EOS
|
|
275
253
|
puts '---- should show help of check'
|
276
254
|
out = catch_out{Yggdrasil.command %w{help check}}
|
277
255
|
out.should == <<"EOS"
|
278
|
-
check (c): check updating of managed files and the execution output of a commands.
|
256
|
+
check (c, status, stat, st): check updating of managed files and the execution output of a commands.
|
279
257
|
usage: #{File.basename($0)} check [OPTIONS...]
|
280
258
|
|
281
259
|
This subcommand execute the executable files in ~/.yggdrasil/checker/, and
|
data/spec/list_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe Yggdrasil, 'list' do
|
|
22
22
|
%w{--username hoge --password foo}
|
23
23
|
end
|
24
24
|
end
|
25
|
-
out.should == "
|
25
|
+
out.should == ".yggdrasil/\nA\nB\n"
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should show list (no path)' do
|
@@ -33,17 +33,39 @@ describe Yggdrasil, 'list' do
|
|
33
33
|
%w{--username hoge --password foo}
|
34
34
|
end
|
35
35
|
end
|
36
|
-
out.should == "
|
36
|
+
out.should == <<"EOS"
|
37
|
+
tmp/
|
38
|
+
tmp/yggdrasil-test/
|
39
|
+
tmp/yggdrasil-test/.yggdrasil/
|
40
|
+
tmp/yggdrasil-test/.yggdrasil/checker_result/
|
41
|
+
tmp/yggdrasil-test/A
|
42
|
+
tmp/yggdrasil-test/B
|
43
|
+
EOS
|
37
44
|
end
|
38
45
|
|
39
|
-
it 'should show list
|
40
|
-
puts '---- should show list
|
46
|
+
it 'should show list with options (1)' do
|
47
|
+
puts '---- should show list with options (1)'
|
41
48
|
out = catch_out{Yggdrasil.command(%w{list -R --revision 2 /tmp} +
|
42
|
-
|
43
|
-
out.should == "
|
49
|
+
%w{--username hoge --password foo})}
|
50
|
+
out.should == <<"EOS"
|
51
|
+
yggdrasil-test/
|
52
|
+
yggdrasil-test/.yggdrasil/
|
53
|
+
yggdrasil-test/.yggdrasil/checker_result/
|
54
|
+
yggdrasil-test/A
|
55
|
+
yggdrasil-test/B
|
56
|
+
EOS
|
57
|
+
end
|
44
58
|
|
59
|
+
it 'should show list with options (2)' do
|
60
|
+
puts '---- should show list with options (2)'
|
45
61
|
out = catch_out{Yggdrasil.command(%w{list --revision 2 --recursive /tmp} +
|
46
62
|
%w{--username hoge --password foo})}
|
47
|
-
out.should == "
|
63
|
+
out.should == <<"EOS"
|
64
|
+
yggdrasil-test/
|
65
|
+
yggdrasil-test/.yggdrasil/
|
66
|
+
yggdrasil-test/.yggdrasil/checker_result/
|
67
|
+
yggdrasil-test/A
|
68
|
+
yggdrasil-test/B
|
69
|
+
EOS
|
48
70
|
end
|
49
71
|
end
|
data/spec/log_spec.rb
CHANGED
data/spec/revert_spec.rb
CHANGED
@@ -23,11 +23,11 @@ describe Yggdrasil, 'revert' do
|
|
23
23
|
|
24
24
|
puts "\n-- check revert file (add)"
|
25
25
|
out = catch_out do
|
26
|
-
Yggdrasil.command %w{
|
26
|
+
Yggdrasil.command %w{check /tmp/yggdrasil-test --non-interactive} +
|
27
27
|
%w{--username hoge --password foo}
|
28
28
|
end
|
29
29
|
puts out
|
30
|
-
out.should ==
|
30
|
+
out.should == "no files.\n"
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should revert modified file' do
|
@@ -41,11 +41,11 @@ describe Yggdrasil, 'revert' do
|
|
41
41
|
|
42
42
|
puts "\n-- check revert file (modify)"
|
43
43
|
out = catch_out do
|
44
|
-
Yggdrasil.command %w{
|
44
|
+
Yggdrasil.command %w{check /tmp/yggdrasil-test --non-interactive} +
|
45
45
|
%w{--username hoge --password foo}
|
46
46
|
end
|
47
47
|
puts out
|
48
|
-
out.should ==
|
48
|
+
out.should == "no files.\n"
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should accept password interactive' do
|
@@ -57,11 +57,11 @@ describe Yggdrasil, 'revert' do
|
|
57
57
|
|
58
58
|
puts "\n-- check revert file"
|
59
59
|
out = catch_out do
|
60
|
-
Yggdrasil.command %w{
|
60
|
+
Yggdrasil.command %w{check /tmp/yggdrasil-test --non-interactive} +
|
61
61
|
%w{--username hoge --password foo}
|
62
62
|
end
|
63
63
|
puts out
|
64
|
-
out.should ==
|
64
|
+
out.should == "no files.\n"
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'should revert specified file only' do
|
@@ -75,12 +75,23 @@ describe Yggdrasil, 'revert' do
|
|
75
75
|
|
76
76
|
puts "\n-- check revert file"
|
77
77
|
out = catch_out do
|
78
|
-
Yggdrasil.command %w{
|
78
|
+
Yggdrasil.command %w{check /tmp/yggdrasil-test --non-interactive} +
|
79
79
|
%w{--username hoge --password foo}
|
80
80
|
end
|
81
81
|
puts out
|
82
82
|
out.gsub!(%r{ +}, ' ')
|
83
|
-
out.should == "
|
83
|
+
out.should == <<"EOS"
|
84
|
+
M 3 tmp/yggdrasil-test/A
|
85
|
+
|
86
|
+
Index: tmp/yggdrasil-test/A
|
87
|
+
===================================================================
|
88
|
+
--- tmp/yggdrasil-test/A (revision 3)
|
89
|
+
+++ tmp/yggdrasil-test/A (working copy)
|
90
|
+
@@ -1,2 +1,3 @@
|
91
|
+
hoge
|
92
|
+
hoge
|
93
|
+
+A
|
94
|
+
EOS
|
84
95
|
end
|
85
96
|
|
86
97
|
it 'should not revert deleted file' do
|
@@ -93,13 +104,22 @@ describe Yggdrasil, 'revert' do
|
|
93
104
|
|
94
105
|
puts "\n-- check status"
|
95
106
|
out = catch_out do
|
96
|
-
Yggdrasil.command %w{
|
107
|
+
Yggdrasil.command %w{check /tmp/yggdrasil-test --non-interactive} +
|
97
108
|
%w{--username hoge --password foo}
|
98
109
|
end
|
99
|
-
out.chomp!
|
100
110
|
puts out
|
101
|
-
out.gsub!(%r{
|
102
|
-
out.should ==
|
111
|
+
out.gsub!(%r{ +},' ')
|
112
|
+
out.should == <<"EOS"
|
113
|
+
D 3 tmp/yggdrasil-test/A
|
114
|
+
|
115
|
+
Index: tmp/yggdrasil-test/A
|
116
|
+
===================================================================
|
117
|
+
--- tmp/yggdrasil-test/A (revision 3)
|
118
|
+
+++ tmp/yggdrasil-test/A (working copy)
|
119
|
+
@@ -1,2 +0,0 @@
|
120
|
+
-hoge
|
121
|
+
-hoge
|
122
|
+
EOS
|
103
123
|
end
|
104
124
|
|
105
125
|
it 'should revert all files at once' do
|
@@ -117,10 +137,10 @@ describe Yggdrasil, 'revert' do
|
|
117
137
|
|
118
138
|
puts "\n-- check status"
|
119
139
|
out = catch_out do
|
120
|
-
Yggdrasil.command %w{
|
140
|
+
Yggdrasil.command %w{check /tmp/yggdrasil-test --non-interactive} +
|
121
141
|
%w{--username hoge --password foo}
|
122
142
|
end
|
123
143
|
puts out
|
124
|
-
out.should ==
|
144
|
+
out.should == "no files.\n"
|
125
145
|
end
|
126
146
|
end
|
data/spec/server_results_spec.rb
CHANGED
@@ -52,7 +52,7 @@ describe YggdrasilServer, 'results' do
|
|
52
52
|
puts '---- should show results'
|
53
53
|
|
54
54
|
`echo foo >> /tmp/yggdrasil-test/A`
|
55
|
-
Yggdrasil.command %w{check}
|
55
|
+
Yggdrasil.command %w{check --non-interactive}
|
56
56
|
|
57
57
|
`echo hoge > /tmp/yggdrasil-test/.yggdrasil/results/hoge-old`
|
58
58
|
File.utime Time.local(2001, 5, 22, 23, 59, 59),
|
data/spec/spec_helper.rb
CHANGED
@@ -33,6 +33,7 @@ def init_yggdrasil
|
|
33
33
|
Yggdrasil.command %w{init} +
|
34
34
|
%w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/mng-repo/host-name/} +
|
35
35
|
%w{--username hoge --password foo --parents}
|
36
|
+
`rm /tmp/yggdrasil-test/.yggdrasil/checker/gem_list`
|
36
37
|
puts '-- add'
|
37
38
|
`echo hoge > /tmp/yggdrasil-test/A`
|
38
39
|
`echo foo > /tmp/yggdrasil-test/B`
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yggdrasil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -71,8 +71,6 @@ files:
|
|
71
71
|
- lib/yggdrasil/init.rb
|
72
72
|
- lib/yggdrasil/list.rb
|
73
73
|
- lib/yggdrasil/log.rb
|
74
|
-
- lib/yggdrasil/revert.rb
|
75
|
-
- lib/yggdrasil/status.rb
|
76
74
|
- lib/yggdrasil/update.rb
|
77
75
|
- lib/yggdrasil/version.rb
|
78
76
|
- lib/yggdrasil_common.rb
|
@@ -101,7 +99,6 @@ files:
|
|
101
99
|
- spec/server_spec.rb
|
102
100
|
- spec/server_version_spec.rb
|
103
101
|
- spec/spec_helper.rb
|
104
|
-
- spec/status_spec.rb
|
105
102
|
- spec/update_spec.rb
|
106
103
|
- spec/version_spec.rb
|
107
104
|
- yggdrasil.gemspec
|
@@ -119,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
116
|
version: '0'
|
120
117
|
segments:
|
121
118
|
- 0
|
122
|
-
hash:
|
119
|
+
hash: 2992744534865834849
|
123
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
121
|
none: false
|
125
122
|
requirements:
|
@@ -128,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
125
|
version: '0'
|
129
126
|
segments:
|
130
127
|
- 0
|
131
|
-
hash:
|
128
|
+
hash: 2992744534865834849
|
132
129
|
requirements: []
|
133
130
|
rubyforge_project:
|
134
131
|
rubygems_version: 1.8.25
|
@@ -152,6 +149,5 @@ test_files:
|
|
152
149
|
- spec/server_spec.rb
|
153
150
|
- spec/server_version_spec.rb
|
154
151
|
- spec/spec_helper.rb
|
155
|
-
- spec/status_spec.rb
|
156
152
|
- spec/update_spec.rb
|
157
153
|
- spec/version_spec.rb
|
data/lib/yggdrasil/revert.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
class Yggdrasil
|
2
|
-
|
3
|
-
# @param [Array] args
|
4
|
-
def revert(args)
|
5
|
-
target_paths = parse_options(args,
|
6
|
-
{'--username'=>:username, '--password'=>:password,
|
7
|
-
'--non-interactive'=>:non_interactive?})
|
8
|
-
get_user_pass_if_need_to_read_repo
|
9
|
-
|
10
|
-
updates = sync_mirror
|
11
|
-
matched_updates = select_updates(updates, target_paths)
|
12
|
-
if matched_updates.size == 0
|
13
|
-
puts "\nno files."
|
14
|
-
return
|
15
|
-
end
|
16
|
-
|
17
|
-
confirmed_updates = confirm_updates(matched_updates) do |relative_path|
|
18
|
-
FileUtils.cd @mirror_dir do
|
19
|
-
cmd = "#@svn diff --no-auth-cache --non-interactive #{relative_path}"
|
20
|
-
cmd += username_password_options_to_read_repo
|
21
|
-
puts system3(cmd)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
return unless confirmed_updates
|
26
|
-
return if confirmed_updates.size == 0
|
27
|
-
|
28
|
-
FileUtils.cd @mirror_dir do
|
29
|
-
cmd = "#@svn revert #{confirmed_updates.reverse.join(' ')}"
|
30
|
-
cmd += username_password_options_to_read_repo
|
31
|
-
system3 cmd
|
32
|
-
|
33
|
-
# make ls hash
|
34
|
-
cmd = "#@svn ls -R #@repo --no-auth-cache --non-interactive"
|
35
|
-
cmd += username_password_options_to_read_repo
|
36
|
-
out = system3(cmd)
|
37
|
-
|
38
|
-
ls_hash = Hash.new
|
39
|
-
out.split(/\n/).each {|relative| ls_hash[relative]=true}
|
40
|
-
|
41
|
-
# reflect mirror to real file
|
42
|
-
confirmed_updates.each do |file|
|
43
|
-
if ls_hash.has_key?(file)
|
44
|
-
if File.file?("#@mirror_dir/#{file}")
|
45
|
-
FileUtils.copy_file "#@mirror_dir/#{file}", "/#{file}"
|
46
|
-
end
|
47
|
-
else
|
48
|
-
system3 "rm -rf #{@mirror_dir + '/' + file}"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/yggdrasil/status.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
class Yggdrasil
|
2
|
-
|
3
|
-
# @param [Array] args
|
4
|
-
def status(args)
|
5
|
-
args = parse_options(args,
|
6
|
-
{'--username'=>:username, '--password'=>:password})
|
7
|
-
get_user_pass_if_need_to_read_repo
|
8
|
-
|
9
|
-
sync_mirror
|
10
|
-
|
11
|
-
paths = String.new
|
12
|
-
if args.size == 0
|
13
|
-
paths += ' '+@current_dir.sub(%r{^/*}, '')
|
14
|
-
else
|
15
|
-
args.each do |path|
|
16
|
-
path = "#@current_dir/#{path}" unless %r{^/} =~ path
|
17
|
-
paths += ' ' + path.sub(%r{^/*}, '')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
cmd_arg = "#@svn status#{paths} -qu --no-auth-cache --non-interactive"
|
22
|
-
cmd_arg += username_password_options_to_read_repo
|
23
|
-
FileUtils.cd @mirror_dir do
|
24
|
-
out = system3(cmd_arg)
|
25
|
-
print out.gsub(/^Status against revision:.*\n/, '')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/spec/status_spec.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe Yggdrasil, 'status' do
|
4
|
-
it '-------- status' do
|
5
|
-
puts '-------- status'
|
6
|
-
prepare_environment
|
7
|
-
init_yggdrasil
|
8
|
-
|
9
|
-
# modify and not commit yet
|
10
|
-
`echo HOGE >> /tmp/yggdrasil-test/A`
|
11
|
-
`rm -f /tmp/yggdrasil-test/B`
|
12
|
-
`mkdir /tmp/yggdrasil-test/c`
|
13
|
-
`echo bar > /tmp/yggdrasil-test/c/C`
|
14
|
-
Yggdrasil.command %w{add /tmp/yggdrasil-test/c/C}
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should show status(absolute and relative)' do
|
18
|
-
puts '---- should show status(absolute and relative)'
|
19
|
-
out = catch_out do
|
20
|
-
FileUtils.cd '/tmp/yggdrasil-test' do
|
21
|
-
Yggdrasil.command %w{status /tmp/yggdrasil-test/A B --username hoge --password foo}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
out.gsub!(%r{ +}, ' ')
|
25
|
-
out.should == <<"EOS"
|
26
|
-
M 3 tmp/yggdrasil-test/A
|
27
|
-
D 3 tmp/yggdrasil-test/B
|
28
|
-
EOS
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should show status(/)' do
|
32
|
-
puts '---- should show status(/)'
|
33
|
-
out = catch_out do
|
34
|
-
FileUtils.cd '/tmp/yggdrasil-test' do
|
35
|
-
Yggdrasil.command %w{status / --username hoge --password foo}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
out.gsub!(%r{ +}, ' ')
|
39
|
-
out.should == <<"EOS"
|
40
|
-
M 3 tmp/yggdrasil-test/A
|
41
|
-
D 3 tmp/yggdrasil-test/B
|
42
|
-
A 0 tmp/yggdrasil-test/c/C
|
43
|
-
A 0 tmp/yggdrasil-test/c
|
44
|
-
EOS
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should show status (no path)' do
|
48
|
-
puts '---- should show status (no path)'
|
49
|
-
out = catch_out do
|
50
|
-
FileUtils.cd '/tmp/yggdrasil-test' do
|
51
|
-
Yggdrasil.command %w{status --username hoge --password foo}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
out.gsub!(%r{ +}, ' ')
|
55
|
-
out.should == <<"EOS"
|
56
|
-
M 3 tmp/yggdrasil-test/A
|
57
|
-
D 3 tmp/yggdrasil-test/B
|
58
|
-
A 0 tmp/yggdrasil-test/c/C
|
59
|
-
A 0 tmp/yggdrasil-test/c
|
60
|
-
EOS
|
61
|
-
end
|
62
|
-
end
|