summaryrefslogtreecommitdiffstats
path: root/cmd
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 /cmd
parente0aab4a7f6c1f1b5cc7fa40e2c09623b635bc4a6 (diff)
downloadgitea-0fbb8c8826771e92e890fb1c72b356d3e62c7b01.tar.gz
gitea-0fbb8c8826771e92e890fb1c72b356d3e62c7b01.zip
New push to head repo of head branch: regenerate patch and retest apply
Diffstat (limited to 'cmd')
-rw-r--r--cmd/serve.go40
-rw-r--r--cmd/update.go8
-rw-r--r--cmd/web.go4
3 files changed, 27 insertions, 25 deletions
diff --git a/cmd/serve.go b/cmd/serve.go
index 34ebe9fbd1..5f0362744b 100644
--- a/cmd/serve.go
+++ b/cmd/serve.go
@@ -200,32 +200,34 @@ func runServ(c *cli.Context) {
}
if requestedMode == models.ACCESS_MODE_WRITE {
- tasks, err := models.GetUpdateTasksByUuid(uuid)
+ task, err := models.GetUpdateTaskByUUID(uuid)
if err != nil {
- log.GitLogger.Fatal(2, "GetUpdateTasksByUuid: %v", err)
+ log.GitLogger.Fatal(2, "GetUpdateTaskByUUID: %v", err)
}
- for _, task := range tasks {
- err = models.Update(task.RefName, task.OldCommitId, task.NewCommitId,
- user.Name, repoUserName, repoName, user.Id)
- if err != nil {
- log.GitLogger.Error(2, "Failed to update: %v", err)
- }
+ if err = models.Update(task.RefName, task.OldCommitID, task.NewCommitID,
+ user.Name, repoUserName, repoName, user.Id); err != nil {
+ log.GitLogger.Error(2, "Update: %v", err)
}
- if err = models.DelUpdateTasksByUuid(uuid); err != nil {
- log.GitLogger.Fatal(2, "DelUpdateTasksByUuid: %v", err)
+ if err = models.DeleteUpdateTaskByUUID(uuid); err != nil {
+ log.GitLogger.Fatal(2, "DeleteUpdateTaskByUUID: %v", err)
}
- }
- // Send deliver hook request.
- reqURL := setting.AppUrl + repoUserName + "/" + repoName + "/hooks/trigger"
- resp, err := httplib.Head(reqURL).Response()
- if err == nil {
- resp.Body.Close()
- log.GitLogger.Trace("Trigger hook: %s", reqURL)
- } else {
- log.GitLogger.Error(2, "Fail to trigger hook: %v", err)
+ // Ask for running deliver hook and test pull request tasks.
+ reqURL := setting.AppUrl + repoUserName + "/" + repoName + "/tasks/trigger?branch=" +
+ strings.TrimPrefix(task.RefName, "refs/heads/")
+ log.GitLogger.Trace("Trigger task: %s", reqURL)
+
+ resp, err := httplib.Head(reqURL).Response()
+ if err == nil {
+ resp.Body.Close()
+ if resp.StatusCode/100 != 2 {
+ log.GitLogger.Error(2, "Fail to trigger task: not 2xx response code")
+ }
+ } else {
+ log.GitLogger.Error(2, "Fail to trigger task: %v", err)
+ }
}
// Update user key activity.
diff --git a/cmd/update.go b/cmd/update.go
index c9eaeccf7b..64093b8177 100644
--- a/cmd/update.go
+++ b/cmd/update.go
@@ -45,13 +45,13 @@ func runUpdate(c *cli.Context) {
uuid := os.Getenv("uuid")
task := models.UpdateTask{
- Uuid: uuid,
+ UUID: uuid,
RefName: args[0],
- OldCommitId: args[1],
- NewCommitId: args[2],
+ OldCommitID: args[1],
+ NewCommitID: args[2],
}
if err := models.AddUpdateTask(&task); err != nil {
- log.GitLogger.Fatal(2, err.Error())
+ log.GitLogger.Fatal(2, "AddUpdateTask: %v", err)
}
}
diff --git a/cmd/web.go b/cmd/web.go
index 2397653534..7e18b938c2 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -545,8 +545,8 @@ func runWeb(ctx *cli.Context) {
}, ignSignIn, middleware.RepoAssignment(true, true), middleware.RepoRef())
m.Group("/:reponame", func() {
- m.Any("/*", ignSignInAndCsrf, repo.Http)
- m.Head("/hooks/trigger", repo.TriggerHook)
+ m.Any("/*", ignSignInAndCsrf, repo.HTTP)
+ m.Head("/tasks/trigger", repo.TriggerTask)
})
})
// ***** END: Repository *****