diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2021-06-29 15:34:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 15:34:03 +0200 |
commit | aac663e0da0af644ae1011d268d027160265dce3 (patch) | |
tree | e2001118696d507561664349a27d7b9fca7d01ed /routers/web | |
parent | 579fcad8cdd16e88edc60685fbf9b555266bac76 (diff) | |
download | gitea-aac663e0da0af644ae1011d268d027160265dce3.tar.gz gitea-aac663e0da0af644ae1011d268d027160265dce3.zip |
Implemented head_commit for webhooks (#16282)
* Removed Len field.
* Added head_commit webhook field.
* Added comment for returns.
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/repo/webhook.go | 44 |
1 files changed, 23 insertions, 21 deletions
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()) |