]> source.dussan.org Git - gitea.git/commitdiff
Create commit status when event is `pull_request_sync` (#23683) (#23691)
authorGiteabot <teabot@gitea.io>
Fri, 24 Mar 2023 21:40:24 +0000 (17:40 -0400)
committerGitHub <noreply@github.com>
Fri, 24 Mar 2023 21:40:24 +0000 (17:40 -0400)
Backport #23683 by @sillyguodong

Fix: #23674
If the type of `hook_event` is `pull_request_sync`, also need to insert
a record of `commit_status` into DB.
Because `pull_request` event and `pull_request_sync` event have the same
payload, so the code is reusable.

Screenshot:

![image](https://user-images.githubusercontent.com/33891828/227465436-1b436807-d0b2-4a2b-8890-09d96c7f666d.png)

Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
models/actions/run.go
services/actions/commit_status.go

index 7d5b7a5d50b61b55ada3174304f0b872d70d0aad..5f0f1907424372f9a5e953977aeed6343bc60f74 100644 (file)
@@ -127,7 +127,7 @@ func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) {
 }
 
 func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, error) {
-       if run.Event == webhook_module.HookEventPullRequest {
+       if run.Event == webhook_module.HookEventPullRequest || run.Event == webhook_module.HookEventPullRequestSync {
                var payload api.PullRequestPayload
                if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil {
                        return nil, err
index 84de106eeca323af79f623b7d990ddd00d2b3a2b..6604a149a5c933f57f417dbe2408e4234b696b4c 100644 (file)
@@ -45,7 +45,7 @@ func CreateCommitStatus(ctx context.Context, job *actions_model.ActionRunJob) er
 
                sha = payload.HeadCommit.ID
                creatorID = payload.Pusher.ID
-       case webhook_module.HookEventPullRequest:
+       case webhook_module.HookEventPullRequest, webhook_module.HookEventPullRequestSync:
                payload, err := run.GetPullRequestEventPayload()
                if err != nil {
                        return fmt.Errorf("GetPullRequestEventPayload: %w", err)