1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-25 18:14:28 +00:00

Fix create commit status (#30225) (#30340)

Partially backport #30223

This PR uses the service layer `CreateCommitstatus` method instead of
the git model method.
This commit is contained in:
Lunny Xiao 2024-04-09 07:30:55 +08:00 committed by GitHub
parent 65d96725bb
commit 3f6ddd9bee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,9 +12,11 @@ import (
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git" git_model "code.gitea.io/gitea/models/git"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
api "code.gitea.io/gitea/modules/structs" api "code.gitea.io/gitea/modules/structs"
webhook_module "code.gitea.io/gitea/modules/webhook" webhook_module "code.gitea.io/gitea/modules/webhook"
commitstatus_service "code.gitea.io/gitea/services/repository/commitstatus"
"github.com/nektos/act/pkg/jobparser" "github.com/nektos/act/pkg/jobparser"
) )
@ -114,18 +116,19 @@ func createCommitStatus(ctx context.Context, job *actions_model.ActionRunJob) er
} }
creator := user_model.NewActionsUser() creator := user_model.NewActionsUser()
if err := git_model.NewCommitStatus(ctx, git_model.NewCommitStatusOptions{ commitID, err := git.NewIDFromString(sha)
Repo: repo, if err != nil {
SHA: sha, return fmt.Errorf("HashTypeInterfaceFromHashString: %w", err)
Creator: creator, }
CommitStatus: &git_model.CommitStatus{ if err := commitstatus_service.CreateCommitStatus(ctx, repo, creator,
SHA: sha, commitID.String(),
&git_model.CommitStatus{
SHA: commitID.String(),
TargetURL: fmt.Sprintf("%s/jobs/%d", run.Link(), index), TargetURL: fmt.Sprintf("%s/jobs/%d", run.Link(), index),
Description: description, Description: description,
Context: ctxname, Context: ctxname,
CreatorID: creator.ID, CreatorID: creator.ID,
State: state, State: state,
},
}); err != nil { }); err != nil {
return fmt.Errorf("NewCommitStatus: %w", err) return fmt.Errorf("NewCommitStatus: %w", err)
} }