#2246 add HTMLURL to webhook type

- Fill Milestone and Assignee field when available in webhook payload
This commit is contained in:
Unknwon 2016-08-16 10:19:09 -07:00
parent 8bf57be9ba
commit 6f9a95f830
16 changed files with 105 additions and 74 deletions

View file

@ -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()
}
}

View file

@ -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 {

View file

@ -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,