@@ -497,7 +497,7 @@ type SignCommitWithStatuses struct {
497497}
498498
499499// ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state
500- func ParseCommitsWithStatus (ctx context.Context , oldCommits []* asymkey_model.SignCommit , repo * repo_model.Repository ) []* SignCommitWithStatuses {
500+ func ParseCommitsWithStatus (ctx context.Context , oldCommits []* asymkey_model.SignCommit , repo * repo_model.Repository ) ( []* SignCommitWithStatuses , error ) {
501501 newCommits := make ([]* SignCommitWithStatuses , 0 , len (oldCommits ))
502502
503503 for _ , c := range oldCommits {
@@ -506,15 +506,14 @@ func ParseCommitsWithStatus(ctx context.Context, oldCommits []*asymkey_model.Sig
506506 }
507507 statuses , _ , err := GetLatestCommitStatus (ctx , repo .ID , commit .ID .String (), db.ListOptions {})
508508 if err != nil {
509- log .Error ("GetLatestCommitStatus: %v" , err )
510- } else {
511- commit .Statuses = statuses
512- commit .Status = CalcCommitStatus (statuses )
509+ return nil , err
513510 }
514511
512+ commit .Statuses = statuses
513+ commit .Status = CalcCommitStatus (statuses )
515514 newCommits = append (newCommits , commit )
516515 }
517- return newCommits
516+ return newCommits , nil
518517}
519518
520519// hashCommitStatusContext hash context
@@ -523,18 +522,19 @@ func hashCommitStatusContext(context string) string {
523522}
524523
525524// ConvertFromGitCommit converts git commits into SignCommitWithStatuses
526- func ConvertFromGitCommit (ctx context.Context , commits []* git.Commit , repo * repo_model.Repository ) []* SignCommitWithStatuses {
527- return ParseCommitsWithStatus (ctx ,
528- asymkey_model .ParseCommitsWithSignature (
529- ctx ,
530- user_model .ValidateCommitsWithEmails (ctx , commits ),
531- repo .GetTrustModel (),
532- func (user * user_model.User ) (bool , error ) {
533- return repo_model .IsOwnerMemberCollaborator (ctx , repo , user .ID )
534- },
535- ),
536- repo ,
525+ func ConvertFromGitCommit (ctx context.Context , commits []* git.Commit , repo * repo_model.Repository ) ([]* SignCommitWithStatuses , error ) {
526+ signedCommits , err := asymkey_model .ParseCommitsWithSignature (
527+ ctx ,
528+ user_model .ValidateCommitsWithEmails (ctx , commits ),
529+ repo .GetTrustModel (),
530+ func (user * user_model.User ) (bool , error ) {
531+ return repo_model .IsOwnerMemberCollaborator (ctx , repo , user .ID )
532+ },
537533 )
534+ if err != nil {
535+ return nil , err
536+ }
537+ return ParseCommitsWithStatus (ctx , signedCommits , repo )
538538}
539539
540540// CommitStatusesHideActionsURL hide Gitea Actions urls
0 commit comments