Skip to content

Commit 7b5b517

Browse files
ethantkoenigbkcsoft
authored andcommitted
Bug fix for edit-hook API endpoint
1 parent bab737b commit 7b5b517

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

routers/api/v1/repo/hook.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
102102
// EditHook modify a hook of a repository
103103
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook
104104
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
105-
w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
105+
hookID := ctx.ParamsInt64(":id")
106+
w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, hookID)
106107
if err != nil {
107108
if models.IsErrWebhookNotExist(err) {
108109
ctx.Status(404)
@@ -165,7 +166,12 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) {
165166
return
166167
}
167168

168-
ctx.JSON(200, convert.ToHook(ctx.Repo.RepoLink, w))
169+
updated, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, hookID)
170+
if err != nil {
171+
ctx.Error(500, "GetWebhookByRepoID", err)
172+
return
173+
}
174+
ctx.JSON(200, convert.ToHook(ctx.Repo.RepoLink, updated))
169175
}
170176

171177
// DeleteHook delete a hook of a repository

0 commit comments

Comments
 (0)