Skip to content

Commit

Permalink
Create commit status when event is pull_request_sync (go-gitea#23683)
Browse files Browse the repository at this point in the history
Fix: go-gitea#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)
  • Loading branch information
sillyguodong authored and GiteaBot committed Mar 24, 2023
1 parent 484cb22 commit 23a94e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion models/actions/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion services/actions/commit_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 23a94e1

Please sign in to comment.