git-si 0.3.1 → 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.
- checksums.yaml +4 -4
- data/git-si.gemspec +2 -1
- data/lib/git/si.rb +68 -369
- data/lib/git/si/actions.rb +153 -0
- data/lib/git/si/errors.rb +20 -0
- data/lib/git/si/git-control.rb +112 -0
- data/lib/git/si/git-ignore.rb +23 -0
- data/lib/git/si/svn-control.rb +135 -0
- data/lib/git/si/util.rb +304 -0
- data/lib/git/si/version.rb +12 -1
- data/spec/actions_spec.rb +356 -0
- data/spec/git-control_spec.rb +254 -0
- data/spec/git-ignore_spec.rb +37 -0
- data/spec/svn-control_spec.rb +391 -0
- data/spec/util_spec.rb +458 -0
- data/spec/version_spec.rb +17 -0
- metadata +40 -8
@@ -0,0 +1,254 @@
|
|
1
|
+
require "git/si/git-control"
|
2
|
+
require "git/si/version"
|
3
|
+
|
4
|
+
describe Git::Si::GitControl do
|
5
|
+
describe ".status_command" do
|
6
|
+
it "returns the correct git command" do
|
7
|
+
expected = "git status --porcelain"
|
8
|
+
actual = Git::Si::GitControl.status_command
|
9
|
+
expect(actual).to eq(expected)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "includes extra arguments if specified" do
|
13
|
+
expected = "git status --porcelain foobar"
|
14
|
+
actual = Git::Si::GitControl.status_command( "foobar" )
|
15
|
+
expect(actual).to eq(expected)
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when a different binary is set" do
|
19
|
+
before do
|
20
|
+
Git::Si::GitControl.git_binary = "testbin"
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
Git::Si::GitControl.git_binary = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "uses the different binary" do
|
28
|
+
expected = "testbin status --porcelain"
|
29
|
+
actual = Git::Si::GitControl.status_command
|
30
|
+
expect(actual).to eq(expected)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".are_there_changes?" do
|
36
|
+
it "returns true if there are changes" do
|
37
|
+
data = "
|
38
|
+
M test1
|
39
|
+
"
|
40
|
+
expect(Git::Si::GitControl.are_there_changes?( data )).to be_truthy
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns true if there are additions" do
|
44
|
+
data = "
|
45
|
+
A test1
|
46
|
+
"
|
47
|
+
expect(Git::Si::GitControl.are_there_changes?( data )).to be_truthy
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns true if there are deletions" do
|
51
|
+
data = "
|
52
|
+
D test1
|
53
|
+
"
|
54
|
+
expect(Git::Si::GitControl.are_there_changes?( data )).to be_truthy
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns true if there are renamed files" do
|
58
|
+
data = "
|
59
|
+
R test1
|
60
|
+
"
|
61
|
+
expect(Git::Si::GitControl.are_there_changes?( data )).to be_truthy
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns true if there are copied files" do
|
65
|
+
data = "
|
66
|
+
C test1
|
67
|
+
"
|
68
|
+
expect(Git::Si::GitControl.are_there_changes?( data )).to be_truthy
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns false if there are no changes" do
|
72
|
+
data = "
|
73
|
+
?? testdir/
|
74
|
+
"
|
75
|
+
expect(Git::Si::GitControl.are_there_changes?( data )).to be_falsey
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe ".log_command" do
|
80
|
+
it "returns the correct git command" do
|
81
|
+
expect( Git::Si::GitControl.log_command ).to eq( "git log" )
|
82
|
+
end
|
83
|
+
|
84
|
+
it "includes extra arguments if specified" do
|
85
|
+
expect( Git::Si::GitControl.log_command( "--pretty=%B" ) ).to eq( "git log --pretty=%B" )
|
86
|
+
end
|
87
|
+
|
88
|
+
context "when a different binary is set" do
|
89
|
+
before do
|
90
|
+
Git::Si::GitControl.git_binary = "testbingit"
|
91
|
+
end
|
92
|
+
|
93
|
+
after do
|
94
|
+
Git::Si::GitControl.git_binary = nil
|
95
|
+
end
|
96
|
+
|
97
|
+
it "uses the different binary" do
|
98
|
+
expect(Git::Si::GitControl.log_command).to eq("testbingit log")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe ".parse_last_svn_revision" do
|
104
|
+
it "returns the correct svn version number" do
|
105
|
+
data = "
|
106
|
+
git-si 0.4.0 svn update to version 1015
|
107
|
+
|
108
|
+
some other commit
|
109
|
+
|
110
|
+
git-si 0.3.0 svn update to version 1014
|
111
|
+
"
|
112
|
+
expect(Git::Si::GitControl.parse_last_svn_revision( data )).to eq( '1015' )
|
113
|
+
end
|
114
|
+
|
115
|
+
it "returns nil if no version number could be found" do
|
116
|
+
expect(Git::Si::GitControl.parse_last_svn_revision( 'foobar' )).to be_nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe ".add_command" do
|
121
|
+
it "raises an error if no files are specified" do
|
122
|
+
expect { Git::Si::GitControl.add_command }.to raise_error
|
123
|
+
end
|
124
|
+
|
125
|
+
it "returns the correct command with files" do
|
126
|
+
expect( Git::Si::GitControl.add_command( "foobar" ) ).to eq( "git add foobar" )
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe ".commit_revision_command" do
|
131
|
+
it "raises an error if no version is specified" do
|
132
|
+
expect { Git::Si::GitControl.commit_revision_command }.to raise_error
|
133
|
+
end
|
134
|
+
|
135
|
+
it "returns the correct command with the revision" do
|
136
|
+
version = Git::Si::Version.version
|
137
|
+
expect( Git::Si::GitControl.commit_revision_command( 21356 ) ).to eq( "git commit --allow-empty -am 'git-si #{version} svn update to version 21356'" )
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe ".stash_command" do
|
142
|
+
it "returns the correct command" do
|
143
|
+
expect(Git::Si::GitControl.stash_command).to eq( "git stash" )
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe ".unstash_command" do
|
148
|
+
it "returns the correct command" do
|
149
|
+
expect(Git::Si::GitControl.unstash_command).to eq( "git stash pop" )
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe ".rebase_command" do
|
154
|
+
it "raises an error if no branch is specified" do
|
155
|
+
expect { Git::Si::GitControl.rebase_command }.to raise_error
|
156
|
+
end
|
157
|
+
|
158
|
+
it "returns the correct command with the branch" do
|
159
|
+
expect( Git::Si::GitControl.rebase_command( 'master' ) ).to eq( "git rebase 'master'" )
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe ".create_branch_command" do
|
164
|
+
it "returns the correct command" do
|
165
|
+
expect(Git::Si::GitControl.create_branch_command('foo')).to eq( "git branch foo" )
|
166
|
+
end
|
167
|
+
|
168
|
+
it "raises an error if no branch is specified" do
|
169
|
+
expect { Git::Si::GitControl.create_branch_command }.to raise_error
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe ".delete_branch_command" do
|
174
|
+
it "returns the correct command" do
|
175
|
+
expect(Git::Si::GitControl.delete_branch_command('foo')).to eq( "git branch -D foo" )
|
176
|
+
end
|
177
|
+
|
178
|
+
it "raises an error if no branch is specified" do
|
179
|
+
expect { Git::Si::GitControl.delete_branch_command }.to raise_error
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe ".branch_command" do
|
184
|
+
it "returns the correct command" do
|
185
|
+
expect(Git::Si::GitControl.branch_command).to eq( "git branch" )
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe ".parse_current_branch" do
|
190
|
+
it "returns the correct branch" do
|
191
|
+
data = "
|
192
|
+
MIRRORBRANCH
|
193
|
+
* master
|
194
|
+
"
|
195
|
+
expect(Git::Si::GitControl.parse_current_branch( data )).to eq( 'master' )
|
196
|
+
end
|
197
|
+
|
198
|
+
it "returns nil if no branch could be found" do
|
199
|
+
expect(Git::Si::GitControl.parse_current_branch( 'foobar' )).to be_nil
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe ".checkout_command" do
|
204
|
+
it "raises an error if no branch is specified" do
|
205
|
+
expect { Git::Si::GitControl.checkout_command }.to raise_error
|
206
|
+
end
|
207
|
+
|
208
|
+
it "returns the correct command with the branch" do
|
209
|
+
expect( Git::Si::GitControl.checkout_command( 'master' ) ).to eq( "git checkout master" )
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe ".hard_reset_command" do
|
214
|
+
it "returns the correct command" do
|
215
|
+
expect(Git::Si::GitControl.hard_reset_command).to eq( "git reset --hard HEAD" )
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe ".list_file_command" do
|
220
|
+
it "raises an error if no filename is specified" do
|
221
|
+
expect { Git::Si::GitControl.list_file_command }.to raise_error
|
222
|
+
end
|
223
|
+
|
224
|
+
it "returns the correct command" do
|
225
|
+
expect(Git::Si::GitControl.list_file_command('foobar')).to eq( "git ls-files foobar" )
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
describe ".init_command" do
|
230
|
+
it "returns the correct command" do
|
231
|
+
expect( Git::Si::GitControl.init_command ).to eq( "git init" )
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe ".show_branch_command" do
|
236
|
+
it "raises an error if no branch is specified" do
|
237
|
+
expect { Git::Si::GitControl.show_branch_command }.to raise_error
|
238
|
+
end
|
239
|
+
|
240
|
+
it "returns the correct command with the branch" do
|
241
|
+
expect( Git::Si::GitControl.show_branch_command( 'master' ) ).to eq( "git show-ref refs/heads/master" )
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe ".delete_command" do
|
246
|
+
it "raises an error if no filename is specified" do
|
247
|
+
expect { Git::Si::GitControl.delete_command }.to raise_error
|
248
|
+
end
|
249
|
+
|
250
|
+
it "returns the correct command" do
|
251
|
+
expect(Git::Si::GitControl.delete_command('foobar')).to eq( "git rm foobar" )
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "git/si/git-ignore"
|
2
|
+
|
3
|
+
describe Git::Si::GitIgnore do
|
4
|
+
describe ".ignore_patterns" do
|
5
|
+
it "allows .gitignore files" do
|
6
|
+
expect( Git::Si::GitIgnore.ignore_patterns ).to include( '!.gitignore' )
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".get_missing_lines_from" do
|
11
|
+
it "returns lines not present in the passed arguments" do
|
12
|
+
data = ["svn-commit.*", "*.orig"]
|
13
|
+
expect( Git::Si::GitIgnore.get_missing_lines_from( data ) ).to include( '*.log' )
|
14
|
+
end
|
15
|
+
|
16
|
+
it "does not return lines present in the passed arguments" do
|
17
|
+
data = ["svn-commit.*", "*.orig"]
|
18
|
+
expect( Git::Si::GitIgnore.get_missing_lines_from( data ) ).not_to include( '*.orig' )
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns an empty array if all the lines are present" do
|
22
|
+
data = Git::Si::GitIgnore.ignore_patterns
|
23
|
+
expect( Git::Si::GitIgnore.get_missing_lines_from( data ) ).to be_empty
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns lines not present in the passed arguments from the passed patterns" do
|
27
|
+
data = ["foo", "bar"]
|
28
|
+
expect( Git::Si::GitIgnore.get_missing_lines_from( data, ['baz'] ) ).to include( 'baz' )
|
29
|
+
end
|
30
|
+
|
31
|
+
it "does not return lines not present in the passed arguments from the passed patterns" do
|
32
|
+
data = ["foo", "bar"]
|
33
|
+
expect( Git::Si::GitIgnore.get_missing_lines_from( data, ['foo'] ) ).not_to include( 'bar' )
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,391 @@
|
|
1
|
+
require "git/si/svn-control"
|
2
|
+
|
3
|
+
describe Git::Si::SvnControl do
|
4
|
+
let( :svn_status_output ) {
|
5
|
+
"Z foobar
|
6
|
+
X foobar
|
7
|
+
M foobar.git
|
8
|
+
M foobar.swp
|
9
|
+
M barfoo
|
10
|
+
A something
|
11
|
+
D something else
|
12
|
+
? whatever
|
13
|
+
" }
|
14
|
+
|
15
|
+
let( :svn_info_output ) {
|
16
|
+
"
|
17
|
+
Path: .
|
18
|
+
Working Copy Root Path: /path/place
|
19
|
+
URL: file:///Users/path/place
|
20
|
+
Relative URL: ^/test
|
21
|
+
Repository Root: file:///Users/path/place
|
22
|
+
Repository UUID: 0101010101
|
23
|
+
Revision: 1014
|
24
|
+
Node Kind: directory
|
25
|
+
Schedule: normal
|
26
|
+
Last Changed Author: me
|
27
|
+
Last Changed Rev: 1
|
28
|
+
" }
|
29
|
+
|
30
|
+
let( :svn_update_output ) {
|
31
|
+
"
|
32
|
+
Restored 'bin/tests/importantthing'
|
33
|
+
A bin/tests/foobar
|
34
|
+
U bin/tests/api/goobar
|
35
|
+
G bin/tests/api/special
|
36
|
+
U bin/tests/api/anotherfile
|
37
|
+
A bin/tests/barfoo
|
38
|
+
? unknownfile.md
|
39
|
+
D byefile
|
40
|
+
C myimage.png
|
41
|
+
D badjs.js
|
42
|
+
C something/javascript.js
|
43
|
+
A something/newjs.js
|
44
|
+
C css/_base.scss
|
45
|
+
Updated to revision 113333.
|
46
|
+
Resolved conflicted state of 'weirdthing/weird.php'
|
47
|
+
" }
|
48
|
+
|
49
|
+
describe ".status_command" do
|
50
|
+
it "returns the correct svn command" do
|
51
|
+
expected = "svn status --ignore-externals"
|
52
|
+
actual = Git::Si::SvnControl.status_command
|
53
|
+
expect(actual).to eq(expected)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "includes extra arguments if specified" do
|
57
|
+
expected = "svn status --ignore-externals --verbose"
|
58
|
+
actual = Git::Si::SvnControl.status_command( "--verbose" )
|
59
|
+
expect(actual).to eq(expected)
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when a different binary is set" do
|
63
|
+
before do
|
64
|
+
Git::Si::SvnControl.svn_binary = "testbin"
|
65
|
+
end
|
66
|
+
|
67
|
+
after do
|
68
|
+
Git::Si::SvnControl.svn_binary = nil
|
69
|
+
end
|
70
|
+
|
71
|
+
it "uses the different binary" do
|
72
|
+
expected = "testbin status --ignore-externals"
|
73
|
+
actual = Git::Si::SvnControl.status_command
|
74
|
+
expect(actual).to eq(expected)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe ".diff_command" do
|
80
|
+
it "returns the correct svn command" do
|
81
|
+
expected = "svn diff"
|
82
|
+
actual = Git::Si::SvnControl.diff_command
|
83
|
+
expect(actual).to eq(expected)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "includes extra arguments if specified" do
|
87
|
+
expected = "svn diff foobar"
|
88
|
+
actual = Git::Si::SvnControl.diff_command( "foobar" )
|
89
|
+
expect(actual).to eq(expected)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe ".info_command" do
|
94
|
+
it "returns the correct svn command" do
|
95
|
+
expected = "svn info"
|
96
|
+
actual = Git::Si::SvnControl.info_command
|
97
|
+
expect(actual).to eq(expected)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe ".parse_last_revision" do
|
102
|
+
it "returns nil from incorrect data" do
|
103
|
+
actual = Git::Si::SvnControl.parse_last_revision('foobar 12345')
|
104
|
+
expect(actual).to be_nil
|
105
|
+
end
|
106
|
+
|
107
|
+
it "returns the revision number from correct data" do
|
108
|
+
expected = "1014"
|
109
|
+
actual = Git::Si::SvnControl.parse_last_revision( svn_info_output )
|
110
|
+
expect(actual).to eq(expected)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe ".add_command" do
|
115
|
+
it "raises an error if no files are specified" do
|
116
|
+
expect { Git::Si::SvnControl.add_command }.to raise_error
|
117
|
+
end
|
118
|
+
|
119
|
+
it "returns the correct command with a file" do
|
120
|
+
expect( Git::Si::SvnControl.add_command( "foobar" ) ).to eq( "svn add foobar" )
|
121
|
+
end
|
122
|
+
|
123
|
+
it "returns the correct command with an array of files" do
|
124
|
+
expect( Git::Si::SvnControl.add_command( ["foobar", "barfoo"] ) ).to eq( "svn add foobar barfoo" )
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe ".update_command" do
|
129
|
+
it "returns the correct command" do
|
130
|
+
expect( Git::Si::SvnControl.update_command ).to eq( "svn up --accept theirs-full --ignore-externals" )
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe ".parse_updated_files" do
|
135
|
+
it "returns files that have been added" do
|
136
|
+
expected = [
|
137
|
+
'bin/tests/foobar',
|
138
|
+
'bin/tests/barfoo'
|
139
|
+
]
|
140
|
+
expect( Git::Si::SvnControl.parse_updated_files( svn_update_output ) ).to include( *expected )
|
141
|
+
end
|
142
|
+
|
143
|
+
it "returns files that have been restored" do
|
144
|
+
expected = [
|
145
|
+
'bin/tests/importantthing'
|
146
|
+
]
|
147
|
+
expect( Git::Si::SvnControl.parse_updated_files( svn_update_output ) ).to include( *expected )
|
148
|
+
end
|
149
|
+
|
150
|
+
it "returns files that are updated" do
|
151
|
+
expected = [
|
152
|
+
'bin/tests/api/goobar',
|
153
|
+
'bin/tests/api/special',
|
154
|
+
'bin/tests/api/anotherfile'
|
155
|
+
]
|
156
|
+
expect( Git::Si::SvnControl.parse_updated_files( svn_update_output ) ).to include( *expected )
|
157
|
+
end
|
158
|
+
|
159
|
+
it "returns files that are resolved conflicts" do
|
160
|
+
expected = [
|
161
|
+
'weirdthing/weird.php'
|
162
|
+
]
|
163
|
+
expect( Git::Si::SvnControl.parse_updated_files( svn_update_output ) ).to include( *expected )
|
164
|
+
end
|
165
|
+
|
166
|
+
it "does not return files that are in conflict" do
|
167
|
+
expected = [
|
168
|
+
'myimage.png',
|
169
|
+
'css/_base.scss',
|
170
|
+
'something/javascript.js'
|
171
|
+
]
|
172
|
+
expect( Git::Si::SvnControl.parse_updated_files( svn_update_output ) ).not_to include( *expected )
|
173
|
+
end
|
174
|
+
|
175
|
+
it "does not return files that are deleted" do
|
176
|
+
expected = [
|
177
|
+
'byefile',
|
178
|
+
'badjs.js'
|
179
|
+
]
|
180
|
+
expect( Git::Si::SvnControl.parse_updated_files( svn_update_output ) ).not_to include( *expected )
|
181
|
+
end
|
182
|
+
|
183
|
+
it "returns files whose properties have been updated" do
|
184
|
+
expected = [
|
185
|
+
'something/newjs.js'
|
186
|
+
]
|
187
|
+
expect( Git::Si::SvnControl.parse_updated_files( svn_update_output ) ).to include( *expected )
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe ".parse_deleted_files" do
|
192
|
+
it "does not return files that are deleted" do
|
193
|
+
expected = [
|
194
|
+
'byefile',
|
195
|
+
'badjs.js'
|
196
|
+
]
|
197
|
+
expect( Git::Si::SvnControl.parse_deleted_files( svn_update_output ) ).to include( *expected )
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe ".parse_conflicted_files" do
|
202
|
+
it "returns files that are resolved conflicts" do
|
203
|
+
expected = [
|
204
|
+
'weirdthing/weird.php'
|
205
|
+
]
|
206
|
+
expect( Git::Si::SvnControl.parse_conflicted_files( svn_update_output ) ).to include( *expected )
|
207
|
+
end
|
208
|
+
|
209
|
+
it "returns files which have conflicts" do
|
210
|
+
expected = [
|
211
|
+
'myimage.png',
|
212
|
+
'css/_base.scss',
|
213
|
+
'something/javascript.js'
|
214
|
+
]
|
215
|
+
expect( Git::Si::SvnControl.parse_conflicted_files( svn_update_output ) ).to include( *expected )
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe ".parse_unknown_files" do
|
220
|
+
it "returns files that are not tracked" do
|
221
|
+
expected = [
|
222
|
+
'unknownfile.md'
|
223
|
+
]
|
224
|
+
expect( Git::Si::SvnControl.parse_unknown_files( svn_update_output ) ).to include( *expected )
|
225
|
+
end
|
226
|
+
|
227
|
+
it "does not return files that are tracked" do
|
228
|
+
expected = [
|
229
|
+
'myimage.png',
|
230
|
+
'css/_base.scss',
|
231
|
+
'something/javascript.js'
|
232
|
+
]
|
233
|
+
expect( Git::Si::SvnControl.parse_unknown_files( svn_update_output ) ).not_to include( *expected )
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe ".revert_command" do
|
238
|
+
it "returns the correct command for all files" do
|
239
|
+
expect( Git::Si::SvnControl.revert_command ).to eq('svn revert -R .')
|
240
|
+
end
|
241
|
+
|
242
|
+
it "returns the correct command for some files" do
|
243
|
+
expect( Git::Si::SvnControl.revert_command(['foobar', 'barfoo']) ).to eq('svn revert -R foobar barfoo')
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
describe ".commit_command" do
|
248
|
+
it "returns the correct command for all files" do
|
249
|
+
expect( Git::Si::SvnControl.commit_command ).to eq('svn commit')
|
250
|
+
end
|
251
|
+
|
252
|
+
it "returns the correct command for some files" do
|
253
|
+
expect( Git::Si::SvnControl.commit_command(['foobar', 'barfoo']) ).to eq('svn commit foobar barfoo')
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe ".blame_command" do
|
258
|
+
it "raises an error with no files" do
|
259
|
+
expect { Git::Si::SvnControl.blame_command }.to raise_error
|
260
|
+
end
|
261
|
+
|
262
|
+
it "returns the correct command" do
|
263
|
+
expect( Git::Si::SvnControl.blame_command('foobar') ).to eq( 'svn blame foobar' )
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
describe ".parse_root_path" do
|
268
|
+
it "raises an error with no data" do
|
269
|
+
expect { Git::Si::SvnControl.parse_root_path }.to raise_error
|
270
|
+
end
|
271
|
+
|
272
|
+
it "returns the correct root path" do
|
273
|
+
data = "
|
274
|
+
Path: .
|
275
|
+
Working Copy Root Path: /Users/foobar/git-si/testdir/test-copy
|
276
|
+
URL: file:///Users/foobar/git-si/testdir/SVNrep/test
|
277
|
+
Relative URL: ^/test
|
278
|
+
Repository Root: file:///Users/foobar/git-si/testdir/SVNrep
|
279
|
+
Repository UUID: 0101010101
|
280
|
+
Revision: 1432
|
281
|
+
"
|
282
|
+
expect( Git::Si::SvnControl.parse_root_path(data) ).to eq( '/Users/foobar/git-si/testdir/test-copy' )
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
describe ".list_file_command" do
|
287
|
+
it "returns the correct command" do
|
288
|
+
expect( Git::Si::SvnControl.list_file_command ).to eq( 'svn list -R' )
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
describe ".parse_file_list" do
|
293
|
+
let ( :svn_list_output ) { "
|
294
|
+
.hiddenfile
|
295
|
+
.hiddendir/
|
296
|
+
.hiddendir/regularfile.txt
|
297
|
+
myimage.png
|
298
|
+
something/
|
299
|
+
something/.subhidden/
|
300
|
+
something/.subhidden/regularfile.txt
|
301
|
+
something/javascript.js
|
302
|
+
" }
|
303
|
+
|
304
|
+
it "returns files in the list" do
|
305
|
+
expected = [
|
306
|
+
'myimage.png',
|
307
|
+
'something/javascript.js'
|
308
|
+
]
|
309
|
+
expect( Git::Si::SvnControl.parse_file_list( svn_list_output ) ).to include( *expected )
|
310
|
+
end
|
311
|
+
|
312
|
+
it "does not return directories" do
|
313
|
+
expected = [
|
314
|
+
'something/'
|
315
|
+
]
|
316
|
+
expect( Git::Si::SvnControl.parse_file_list( svn_list_output ) ).not_to include( *expected )
|
317
|
+
end
|
318
|
+
|
319
|
+
it "does not return empty strings" do
|
320
|
+
expected = [
|
321
|
+
'',
|
322
|
+
' ',
|
323
|
+
]
|
324
|
+
expect( Git::Si::SvnControl.parse_file_list( svn_list_output ) ).not_to include( *expected )
|
325
|
+
end
|
326
|
+
|
327
|
+
it "does not return hidden files or files in hidden directories" do
|
328
|
+
expected = [
|
329
|
+
'.hiddenfile',
|
330
|
+
'.hiddendir/regularfile.txt',
|
331
|
+
'something/.subhidden/regularfile.txt'
|
332
|
+
]
|
333
|
+
expect( Git::Si::SvnControl.parse_file_list( svn_list_output ) ).not_to include( *expected )
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
describe ".parse_external_repos" do
|
338
|
+
it "includes lines beginning with 'X'" do
|
339
|
+
expected = [ 'foobar' ]
|
340
|
+
actual = Git::Si::SvnControl.parse_external_repos( svn_status_output )
|
341
|
+
expect(actual).to include(*expected)
|
342
|
+
end
|
343
|
+
|
344
|
+
it "excludes lines starting with 'M'" do
|
345
|
+
expected = [ 'barfoo' ]
|
346
|
+
actual = Git::Si::SvnControl.parse_external_repos( svn_status_output )
|
347
|
+
expect(actual).not_to include(expected)
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
describe ".parse_svn_status" do
|
352
|
+
it "excludes lines beginning with 'X'" do
|
353
|
+
expected = 'X foobar'
|
354
|
+
actual = Git::Si::SvnControl.parse_svn_status( svn_status_output )
|
355
|
+
expect(actual).to_not include(expected)
|
356
|
+
end
|
357
|
+
|
358
|
+
it "excludes lines ending with '.git'" do
|
359
|
+
expected = 'foobar.git'
|
360
|
+
actual = Git::Si::SvnControl.parse_svn_status( svn_status_output )
|
361
|
+
expect(actual).to_not include(expected)
|
362
|
+
end
|
363
|
+
|
364
|
+
it "excludes lines ending with '.swp'" do
|
365
|
+
expected = 'foobar.swp'
|
366
|
+
actual = Git::Si::SvnControl.parse_svn_status( svn_status_output )
|
367
|
+
expect(actual).to_not include(expected)
|
368
|
+
end
|
369
|
+
|
370
|
+
it "includes lines starting with 'M'" do
|
371
|
+
expected = 'M barfoo'
|
372
|
+
actual = Git::Si::SvnControl.parse_svn_status( svn_status_output )
|
373
|
+
expect(actual).to include(expected)
|
374
|
+
end
|
375
|
+
|
376
|
+
it "includes lines starting with 'A'" do
|
377
|
+
expected = 'A something'
|
378
|
+
actual = Git::Si::SvnControl.parse_svn_status( svn_status_output )
|
379
|
+
expect(actual).to include(expected)
|
380
|
+
end
|
381
|
+
|
382
|
+
it "includes lines starting with '?'" do
|
383
|
+
expected = '? whatever'
|
384
|
+
actual = Git::Si::SvnControl.parse_svn_status( svn_status_output )
|
385
|
+
expect(actual).to include(expected)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
end
|
390
|
+
|
391
|
+
|