@@ -422,6 +422,9 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
422
422
tmpDir , err := ioutil .TempDir ("" , ctx .Reponame )
423
423
assert .NoError (t , err )
424
424
425
+ _ , err = git .NewCommand ("clone" , u .String ()).RunInDir (tmpDir )
426
+ assert .Error (t , err )
427
+
425
428
err = git .InitRepository (tmpDir , false )
426
429
assert .NoError (t , err )
427
430
@@ -449,13 +452,26 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
449
452
_ , err = git .NewCommand ("remote" , "add" , "origin" , u .String ()).RunInDir (tmpDir )
450
453
assert .NoError (t , err )
451
454
455
+ invalidCtx := ctx
456
+ invalidCtx .Reponame = fmt .Sprintf ("invalid/repo-tmp-push-create-%s" , u .Scheme )
457
+ u .Path = invalidCtx .GitPath ()
458
+
459
+ _ , err = git .NewCommand ("remote" , "add" , "invalid" , u .String ()).RunInDir (tmpDir )
460
+ assert .NoError (t , err )
461
+
452
462
// Push to create disabled
453
463
setting .Repository .EnablePushCreateUser = false
454
464
_ , err = git .NewCommand ("push" , "origin" , "master" ).RunInDir (tmpDir )
455
465
assert .Error (t , err )
456
466
457
467
// Push to create enabled
458
468
setting .Repository .EnablePushCreateUser = true
469
+
470
+ // Invalid repo
471
+ _ , err = git .NewCommand ("push" , "invalid" , "master" ).RunInDir (tmpDir )
472
+ assert .Error (t , err )
473
+
474
+ // Valid repo
459
475
_ , err = git .NewCommand ("push" , "origin" , "master" ).RunInDir (tmpDir )
460
476
assert .NoError (t , err )
461
477
0 commit comments