@@ -30,7 +30,6 @@ import (
30
30
"code.gitea.io/gitea/modules/log"
31
31
"code.gitea.io/gitea/modules/markup"
32
32
"code.gitea.io/gitea/modules/options"
33
- "code.gitea.io/gitea/modules/process"
34
33
"code.gitea.io/gitea/modules/setting"
35
34
"code.gitea.io/gitea/modules/structs"
36
35
api "code.gitea.io/gitea/modules/structs"
@@ -1202,11 +1201,11 @@ func initRepoCommit(tmpPath string, u *User) (err error) {
1202
1201
"GIT_COMMITTER_DATE=" + commitTimeStr ,
1203
1202
)
1204
1203
1205
- var stderr string
1206
- if _ , stderr , err = process . GetManager (). ExecDir ( - 1 ,
1207
- tmpPath , fmt . Sprintf ( "initRepoCommit (git add): %s" , tmpPath ),
1208
- git . GitExecutable , " add" , " --all" ); err != nil {
1209
- return fmt .Errorf ("git add: %s " , stderr )
1204
+ if stdout , err := git . NewCommand ( "add" , "--all" ).
1205
+ SetDescription ( fmt . Sprintf ( "initRepoCommit (git add): %s" , tmpPath )).
1206
+ RunInDir ( tmpPath ); err != nil {
1207
+ log . Error ( "git add --all failed: Stdout: %s \n Error: %v" , stdout , err )
1208
+ return fmt .Errorf ("git add --all : %v " , err )
1210
1209
}
1211
1210
1212
1211
binVersion , err := git .BinVersion ()
@@ -1228,18 +1227,20 @@ func initRepoCommit(tmpPath string, u *User) (err error) {
1228
1227
}
1229
1228
}
1230
1229
1231
- if _ , stderr , err = process . GetManager (). ExecDirEnv ( - 1 ,
1232
- tmpPath , fmt .Sprintf ("initRepoCommit (git commit): %s" , tmpPath ),
1233
- env ,
1234
- git . GitExecutable , args ... ); err != nil {
1235
- return fmt .Errorf ("git commit: %s " , stderr )
1230
+ if stdout , err := git . NewCommand ( args ... ).
1231
+ SetDescription ( fmt .Sprintf ("initRepoCommit (git commit): %s" , tmpPath )).
1232
+ RunInDirWithEnv ( tmpPath , env ); err != nil {
1233
+ log . Error ( "Failed to commit: %v: Stdout: %s \n Error: %v" , args , stdout , err )
1234
+ return fmt .Errorf ("git commit: %v " , err )
1236
1235
}
1237
1236
1238
- if _ , stderr , err = process .GetManager ().ExecDir (- 1 ,
1239
- tmpPath , fmt .Sprintf ("initRepoCommit (git push): %s" , tmpPath ),
1240
- git .GitExecutable , "push" , "origin" , "master" ); err != nil {
1241
- return fmt .Errorf ("git push: %s" , stderr )
1237
+ if stdout , err := git .NewCommand ("push" , "origin" , "master" ).
1238
+ SetDescription (fmt .Sprintf ("initRepoCommit (git push): %s" , tmpPath )).
1239
+ RunInDir (tmpPath ); err != nil {
1240
+ log .Error ("Failed to push back to master: Stdout: %s\n Error: %v" , stdout , err )
1241
+ return fmt .Errorf ("git push: %v" , err )
1242
1242
}
1243
+
1243
1244
return nil
1244
1245
}
1245
1246
@@ -1297,14 +1298,11 @@ func prepareRepoCommit(e Engine, repo *Repository, tmpDir, repoPath string, opts
1297
1298
)
1298
1299
1299
1300
// Clone to temporary path and do the init commit.
1300
- _ , stderr , err := process .GetManager ().ExecDirEnv (
1301
- - 1 , "" ,
1302
- fmt .Sprintf ("initRepository(git clone): %s" , repoPath ),
1303
- env ,
1304
- git .GitExecutable , "clone" , repoPath , tmpDir ,
1305
- )
1306
- if err != nil {
1307
- return fmt .Errorf ("git clone: %v - %s" , err , stderr )
1301
+ if stdout , err := git .NewCommand ("clone" , repoPath , tmpDir ).
1302
+ SetDescription (fmt .Sprintf ("initRepository (git clone): %s to %s" , repoPath , tmpDir )).
1303
+ RunInDirWithEnv ("" , env ); err != nil {
1304
+ log .Error ("Failed to clone from %v into %s: stdout: %s\n Error: %v" , repo , tmpDir , stdout , err )
1305
+ return fmt .Errorf ("git clone: %v" , err )
1308
1306
}
1309
1307
1310
1308
// README
@@ -1584,11 +1582,11 @@ func CreateRepository(doer, u *User, opts CreateRepoOptions) (_ *Repository, err
1584
1582
}
1585
1583
}
1586
1584
1587
- _ , stderr , err := process . GetManager (). ExecDir ( - 1 ,
1588
- repoPath , fmt .Sprintf ("CreateRepository(git update-server-info): %s" , repoPath ),
1589
- git . GitExecutable , "update-server-info" )
1590
- if err != nil {
1591
- return nil , errors . New ("CreateRepository(git update-server-info): " + stderr )
1585
+ if stdout , err := git . NewCommand ( "update-server-info" ).
1586
+ SetDescription ( fmt .Sprintf ("CreateRepository(git update-server-info): %s" , repoPath )).
1587
+ RunInDir ( repoPath ); err != nil {
1588
+ log . Error ( "CreateRepitory(git update-server-info) in %v: Stdout: %s \n Error: %v" , repo , stdout , err )
1589
+ return nil , fmt . Errorf ("CreateRepository(git update-server-info): %v" , err )
1592
1590
}
1593
1591
}
1594
1592
@@ -2422,12 +2420,13 @@ func GitGcRepos() error {
2422
2420
if err := repo .GetOwner (); err != nil {
2423
2421
return err
2424
2422
}
2425
- _ , stderr , err := process .GetManager ().ExecDir (
2426
- time .Duration (setting .Git .Timeout .GC )* time .Second ,
2427
- RepoPath (repo .Owner .Name , repo .Name ), "Repository garbage collection" ,
2428
- git .GitExecutable , args ... )
2429
- if err != nil {
2430
- return fmt .Errorf ("%v: %v" , err , stderr )
2423
+ if stdout , err := git .NewCommand (args ... ).
2424
+ SetDescription (fmt .Sprintf ("Repository Garbage Collection: %s" , repo .FullName ())).
2425
+ RunInDirTimeout (
2426
+ time .Duration (setting .Git .Timeout .GC )* time .Second ,
2427
+ RepoPath (repo .Owner .Name , repo .Name )); err != nil {
2428
+ log .Error ("Repository garbage collection failed for %v. Stdout: %s\n Error: %v" , repo , stdout , err )
2429
+ return fmt .Errorf ("Repository garbage collection failed: Error: %v" , err )
2431
2430
}
2432
2431
return nil
2433
2432
})
@@ -2647,18 +2646,19 @@ func ForkRepository(doer, owner *User, oldRepo *Repository, name, desc string) (
2647
2646
}
2648
2647
2649
2648
repoPath := RepoPath (owner .Name , repo .Name )
2650
- _ , stderr , err := process .GetManager ().ExecTimeout (10 * time .Minute ,
2651
- fmt .Sprintf ("ForkRepository(git clone): %s/%s" , owner .Name , repo .Name ),
2652
- git .GitExecutable , "clone" , "--bare" , oldRepo .repoPath (sess ), repoPath )
2653
- if err != nil {
2654
- return nil , fmt .Errorf ("git clone: %v" , stderr )
2655
- }
2656
-
2657
- _ , stderr , err = process .GetManager ().ExecDir (- 1 ,
2658
- repoPath , fmt .Sprintf ("ForkRepository(git update-server-info): %s" , repoPath ),
2659
- git .GitExecutable , "update-server-info" )
2660
- if err != nil {
2661
- return nil , fmt .Errorf ("git update-server-info: %v" , stderr )
2649
+ if stdout , err := git .NewCommand (
2650
+ "clone" , "--bare" , oldRepo .repoPath (sess ), repoPath ).
2651
+ SetDescription (fmt .Sprintf ("ForkRepository(git clone): %s to %s" , oldRepo .FullName (), repo .FullName ())).
2652
+ RunInDirTimeout (10 * time .Minute , "" ); err != nil {
2653
+ log .Error ("Fork Repository (git clone) Failed for %v (from %v):\n Stdout: %s\n Error: %v" , repo , oldRepo , stdout , err )
2654
+ return nil , fmt .Errorf ("git clone: %v" , err )
2655
+ }
2656
+
2657
+ if stdout , err := git .NewCommand ("update-server-info" ).
2658
+ SetDescription (fmt .Sprintf ("ForkRepository(git update-server-info): %s" , repo .FullName ())).
2659
+ RunInDir (repoPath ); err != nil {
2660
+ log .Error ("Fork Repository (git update-server-info) failed for %v:\n Stdout: %s\n Error: %v" , repo , stdout , err )
2661
+ return nil , fmt .Errorf ("git update-server-info: %v" , err )
2662
2662
}
2663
2663
2664
2664
if err = createDelegateHooks (repoPath ); err != nil {
0 commit comments