diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/hook.go | 19 | ||||
-rw-r--r-- | routers/web/repo/webhook.go | 44 |
2 files changed, 33 insertions, 30 deletions
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 5a0911544a..da0a2c501c 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -140,16 +140,17 @@ func TestHook(ctx *context.APIContext) { return } + commit := convert.ToPayloadCommit(ctx.Repo.Repository, ctx.Repo.Commit) + if err := webhook.PrepareWebhook(hook, ctx.Repo.Repository, models.HookEventPush, &api.PushPayload{ - Ref: git.BranchPrefix + ctx.Repo.Repository.DefaultBranch, - Before: ctx.Repo.Commit.ID.String(), - After: ctx.Repo.Commit.ID.String(), - Commits: []*api.PayloadCommit{ - convert.ToPayloadCommit(ctx.Repo.Repository, ctx.Repo.Commit), - }, - Repo: convert.ToRepo(ctx.Repo.Repository, models.AccessModeNone), - Pusher: convert.ToUserWithAccessMode(ctx.User, models.AccessModeNone), - Sender: convert.ToUserWithAccessMode(ctx.User, models.AccessModeNone), + Ref: git.BranchPrefix + ctx.Repo.Repository.DefaultBranch, + Before: ctx.Repo.Commit.ID.String(), + After: ctx.Repo.Commit.ID.String(), + Commits: []*api.PayloadCommit{commit}, + HeadCommit: commit, + Repo: convert.ToRepo(ctx.Repo.Repository, models.AccessModeNone), + Pusher: convert.ToUserWithAccessMode(ctx.User, models.AccessModeNone), + Sender: convert.ToUserWithAccessMode(ctx.User, models.AccessModeNone), }); err != nil { ctx.Error(http.StatusInternalServerError, "PrepareWebhook: ", err) return diff --git a/routers/web/repo/webhook.go b/routers/web/repo/webhook.go index ab254dbe46..e8d86db51d 100644 --- a/routers/web/repo/webhook.go +++ b/routers/web/repo/webhook.go @@ -1085,28 +1085,30 @@ func TestWebhook(ctx *context.Context) { } apiUser := convert.ToUserWithAccessMode(ctx.User, models.AccessModeNone) - p := &api.PushPayload{ - Ref: git.BranchPrefix + ctx.Repo.Repository.DefaultBranch, - Before: commit.ID.String(), - After: commit.ID.String(), - Commits: []*api.PayloadCommit{ - { - ID: commit.ID.String(), - Message: commit.Message(), - URL: ctx.Repo.Repository.HTMLURL() + "/commit/" + commit.ID.String(), - Author: &api.PayloadUser{ - Name: commit.Author.Name, - Email: commit.Author.Email, - }, - Committer: &api.PayloadUser{ - Name: commit.Committer.Name, - Email: commit.Committer.Email, - }, - }, + + apiCommit := &api.PayloadCommit{ + ID: commit.ID.String(), + Message: commit.Message(), + URL: ctx.Repo.Repository.HTMLURL() + "/commit/" + commit.ID.String(), + Author: &api.PayloadUser{ + Name: commit.Author.Name, + Email: commit.Author.Email, + }, + Committer: &api.PayloadUser{ + Name: commit.Committer.Name, + Email: commit.Committer.Email, }, - Repo: convert.ToRepo(ctx.Repo.Repository, models.AccessModeNone), - Pusher: apiUser, - Sender: apiUser, + } + + p := &api.PushPayload{ + Ref: git.BranchPrefix + ctx.Repo.Repository.DefaultBranch, + Before: commit.ID.String(), + After: commit.ID.String(), + Commits: []*api.PayloadCommit{apiCommit}, + HeadCommit: apiCommit, + Repo: convert.ToRepo(ctx.Repo.Repository, models.AccessModeNone), + Pusher: apiUser, + Sender: apiUser, } if err := webhook.PrepareWebhook(w, ctx.Repo.Repository, models.HookEventPush, p); err != nil { ctx.Flash.Error("PrepareWebhook: " + err.Error()) |