Skip to content

Commit

Permalink
Add WithPullRequest for actionsNotifier (#25144) (#25196)
Browse files Browse the repository at this point in the history
Backport #25144 by @Zettat123

Fix #25093

If
[`WithPullRequest`](https://github.com/go-gitea/gitea/blob/679b1f7949aa40d4f962ef27f91b0b384b9c56a5/services/actions/notifier_helper.go#L90-L96)
is not called, the `Ref` in
[`notifyInput`](https://github.com/go-gitea/gitea/blob/679b1f7949aa40d4f962ef27f91b0b384b9c56a5/services/actions/notifier_helper.go#L55-L65)
will be empty, so the workflows in the head branch will not be found and
triggered.

Co-authored-by: Zettat123 <zettat123@gmail.com>
  • Loading branch information
GiteaBot and Zettat123 authored Jun 11, 2023
1 parent a903005 commit de6ac4b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions services/actions/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (n *actionsNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *use
newNotifyInputFromIssue(issue, webhook_module.HookEventPullRequest).
WithDoer(doer).
WithPayload(apiPullRequest).
WithPullRequest(issue.PullRequest).
Notify(ctx)
return
}
Expand Down Expand Up @@ -136,6 +137,7 @@ func (n *actionsNotifier) NotifyIssueChangeLabels(ctx context.Context, doer *use
Repository: convert.ToRepo(ctx, issue.Repo, perm_model.AccessModeNone),
Sender: convert.ToUser(ctx, doer, nil),
}).
WithPullRequest(issue.PullRequest).
Notify(ctx)
return
}
Expand All @@ -160,6 +162,10 @@ func (n *actionsNotifier) NotifyCreateIssueComment(ctx context.Context, doer *us
mode, _ := access_model.AccessLevel(ctx, doer, repo)

if issue.IsPull {
if err := issue.LoadPullRequest(ctx); err != nil {
log.Error("LoadPullRequest: %v", err)
return
}
newNotifyInputFromIssue(issue, webhook_module.HookEventPullRequestComment).
WithDoer(doer).
WithPayload(&api.IssueCommentPayload{
Expand All @@ -170,6 +176,7 @@ func (n *actionsNotifier) NotifyCreateIssueComment(ctx context.Context, doer *us
Sender: convert.ToUser(ctx, doer, nil),
IsPull: true,
}).
WithPullRequest(issue.PullRequest).
Notify(ctx)
return
}
Expand Down

0 comments on commit de6ac4b

Please # to comment.