diff options
author | Brad Albright <32200834+bhalbright@users.noreply.github.com> | 2019-12-24 23:59:41 -0600 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-12-25 05:59:41 +0000 |
commit | f88715e29c8cd6865b69eb8e692d051d977e93a5 (patch) | |
tree | 773a3cf4239d116fc43a4c31eebf4210fc748be3 /routers | |
parent | 8e655728e900df10a1d1eedb631dcd8fcb2729d3 (diff) | |
download | gitea-f88715e29c8cd6865b69eb8e692d051d977e93a5.tar.gz gitea-f88715e29c8cd6865b69eb8e692d051d977e93a5.zip |
Trigger webhook when deleting a branch after merging a PR (#9424)
* fixed so when deleting a branch after merging a PR, a webhook is triggered
* changed to use pr.HeadRepo instead of ctx.Repo when sending webhook for a deletion of branch after merging pr
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/pull.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go index e4b4a5ac49..932e99290b 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -22,6 +22,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification" + "code.gitea.io/gitea/modules/repofiles" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/gitdiff" @@ -928,6 +929,21 @@ func CleanUpPullRequest(ctx *context.Context) { return } + if err := repofiles.PushUpdate( + pr.HeadRepo, + pr.HeadBranch, + repofiles.PushUpdateOptions{ + RefFullName: git.BranchPrefix + pr.HeadBranch, + OldCommitID: branchCommitID, + NewCommitID: git.EmptySHA, + PusherID: ctx.User.ID, + PusherName: ctx.User.Name, + RepoUserName: pr.HeadRepo.Owner.Name, + RepoName: pr.HeadRepo.Name, + }); err != nil { + log.Error("Update: %v", err) + } + if err := models.AddDeletePRBranchComment(ctx.User, pr.BaseRepo, issue.ID, pr.HeadBranch); err != nil { // Do not fail here as branch has already been deleted log.Error("DeleteBranch: %v", err) |