@@ -17,6 +17,7 @@ import (
17
17
"unicode"
18
18
19
19
"code.gitea.io/gitea/modules/base"
20
+ "code.gitea.io/gitea/modules/git"
20
21
"code.gitea.io/gitea/modules/log"
21
22
"code.gitea.io/gitea/modules/setting"
22
23
api "code.gitea.io/gitea/modules/structs"
@@ -385,7 +386,7 @@ func NewPushCommits() *PushCommits {
385
386
386
387
// ToAPIPayloadCommits converts a PushCommits object to
387
388
// api.PayloadCommit format.
388
- func (pc * PushCommits ) ToAPIPayloadCommits (repoLink string ) []* api.PayloadCommit {
389
+ func (pc * PushCommits ) ToAPIPayloadCommits (repoPath , repoLink string ) ( []* api.PayloadCommit , error ) {
389
390
commits := make ([]* api.PayloadCommit , len (pc .Commits ))
390
391
391
392
if pc .emailUsers == nil {
@@ -417,6 +418,12 @@ func (pc *PushCommits) ToAPIPayloadCommits(repoLink string) []*api.PayloadCommit
417
418
} else {
418
419
committerUsername = committer .Name
419
420
}
421
+
422
+ fileStatus , err := git .GetCommitFileStatus (repoPath , commit .Sha1 )
423
+ if err != nil {
424
+ return nil , fmt .Errorf ("FileStatus [commit_sha1: %s]: %v" , commit .Sha1 , err )
425
+ }
426
+
420
427
commits [i ] = & api.PayloadCommit {
421
428
ID : commit .Sha1 ,
422
429
Message : commit .Message ,
@@ -431,10 +438,13 @@ func (pc *PushCommits) ToAPIPayloadCommits(repoLink string) []*api.PayloadCommit
431
438
Email : commit .CommitterEmail ,
432
439
UserName : committerUsername ,
433
440
},
441
+ Added : fileStatus .Added ,
442
+ Removed : fileStatus .Removed ,
443
+ Modified : fileStatus .Modified ,
434
444
Timestamp : commit .Timestamp ,
435
445
}
436
446
}
437
- return commits
447
+ return commits , nil
438
448
}
439
449
440
450
// AvatarLink tries to match user in database with e-mail
@@ -738,7 +748,10 @@ func MirrorSyncPushAction(repo *Repository, opts MirrorSyncPushActionOptions) er
738
748
opts .Commits .Commits = opts .Commits .Commits [:setting .UI .FeedMaxCommitNum ]
739
749
}
740
750
741
- apiCommits := opts .Commits .ToAPIPayloadCommits (repo .HTMLURL ())
751
+ apiCommits , err := opts .Commits .ToAPIPayloadCommits (repo .RepoPath (), repo .HTMLURL ())
752
+ if err != nil {
753
+ return err
754
+ }
742
755
743
756
opts .Commits .CompareURL = repo .ComposeCompareURL (opts .OldCommitID , opts .NewCommitID )
744
757
apiPusher := repo .MustOwner ().APIFormat ()
0 commit comments