@@ -105,6 +105,8 @@ IEnumerator IEnumerable.GetEnumerator()
105
105
/// <param name = "path">The path of the file within the working directory.</param>
106
106
public void Stage ( string path )
107
107
{
108
+ Ensure . ArgumentNotNull ( path , "path" ) ;
109
+
108
110
Stage ( new [ ] { path } ) ;
109
111
}
110
112
@@ -114,18 +116,11 @@ public void Stage(string path)
114
116
/// <param name = "paths">The collection of paths of the files within the working directory.</param>
115
117
public void Stage ( IEnumerable < string > paths )
116
118
{
117
- Ensure . ArgumentNotNull ( paths , "paths" ) ;
118
-
119
119
//TODO: Stage() should support following use cases:
120
120
// - Recursively staging the content of a directory
121
121
122
122
IDictionary < string , FileStatus > batch = PrepareBatch ( paths ) ;
123
123
124
- if ( batch . Count == 0 )
125
- {
126
- throw new ArgumentNullException ( "paths" ) ;
127
- }
128
-
129
124
foreach ( KeyValuePair < string , FileStatus > kvp in batch )
130
125
{
131
126
if ( Directory . Exists ( kvp . Key ) )
@@ -165,6 +160,8 @@ public void Stage(IEnumerable<string> paths)
165
160
/// <param name = "path">The path of the file within the working directory.</param>
166
161
public void Unstage ( string path )
167
162
{
163
+ Ensure . ArgumentNotNull ( path , "path" ) ;
164
+
168
165
Unstage ( new [ ] { path } ) ;
169
166
}
170
167
@@ -174,15 +171,8 @@ public void Unstage(string path)
174
171
/// <param name = "paths">The collection of paths of the files within the working directory.</param>
175
172
public void Unstage ( IEnumerable < string > paths )
176
173
{
177
- Ensure . ArgumentNotNull ( paths , "paths" ) ;
178
-
179
174
IDictionary < string , FileStatus > batch = PrepareBatch ( paths ) ;
180
175
181
- if ( batch . Count == 0 )
182
- {
183
- throw new ArgumentNullException ( "paths" ) ;
184
- }
185
-
186
176
foreach ( KeyValuePair < string , FileStatus > kvp in batch )
187
177
{
188
178
if ( Directory . Exists ( kvp . Key ) )
@@ -291,6 +281,8 @@ public void Move(IEnumerable<string> sourcePaths, IEnumerable<string> destinatio
291
281
/// <param name = "path">The path of the file within the working directory.</param>
292
282
public void Remove ( string path )
293
283
{
284
+ Ensure . ArgumentNotNull ( path , "path" ) ;
285
+
294
286
Remove ( new [ ] { path } ) ;
295
287
}
296
288
@@ -304,18 +296,11 @@ public void Remove(string path)
304
296
/// <param name = "paths">The collection of paths of the files within the working directory.</param>
305
297
public void Remove ( IEnumerable < string > paths )
306
298
{
307
- Ensure . ArgumentNotNull ( paths , "paths" ) ;
308
-
309
299
//TODO: Remove() should support following use cases:
310
300
// - Removing a directory and its content
311
301
312
302
IDictionary < string , FileStatus > batch = PrepareBatch ( paths ) ;
313
303
314
- if ( batch . Count == 0 )
315
- {
316
- throw new ArgumentNullException ( "paths" ) ;
317
- }
318
-
319
304
foreach ( KeyValuePair < string , FileStatus > keyValuePair in batch )
320
305
{
321
306
if ( Directory . Exists ( keyValuePair . Key ) )
@@ -347,16 +332,28 @@ public void Remove(IEnumerable<string> paths)
347
332
348
333
private IDictionary < string , FileStatus > PrepareBatch ( IEnumerable < string > paths )
349
334
{
335
+ Ensure . ArgumentNotNull ( paths , "paths" ) ;
336
+
350
337
IDictionary < string , FileStatus > dic = new Dictionary < string , FileStatus > ( ) ;
351
338
352
339
foreach ( string path in paths )
353
340
{
341
+ if ( string . IsNullOrEmpty ( path ) )
342
+ {
343
+ throw new ArgumentException ( "At least one provided path is either null or empty." , "paths" ) ;
344
+ }
345
+
354
346
string relativePath = BuildRelativePathFrom ( repo , path ) ;
355
347
FileStatus fileStatus = RetrieveStatus ( relativePath ) ;
356
348
357
349
dic . Add ( relativePath , fileStatus ) ;
358
350
}
359
351
352
+ if ( dic . Count == 0 )
353
+ {
354
+ throw new ArgumentException ( "No path has been provided." , "paths" ) ;
355
+ }
356
+
360
357
return dic ;
361
358
}
362
359
0 commit comments