mirror of
https://github.com/gogs/gogs.git
synced 2025-12-24 01:00:00 +01:00
repo: trigger webhook when delete branch after merged pull request (#5331)
This commit is contained in:
2
gogs.go
2
gogs.go
@@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/gogs/gogs/pkg/setting"
|
"github.com/gogs/gogs/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.11.64.0913"
|
const APP_VER = "0.11.65.0914"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setting.AppVer = APP_VER
|
setting.AppVer = APP_VER
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
log "gopkg.in/clog.v1"
|
log "gopkg.in/clog.v1"
|
||||||
|
|
||||||
"github.com/gogs/git-module"
|
"github.com/gogs/git-module"
|
||||||
|
api "github.com/gogs/go-gogs-client"
|
||||||
|
|
||||||
"github.com/gogs/gogs/models"
|
"github.com/gogs/gogs/models"
|
||||||
"github.com/gogs/gogs/pkg/context"
|
"github.com/gogs/gogs/pkg/context"
|
||||||
@@ -123,7 +124,7 @@ func DeleteBranchPost(c *context.Context) {
|
|||||||
if len(commitID) > 0 {
|
if len(commitID) > 0 {
|
||||||
branchCommitID, err := c.Repo.GitRepo.GetBranchCommitID(branchName)
|
branchCommitID, err := c.Repo.GitRepo.GetBranchCommitID(branchName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(2, "GetBranchCommitID: %v", err)
|
log.Error(2, "Failed to get commit ID of branch %q: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +137,18 @@ func DeleteBranchPost(c *context.Context) {
|
|||||||
if err := c.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{
|
if err := c.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{
|
||||||
Force: true,
|
Force: true,
|
||||||
}); err != nil {
|
}); 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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0.11.64.0913
|
0.11.65.0914
|
||||||
|
|||||||
Reference in New Issue
Block a user