1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Replace convert.To with APIFormat calls

This commit is contained in:
Unknwon
2016-08-14 04:17:26 -07:00
parent 3f7f4852ef
commit dccb0c15b9
21 changed files with 79 additions and 225 deletions

View File

@@ -20,6 +20,8 @@ import (
"strings"
"time"
git "github.com/gogits/git-module"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/context"
@@ -206,7 +208,7 @@ func HTTP(ctx *context.Context) {
RepoName: reponame,
}); err == nil {
go models.HookQueue.Add(repo.ID)
go models.AddTestPullRequestTask(authUser, repo.ID, strings.TrimPrefix(refName, "refs/heads/"), true)
go models.AddTestPullRequestTask(authUser, repo.ID, strings.TrimPrefix(refName, git.BRANCH_PREFIX), true)
}
}

View File

@@ -347,6 +347,7 @@ func SlackHooksEditPost(ctx *context.Context, form auth.NewSlackHookForm) {
}
func TestWebhook(ctx *context.Context) {
apiUser := ctx.User.APIFormat()
p := &api.PushPayload{
Ref: git.BRANCH_PREFIX + ctx.Repo.Repository.DefaultBranch,
Before: ctx.Repo.CommitID,
@@ -356,27 +357,19 @@ func TestWebhook(ctx *context.Context) {
ID: ctx.Repo.CommitID,
Message: ctx.Repo.Commit.Message(),
URL: ctx.Repo.Repository.FullLink() + "/commit/" + ctx.Repo.CommitID,
Author: &api.PayloadAuthor{
Author: &api.PayloadUser{
Name: ctx.Repo.Commit.Author.Name,
Email: ctx.Repo.Commit.Author.Email,
},
Committer: &api.PayloadCommitter{
Committer: &api.PayloadUser{
Name: ctx.Repo.Commit.Committer.Name,
Email: ctx.Repo.Commit.Committer.Email,
},
},
},
Repo: ctx.Repo.Repository.ComposePayload(),
Pusher: &api.PayloadAuthor{
Name: ctx.User.Name,
Email: ctx.User.Email,
UserName: ctx.User.Name,
},
Sender: &api.PayloadUser{
UserName: ctx.User.Name,
ID: ctx.User.ID,
AvatarUrl: ctx.User.AvatarLink(),
},
Repo: ctx.Repo.Repository.APIFormat(nil),
Pusher: apiUser,
Sender: apiUser,
}
if err := models.PrepareWebhooks(ctx.Repo.Repository, models.HOOK_EVENT_PUSH, p); err != nil {
ctx.Flash.Error("PrepareWebhooks: " + err.Error())