aboutsummaryrefslogtreecommitdiff
path: root/routers/repo/pull.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-10-24 03:36:47 -0400
committerUnknwon <u@gogs.io>2015-10-24 03:36:47 -0400
commit0fbb8c8826771e92e890fb1c72b356d3e62c7b01 (patch)
tree2695707e4789a6611fa35393b06631848657469a /routers/repo/pull.go
parente0aab4a7f6c1f1b5cc7fa40e2c09623b635bc4a6 (diff)
New push to head repo of head branch: regenerate patch and retest apply
Diffstat (limited to 'routers/repo/pull.go')
1 files changed, 33 insertions, 0 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index c8f00cc0..eade4407 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -6,6 +6,7 @@ package repo
import (
"container/list"
+ "errors"
"path"
"strings"
@@ -148,6 +149,9 @@ func checkPullInfo(ctx *middleware.Context) *models.Issue {
if err = issue.GetPoster(); err != nil {
ctx.Handle(500, "GetPoster", err)
return nil
+ } else if issue.GetHeadRepo(); err != nil {
+ ctx.Handle(500, "GetHeadRepo", err)
+ return nil
}
if ctx.IsSigned {
@@ -166,6 +170,11 @@ func PrepareMergedViewPullInfo(ctx *middleware.Context, pull *models.Issue) {
var err error
+ if err = pull.GetMerger(); err != nil {
+ ctx.Handle(500, "GetMerger", err)
+ return
+ }
+
ctx.Data["HeadTarget"] = pull.HeadUserName + "/" + pull.HeadBranch
ctx.Data["BaseTarget"] = ctx.Repo.Owner.Name + "/" + pull.BaseBranch
@@ -191,6 +200,12 @@ func PrepareViewPullInfo(ctx *middleware.Context, pull *models.Issue) *git.PullR
headGitRepo *git.Repository
err error
)
+
+ if err = pull.GetHeadRepo(); err != nil {
+ ctx.Handle(500, "GetHeadRepo", err)
+ return nil
+ }
+
if pull.HeadRepo != nil {
headRepoPath, err := pull.HeadRepo.RepoPath()
if err != nil {
@@ -628,3 +643,21 @@ func CompareAndPullRequestPost(ctx *middleware.Context, form auth.CreateIssueFor
log.Trace("Pull request created: %d/%d", repo.ID, pull.ID)
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pull.Index))
}
+
+func TriggerTask(ctx *middleware.Context) {
+ _, repo := parseOwnerAndRepo(ctx)
+ if ctx.Written() {
+ return
+ }
+ branch := ctx.Query("branch")
+ if len(branch) == 0 {
+ ctx.Handle(422, "TriggerTask", errors.New("branch is empty"))
+ return
+ }
+
+ log.Trace("TriggerTask[%d].(new request): %s", repo.ID, branch)
+
+ go models.HookQueue.Add(repo.ID)
+ go models.AddTestPullRequestTask(repo.ID, branch)
+ ctx.Status(202)
+}