File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -234,7 +234,19 @@ public function getLocalBranches()
234
234
*/
235
235
public function checkout ($ name )
236
236
{
237
- $ this ->run ('checkout ' , '--end-of-options ' , $ name );
237
+ if (!is_string ($ name )) {
238
+ throw new InvalidArgumentException ('Branch name must be string. ' );
239
+ }
240
+
241
+ if ($ name === '' ) {
242
+ throw new InvalidArgumentException ('Branch name cannot be empty. ' );
243
+ }
244
+
245
+ if ($ name [0 ] === '- ' ) {
246
+ throw new InvalidArgumentException ('Branch name cannot be option name. ' );
247
+ }
248
+
249
+ $ this ->run ('checkout ' , $ name );
238
250
return $ this ;
239
251
}
240
252
Original file line number Diff line number Diff line change @@ -12,10 +12,10 @@ $git = new Git($runner);
12
12
13
13
$ runner ->assert (['branch ' , '--end-of-options ' , 'master ' ]);
14
14
$ runner ->assert (['branch ' , '--end-of-options ' , 'develop ' ]);
15
- $ runner ->assert (['checkout ' , '--end-of-options ' , ' develop ' ]);
15
+ $ runner ->assert (['checkout ' , 'develop ' ]);
16
16
$ runner ->assert (['merge ' , '--end-of-options ' , 'feature-1 ' ]);
17
17
$ runner ->assert (['branch ' , '-d ' , 'feature-1 ' ]);
18
- $ runner ->assert (['checkout ' , '--end-of-options ' , ' master ' ]);
18
+ $ runner ->assert (['checkout ' , 'master ' ]);
19
19
20
20
$ repo = $ git ->open (__DIR__ );
21
21
$ repo ->createBranch ('master ' );
You can’t perform that action at this time.
0 commit comments