aboutsummaryrefslogtreecommitdiff
path: root/routes/repo
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2018-09-14 20:02:49 -0400
committerUnknwon <u@gogs.io>2018-09-14 20:04:31 -0400
commit1ec365de25821ac4450996edaa2c2f7792c800b6 (patch)
tree745761b201eebaeb4e783845e48ebacc1902bf8c /routes/repo
parent99f3eabb1b70981c383b944a55697a3799292a32 (diff)
repo: trigger webhook when delete branch after merged pull request (#5331)
Diffstat (limited to 'routes/repo')
1 files changed, 14 insertions, 2 deletions
diff --git a/routes/repo/branch.go b/routes/repo/branch.go
index cd5514b6..072234ce 100644
--- a/routes/repo/branch.go
+++ b/routes/repo/branch.go
@@ -10,6 +10,7 @@ import (
log "gopkg.in/clog.v1"
"github.com/gogs/git-module"
+ api "github.com/gogs/go-gogs-client"
"github.com/gogs/gogs/models"
"github.com/gogs/gogs/pkg/context"
@@ -123,7 +124,7 @@ func DeleteBranchPost(c *context.Context) {
if len(commitID) > 0 {
branchCommitID, err := c.Repo.GitRepo.GetBranchCommitID(branchName)
if err != nil {
- log.Error(2, "GetBranchCommitID: %v", err)
+ log.Error(2, "Failed to get commit ID of branch %q: %v", err)
return
}
@@ -136,7 +137,18 @@ func DeleteBranchPost(c *context.Context) {
if err := c.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{
Force: true,
}); err != nil {
- log.Error(2, "DeleteBranch '%s': %v", branchName, err)
+ log.Error(2, "Failed to delete branch %q: %v", branchName, err)
+ return
+ }
+
+ if err := models.PrepareWebhooks(c.Repo.Repository, models.HOOK_EVENT_DELETE, &api.DeletePayload{
+ Ref: branchName,
+ RefType: "branch",
+ PusherType: api.PUSHER_TYPE_USER,
+ Repo: c.Repo.Repository.APIFormat(nil),
+ Sender: c.User.APIFormat(),
+ }); err != nil {
+ log.Error(2, "Failed to prepare webhooks for %q: %v", models.HOOK_EVENT_DELETE, err)
return
}
}