diff options
author | Unknwon <u@gogs.io> | 2016-08-16 10:19:09 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-16 10:19:09 -0700 |
commit | 6f9a95f83020e215ebe3942bd541da34791dd043 (patch) | |
tree | 9d95bc94e2346c808863377f79708d32decb8908 /routers | |
parent | 8bf57be9ba82d7b5289c894c902b5ecaaa1142bf (diff) | |
download | gitea-6f9a95f83020e215ebe3942bd541da34791dd043.tar.gz gitea-6f9a95f83020e215ebe3942bd541da34791dd043.zip |
#2246 add HTMLURL to webhook type
- Fill Milestone and Assignee field when available in webhook payload
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/issue.go | 10 | ||||
-rw-r--r-- | routers/repo/pull.go | 24 | ||||
-rw-r--r-- | routers/repo/webhook.go | 2 |
3 files changed, 20 insertions, 16 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 3b36556c00..37731e5ee6 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -538,8 +538,8 @@ func ViewIssue(ctx *context.Context) { // Get more information if it's a pull request. if issue.IsPull { - if issue.HasMerged { - ctx.Data["DisableStatusChange"] = issue.HasMerged + if issue.PullRequest.HasMerged { + ctx.Data["DisableStatusChange"] = issue.PullRequest.HasMerged PrepareMergedViewPullInfo(ctx, issue) } else { PrepareViewPullInfo(ctx, issue) @@ -822,7 +822,7 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { // Check if issue admin/poster changes the status of issue. if (ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))) && (form.Status == "reopen" || form.Status == "close") && - !(issue.IsPull && issue.HasMerged) { + !(issue.IsPull && issue.PullRequest.HasMerged) { // Duplication and conflict check should apply to reopen pull request. var pr *models.PullRequest @@ -839,12 +839,12 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { // Regenerate patch and test conflict. if pr == nil { - if err = issue.UpdatePatch(); err != nil { + if err = issue.PullRequest.UpdatePatch(); err != nil { ctx.Handle(500, "UpdatePatch", err) return } - issue.AddToTaskQueue() + issue.PullRequest.AddToTaskQueue() } } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 87bc7bc217..d5d9bc9b07 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -156,7 +156,7 @@ func checkPullInfo(ctx *context.Context) *models.Issue { return nil } - if err = issue.GetHeadRepo(); err != nil { + if err = issue.PullRequest.GetHeadRepo(); err != nil { ctx.Handle(500, "GetHeadRepo", err) return nil } @@ -172,9 +172,10 @@ func checkPullInfo(ctx *context.Context) *models.Issue { return issue } -func PrepareMergedViewPullInfo(ctx *context.Context, pull *models.Issue) { +func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) { + pull := issue.PullRequest ctx.Data["HasMerged"] = true - ctx.Data["HeadTarget"] = pull.HeadUserName + "/" + pull.HeadBranch + ctx.Data["HeadTarget"] = issue.PullRequest.HeadUserName + "/" + pull.HeadBranch ctx.Data["BaseTarget"] = ctx.Repo.Owner.Name + "/" + pull.BaseBranch var err error @@ -190,8 +191,9 @@ func PrepareMergedViewPullInfo(ctx *context.Context, pull *models.Issue) { } } -func PrepareViewPullInfo(ctx *context.Context, pull *models.Issue) *git.PullRequestInfo { +func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.PullRequestInfo { repo := ctx.Repo.Repository + pull := issue.PullRequest ctx.Data["HeadTarget"] = pull.HeadUserName + "/" + pull.HeadBranch ctx.Data["BaseTarget"] = ctx.Repo.Owner.Name + "/" + pull.BaseBranch @@ -245,16 +247,17 @@ func ViewPullCommits(ctx *context.Context) { ctx.Data["PageIsPullList"] = true ctx.Data["PageIsPullCommits"] = true - pull := checkPullInfo(ctx) + issue := checkPullInfo(ctx) if ctx.Written() { return } + pull := issue.PullRequest ctx.Data["Username"] = pull.HeadUserName ctx.Data["Reponame"] = pull.HeadRepo.Name var commits *list.List if pull.HasMerged { - PrepareMergedViewPullInfo(ctx, pull) + PrepareMergedViewPullInfo(ctx, issue) if ctx.Written() { return } @@ -275,7 +278,7 @@ func ViewPullCommits(ctx *context.Context) { } } else { - prInfo := PrepareViewPullInfo(ctx, pull) + prInfo := PrepareViewPullInfo(ctx, issue) if ctx.Written() { return } else if prInfo == nil { @@ -296,10 +299,11 @@ func ViewPullFiles(ctx *context.Context) { ctx.Data["PageIsPullList"] = true ctx.Data["PageIsPullFiles"] = true - pull := checkPullInfo(ctx) + issue := checkPullInfo(ctx) if ctx.Written() { return } + pull := issue.PullRequest var ( diffRepoPath string @@ -309,7 +313,7 @@ func ViewPullFiles(ctx *context.Context) { ) if pull.HasMerged { - PrepareMergedViewPullInfo(ctx, pull) + PrepareMergedViewPullInfo(ctx, issue) if ctx.Written() { return } @@ -319,7 +323,7 @@ func ViewPullFiles(ctx *context.Context) { endCommitID = pull.MergedCommitID gitRepo = ctx.Repo.GitRepo } else { - prInfo := PrepareViewPullInfo(ctx, pull) + prInfo := PrepareViewPullInfo(ctx, issue) if ctx.Written() { return } else if prInfo == nil { diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 85878e7d1e..d3605b2a42 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -368,7 +368,7 @@ func TestWebhook(ctx *context.Context) { { ID: commit.ID.String(), Message: commit.Message(), - URL: ctx.Repo.Repository.FullLink() + "/commit/" + commit.ID.String(), + URL: ctx.Repo.Repository.HTMLURL() + "/commit/" + commit.ID.String(), Author: &api.PayloadUser{ Name: commit.Author.Name, Email: commit.Author.Email, |