0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-14 13:08:11 +02:00

don't return if get force push commits failure

This commit is contained in:
Lunny Xiao 2026-02-19 12:06:38 -08:00
parent 6594b38c4e
commit 479370e5c9
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -12,6 +12,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/gitrepo"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
)
// getCommitIDsFromRepo get commit IDs from repo in between oldCommitID and newCommitID
@ -63,9 +64,15 @@ func CreatePushPullComment(ctx context.Context, pusher *user_model.User, pr *iss
var data issues_model.PushActionContent
data.CommitIDs, err = getCommitIDsFromRepo(ctx, pr.BaseRepo, oldCommitID, newCommitID, pr.BaseBranch)
if err != nil {
return nil, err
// For force-push events, a missing/unreachable old commit should not prevent
// deleting stale push comments or creating the force-push timeline entry.
if !isForcePush {
return nil, err
}
log.Error("getCommitIDsFromRepo: %v", err)
}
// It maybe an empty pull request. Only non-empty pull request need to create push comment
// for force push, we always need to delete the old push comment so don't return here.
if len(data.CommitIDs) == 0 && !isForcePush {
return nil, nil //nolint:nilnil // return nil because no comment needs to be created
}