svn-command 0.2.7 → 0.2.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/ProjectInfo.rb +1 -2
- data/Readme +52 -11
- data/lib/svn-command/subversion.rb +35 -7
- data/lib/svn-command/subversion_extensions.rb +73 -67
- data/lib/svn-command/svn_command.rb +343 -77
- data/test/svn_command_test.rb +74 -47
- metadata +2 -11
data/test/svn_command_test.rb
CHANGED
@@ -13,6 +13,33 @@ require 'qualitysmith_extensions/regexp/join'
|
|
13
13
|
Subversion.color = false
|
14
14
|
String.color_on! false
|
15
15
|
|
16
|
+
#pp Subversion::SvnCommand.instance_methods.sort
|
17
|
+
|
18
|
+
# Since this doesn't work: Subversion::SvnCommand.any_instance.stubs(:system).returns(Proc.new {|a| p a; puts "Tried to call system(#{a})" })
|
19
|
+
class Subversion::SvnCommand
|
20
|
+
def system(*args)
|
21
|
+
Subversion::SvnCommand.executed_system << args.join(' ')
|
22
|
+
end
|
23
|
+
def self.executed_system
|
24
|
+
@@executed_system ||= []
|
25
|
+
end
|
26
|
+
def self.reset_executed_system(as = [])
|
27
|
+
@@executed_system = as
|
28
|
+
end
|
29
|
+
end
|
30
|
+
module Kernel
|
31
|
+
def exit_code
|
32
|
+
o = Object.new
|
33
|
+
class << o
|
34
|
+
def success?
|
35
|
+
true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
o
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
16
43
|
module Subversion
|
17
44
|
class BaseSvnCommandTest < Test::Unit::TestCase
|
18
45
|
def setup
|
@@ -21,8 +48,14 @@ class BaseSvnCommandTest < Test::Unit::TestCase
|
|
21
48
|
def test_dummy_test
|
22
49
|
# Because it tries to run this base class too!
|
23
50
|
end
|
51
|
+
# When we don't care what the output is -- we just don't want to see it while running the test!
|
52
|
+
def silence(&block)
|
53
|
+
capture_output(&block)
|
54
|
+
nil
|
55
|
+
end
|
24
56
|
end
|
25
57
|
|
58
|
+
|
26
59
|
class SvnCommandTest < BaseSvnCommandTest
|
27
60
|
def test_invalid_quotes_gives_informative_error
|
28
61
|
assert_exception(ArgumentError, lambda { |exception|
|
@@ -44,13 +77,14 @@ end
|
|
44
77
|
|
45
78
|
class ArgEscapingTest < BaseSvnCommandTest
|
46
79
|
def test_argument_escaping
|
47
|
-
|
48
|
-
|
80
|
+
args = nil
|
81
|
+
silence { SvnCommand.execute( args = %q{commit -m 'a message with lots of !&`$0 |()<> garbage'} ) }
|
82
|
+
assert_equal "svn #{args} --force-log", Subversion.executed[0]
|
49
83
|
end
|
50
84
|
def test_asterisk
|
51
85
|
# Don't worry, this'll never happen, because the shell will expand the * *before* it gets to SvnCommand. But if you *did* sneak in an asterisk to SvnCommand.execute somehow, this is what would happen...
|
52
86
|
SvnCommand.execute("add dir/* --non-recursive")
|
53
|
-
assert_equal "svn add --non-recursive 'dir/*'", Subversion.executed
|
87
|
+
assert_equal "svn add --non-recursive 'dir/*'", Subversion.executed[0]
|
54
88
|
# Actually, I lied... The * will *not* be expanded in the (rather uncommon) case that there are *no files matching the glob*. But that seems like a bash/shell problem, not our concern. Demo:
|
55
89
|
# > mkdir foo
|
56
90
|
# > echo foo/*
|
@@ -60,10 +94,17 @@ class ArgEscapingTest < BaseSvnCommandTest
|
|
60
94
|
# foo/file
|
61
95
|
end
|
62
96
|
def test_multiline
|
63
|
-
|
97
|
+
args = nil
|
98
|
+
silence { SvnCommand.execute(args = "commit -m 'This is a
|
64
99
|
|multi-line
|
65
|
-
|message'".margin)
|
66
|
-
assert_equal "svn #{args} --force-log", Subversion.executed
|
100
|
+
|message'".margin) }
|
101
|
+
assert_equal "svn #{args} --force-log", Subversion.executed[0]
|
102
|
+
end
|
103
|
+
def test_multiword_arg_preserved_even_for_passthrough_subcommands
|
104
|
+
# foo, for instance is entirely a passthrough subcommand; no 'def foo' exists, so it's handled entirely through method_missing.
|
105
|
+
args = nil
|
106
|
+
silence { SvnCommand.execute( args = %q{foo -m 'a multi-word message' --something-else 'something else'} ) }
|
107
|
+
assert_equal "svn #{args}", Subversion.executed[0]
|
67
108
|
end
|
68
109
|
end
|
69
110
|
|
@@ -74,11 +115,11 @@ end
|
|
74
115
|
class SubcommandPassThroughTest < BaseSvnCommandTest
|
75
116
|
def test_1
|
76
117
|
SvnCommand.execute("rm -q file1 file2 --force")
|
77
|
-
assert_equal "svn rm -q file1 file2 --force", Subversion.executed
|
118
|
+
assert_equal "svn rm -q file1 file2 --force", Subversion.executed[0]
|
78
119
|
end
|
79
120
|
def test_2
|
80
121
|
SvnCommand.execute("info -q file1 file2 --force")
|
81
|
-
assert_equal "svn info -q file1 file2 --force", Subversion.executed
|
122
|
+
assert_equal "svn info -q file1 file2 --force", Subversion.executed[0]
|
82
123
|
end
|
83
124
|
end
|
84
125
|
|
@@ -87,29 +128,29 @@ class SvnAddTest < BaseSvnCommandTest
|
|
87
128
|
end
|
88
129
|
def test_2
|
89
130
|
SvnCommand.execute('add "a b"')
|
90
|
-
assert_equal "svn add 'a b'", Subversion.executed
|
131
|
+
assert_equal "svn add 'a b'", Subversion.executed[0]
|
91
132
|
end
|
92
133
|
def test_3
|
93
134
|
SvnCommand.execute('add a b')
|
94
|
-
assert_equal "svn add a b", Subversion.executed
|
135
|
+
assert_equal "svn add a b", Subversion.executed[0]
|
95
136
|
end
|
96
137
|
end
|
97
138
|
|
98
139
|
class SvnCommitTest < BaseSvnCommandTest
|
99
140
|
def test_1
|
100
|
-
SvnCommand.execute("commit -m 'just an ordinary commit message!'")
|
101
|
-
assert_equal
|
141
|
+
silence { SvnCommand.execute("commit -m 'just an ordinary commit message!'") }
|
142
|
+
assert_equal "svn commit -m 'just an ordinary commit message!' --force-log", Subversion.executed[0]
|
102
143
|
end
|
103
144
|
def test_lots_of_options
|
104
|
-
SvnCommand.execute("commit --non-recursive -q -m '' --targets some_file ")
|
105
|
-
assert_equal
|
145
|
+
silence { SvnCommand.execute("commit --non-recursive -q -m '' --targets some_file ") }
|
146
|
+
assert_equal "svn commit --non-recursive -q -m '' --targets some_file --force-log", Subversion.executed[0]
|
106
147
|
end
|
107
148
|
def test_that_complex_quoting_doesnt_confuse_it
|
108
149
|
original_message = "Can't decide how many \"'quotes'\" to use!"
|
109
|
-
SvnCommand.execute(%Q{commit -m "#{original_message.gsub('"', '\"')}"})
|
150
|
+
silence { SvnCommand.execute(%Q{commit -m "#{original_message.gsub('"', '\"')}"}) }
|
110
151
|
|
111
152
|
expected_escaped_part = %q{'Can'\\''t decide how many "'\\''quotes'\\''" to use!'}
|
112
|
-
assert_equal "svn commit -m #{expected_escaped_part} --force-log", Subversion.executed
|
153
|
+
assert_equal "svn commit -m #{expected_escaped_part} --force-log", Subversion.executed[0]
|
113
154
|
assert_equal original_message, `echo #{expected_escaped_part}`.chomp # We should have gotten back exactly what we put in originally
|
114
155
|
end
|
115
156
|
end
|
@@ -118,7 +159,7 @@ class SvnDiffTest < BaseSvnCommandTest
|
|
118
159
|
def test_1
|
119
160
|
SvnCommand.execute("diff -r 123:125")
|
120
161
|
assert_equal [
|
121
|
-
"svn diff
|
162
|
+
"svn diff -r 123:125 ./",
|
122
163
|
"svn status ./"
|
123
164
|
], Subversion.executed
|
124
165
|
end
|
@@ -127,14 +168,14 @@ class SvnDiffTest < BaseSvnCommandTest
|
|
127
168
|
#capture_output { SvnCommand.execute("diff -r { 2006-07-01 }") }
|
128
169
|
#p Subversion.executed
|
129
170
|
# Currently does this, since it thinks the arity is 1: 2006-07-01 } -r '{'
|
130
|
-
#assert_equal "svn diff -r { 2006-07-01 }", Subversion.executed
|
171
|
+
#assert_equal "svn diff -r { 2006-07-01 }", Subversion.executed[0]
|
131
172
|
end
|
132
173
|
end
|
133
174
|
|
134
175
|
class SvnHelpTest < BaseSvnCommandTest
|
135
176
|
def test_1
|
136
177
|
output = capture_output { SvnCommand.execute("help") }
|
137
|
-
assert_equal "svn help ", Subversion.executed
|
178
|
+
assert_equal "svn help ", Subversion.executed[0]
|
138
179
|
assert_match /wrapper/, output
|
139
180
|
end
|
140
181
|
end
|
@@ -142,7 +183,7 @@ end
|
|
142
183
|
class SvnLogTest < BaseSvnCommandTest
|
143
184
|
def test_1
|
144
185
|
capture_output { SvnCommand.execute("log") }
|
145
|
-
assert_equal "svn log ", Subversion.executed
|
186
|
+
assert_equal "svn log ", Subversion.executed[0]
|
146
187
|
end
|
147
188
|
end
|
148
189
|
|
@@ -178,12 +219,12 @@ End
|
|
178
219
|
|
179
220
|
def test_status_accepts_arguments
|
180
221
|
SvnCommand.execute('st -u /path/to/file1 file2')
|
181
|
-
assert_equal "svn status -u /path/to/file1 file2", Subversion.executed
|
222
|
+
assert_equal "svn status -u /path/to/file1 file2", Subversion.executed[0]
|
182
223
|
|
183
224
|
Subversion.reset_executed
|
184
225
|
SvnCommand.execute('st dir --no-ignore')
|
185
226
|
# It will reorder some of the args (it puts all pass-through options and their args at the *beginning*), but that's okay...
|
186
|
-
assert_equal "svn status --no-ignore dir", Subversion.executed
|
227
|
+
assert_equal "svn status --no-ignore dir", Subversion.executed[0]
|
187
228
|
|
188
229
|
end
|
189
230
|
end #class SvnStatusTest
|
@@ -191,7 +232,7 @@ end #class SvnStatusTest
|
|
191
232
|
class SvnUpdateTest < BaseSvnCommandTest
|
192
233
|
def test_1
|
193
234
|
capture_output { SvnCommand.execute("up -q file1 file2 -r 17") }
|
194
|
-
assert_equal "svn update -q -r 17 file1 file2", Subversion.executed
|
235
|
+
assert_equal "svn update -q -r 17 --non-recursive file1 file2", Subversion.executed[0]
|
195
236
|
end
|
196
237
|
end
|
197
238
|
|
@@ -231,7 +272,7 @@ X temp_dir/calculator/tasks/shared
|
|
231
272
|
end
|
232
273
|
assert_match /What do you want to do with .*unused\.rb/, output
|
233
274
|
assert_match /Adding/, output
|
234
|
-
assert_equal "svn add temp_dir/calculator/lib/unused.rb", Subversion.executed
|
275
|
+
assert_equal "svn add temp_dir/calculator/lib/unused.rb", Subversion.executed[0]
|
235
276
|
end
|
236
277
|
def test_ignore
|
237
278
|
stub_status_1
|
@@ -310,19 +351,6 @@ end
|
|
310
351
|
#-----------------------------------------------------------------------------------------------------------------------------
|
311
352
|
# Externals
|
312
353
|
|
313
|
-
# Since this doesn't work: Subversion::SvnCommand.any_instance.stubs(:system).returns(Proc.new {|a| p a; puts "Tried to call system(#{a})" })
|
314
|
-
class Subversion::SvnCommand
|
315
|
-
def system(*args)
|
316
|
-
Subversion::SvnCommand.executed_system << args.join(' ')
|
317
|
-
end
|
318
|
-
def self.executed_system
|
319
|
-
@@executed_system ||= []
|
320
|
-
end
|
321
|
-
def self.reset_executed_system(as = [])
|
322
|
-
@@executed_system = as
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
354
|
class SvnExternalsTest < BaseSvnCommandTest
|
327
355
|
|
328
356
|
# Causes .stub to break??
|
@@ -408,7 +436,7 @@ class SvnExternalsTest < BaseSvnCommandTest
|
|
408
436
|
"svn propedit svn:externals /home/tyler/code/gemables/svn-command/test",
|
409
437
|
"svn propedit svn:externals /home/tyler/code/gemables/svn-command/tasks",
|
410
438
|
"svn propedit svn:externals /home/tyler/code/gemables/svn-command/doc_include"
|
411
|
-
], Subversion
|
439
|
+
], Subversion.executed
|
412
440
|
end
|
413
441
|
end
|
414
442
|
|
@@ -573,31 +601,30 @@ class SvnRevisionsTest < BaseSvnCommandTest
|
|
573
601
|
assert_match Regexp.loose_join(
|
574
602
|
"Getting list of revisions for './' ...
|
575
603
|
2 revisions found. Starting with most recent revision and going backward in time...",
|
576
|
-
|
604
|
+
|
605
|
+
# Show 1800
|
577
606
|
"2. r1800 | tyler | 2007-12-01 00:00:00
|
578
607
|
I say! Quite the storm, what!
|
579
608
|
|
580
609
|
A dir/file1
|
581
610
|
M dir/file2
|
582
|
-
View this changeset, Diff against specific revision, Grep the changeset, List or Edit revision properties, svn Cat all files
|
611
|
+
r1800: View this changeset, Diff against specific revision, Grep the changeset, List or Edit revision properties, svn Cat all files, grep the cat,
|
583
612
|
mark as Reviewed, edit log Message, or browse using Up/Down/Enter keys >",
|
613
|
+
|
584
614
|
# Show the diff
|
585
615
|
"Diffing 1799:1800...",
|
586
616
|
"the diff",
|
587
|
-
# Show 1800 again
|
588
|
-
"2. r1800 | tyler | 2007-12-01 00:00:00
|
589
|
-
I say! Quite the storm, what!
|
590
617
|
|
591
|
-
|
592
|
-
|
593
|
-
View this changeset, Diff against specific revision, Grep the changeset, List or Edit revision properties, svn Cat all files from revision, grep the cat,
|
618
|
+
# Show 1800 again
|
619
|
+
"r1800: View this changeset, Diff against specific revision, Grep the changeset, List or Edit revision properties, svn Cat all files, grep the cat,
|
594
620
|
mark as Reviewed, edit log Message, or browse using Up/Down/Enter keys > Next...",
|
621
|
+
|
595
622
|
# Now show 1801
|
596
623
|
"1. r1801 | tyler | 2007-12-02 00:00:00
|
597
624
|
These Romans are crazy!
|
598
625
|
|
599
626
|
M dir/file2
|
600
|
-
View this changeset, Diff against specific revision, Grep the changeset, List or Edit revision properties, svn Cat all files
|
627
|
+
r1801: View this changeset, Diff against specific revision, Grep the changeset, List or Edit revision properties, svn Cat all files, grep the cat,
|
601
628
|
mark as Reviewed, edit log Message, or browse using Up/Down/Enter keys > Next...",
|
602
629
|
:multi_line => true
|
603
630
|
), output
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: svn-command
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.12
|
7
|
+
date: 2007-06-11 00:00:00 -07:00
|
8
8
|
summary: A nifty wrapper command for Subversion's command-line svn client
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -104,15 +104,6 @@ dependencies:
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: 0.0.0
|
106
106
|
version:
|
107
|
-
- !ruby/object:Gem::Dependency
|
108
|
-
name: extensions
|
109
|
-
version_requirement:
|
110
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
111
|
-
requirements:
|
112
|
-
- - ">"
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
version: 0.0.0
|
115
|
-
version:
|
116
107
|
- !ruby/object:Gem::Dependency
|
117
108
|
name: qualitysmith_extensions
|
118
109
|
version_requirement:
|