@@ -352,7 +352,7 @@ func NewPushCommits() *PushCommits {
352
352
353
353
// ToAPIPayloadCommits converts a PushCommits object to
354
354
// api.PayloadCommit format.
355
- func (pc * PushCommits ) ToAPIPayloadCommits (repoLink string ) []* api.PayloadCommit {
355
+ func (pc * PushCommits ) ToAPIPayloadCommits (repoPath , repoLink string ) ( []* api.PayloadCommit , error ) {
356
356
commits := make ([]* api.PayloadCommit , len (pc .Commits ))
357
357
358
358
if pc .emailUsers == nil {
@@ -367,6 +367,8 @@ func (pc *PushCommits) ToAPIPayloadCommits(repoLink string) []*api.PayloadCommit
367
367
if err == nil {
368
368
authorUsername = author .Name
369
369
pc .emailUsers [commit .AuthorEmail ] = author
370
+ } else if ! IsErrUserNotExist (err ) {
371
+ return nil , fmt .Errorf ("GetUserByEmail: %v" , err )
370
372
}
371
373
} else {
372
374
authorUsername = author .Name
@@ -380,10 +382,18 @@ func (pc *PushCommits) ToAPIPayloadCommits(repoLink string) []*api.PayloadCommit
380
382
// TODO: check errors other than email not found.
381
383
committerUsername = committer .Name
382
384
pc .emailUsers [commit .CommitterEmail ] = committer
385
+ } else if ! IsErrUserNotExist (err ) {
386
+ return nil , fmt .Errorf ("GetUserByEmail: %v" , err )
383
387
}
384
388
} else {
385
389
committerUsername = committer .Name
386
390
}
391
+
392
+ fileStatus , err := git .GetCommitFileStatus (repoPath , commit .Sha1 )
393
+ if err != nil {
394
+ return nil , fmt .Errorf ("FileStatus [commit_sha1: %s]: %v" , commit .Sha1 , err )
395
+ }
396
+
387
397
commits [i ] = & api.PayloadCommit {
388
398
ID : commit .Sha1 ,
389
399
Message : commit .Message ,
@@ -398,10 +408,13 @@ func (pc *PushCommits) ToAPIPayloadCommits(repoLink string) []*api.PayloadCommit
398
408
Email : commit .CommitterEmail ,
399
409
UserName : committerUsername ,
400
410
},
411
+ Added : fileStatus .Added ,
412
+ Removed : fileStatus .Removed ,
413
+ Modified : fileStatus .Modified ,
401
414
Timestamp : commit .Timestamp ,
402
415
}
403
416
}
404
- return commits
417
+ return commits , nil
405
418
}
406
419
407
420
// AvatarLink tries to match user in database with e-mail
@@ -726,12 +739,16 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
726
739
}
727
740
728
741
if isHookEventPush {
742
+ commits , err := opts .Commits .ToAPIPayloadCommits (repo .RepoPath (), repo .HTMLURL ())
743
+ if err != nil {
744
+ return fmt .Errorf ("ToAPIPayloadCommits: %v" , err )
745
+ }
729
746
if err = PrepareWebhooks (repo , HookEventPush , & api.PushPayload {
730
747
Ref : opts .RefFullName ,
731
748
Before : opts .OldCommitID ,
732
749
After : opts .NewCommitID ,
733
750
CompareURL : setting .AppURL + opts .Commits .CompareURL ,
734
- Commits : opts . Commits . ToAPIPayloadCommits ( repo . HTMLURL ()) ,
751
+ Commits : commits ,
735
752
Repo : apiRepo ,
736
753
Pusher : apiPusher ,
737
754
Sender : apiPusher ,
@@ -819,7 +836,10 @@ func MirrorSyncPushAction(repo *Repository, opts MirrorSyncPushActionOptions) er
819
836
opts .Commits .Commits = opts .Commits .Commits [:setting .UI .FeedMaxCommitNum ]
820
837
}
821
838
822
- apiCommits := opts .Commits .ToAPIPayloadCommits (repo .HTMLURL ())
839
+ apiCommits , err := opts .Commits .ToAPIPayloadCommits (repo .RepoPath (), repo .HTMLURL ())
840
+ if err != nil {
841
+ return fmt .Errorf ("ToAPIPayloadCommits: %v" , err )
842
+ }
823
843
824
844
opts .Commits .CompareURL = repo .ComposeCompareURL (opts .OldCommitID , opts .NewCommitID )
825
845
apiPusher := repo .MustOwner ().APIFormat ()
0 commit comments