aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/serve.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-11-30 20:46:19 -0500
committerUnknwon <u@gogs.io>2015-11-30 20:46:19 -0500
commitdcb391d3415a84ec893d11b788f776ea89c301c3 (patch)
treed83263075dbbe416cc79691fd87cc1255226ddf5 /cmd/serve.go
parent5a14c3cf9854b2762a82ef6bdd781810380ab666 (diff)
parent830d00066785d131413d1de11ce301bf1f0b818a (diff)
downloadgitea-dcb391d3415a84ec893d11b788f776ea89c301c3.tar.gz
gitea-dcb391d3415a84ec893d11b788f776ea89c301c3.zip
Merge branch 'feature/wiki' into develop
Diffstat (limited to 'cmd/serve.go')
-rw-r--r--cmd/serve.go38
1 files changed, 23 insertions, 15 deletions
diff --git a/cmd/serve.go b/cmd/serve.go
index cd2f318516..2aebbd4a87 100644
--- a/cmd/serve.go
+++ b/cmd/serve.go
@@ -87,7 +87,7 @@ func fail(userMessage, logMessage string, args ...interface{}) {
os.Exit(1)
}
-func handleUpdateTask(uuid string, user *models.User, repoUserName, repoName string) {
+func handleUpdateTask(uuid string, user *models.User, username, reponame string, isWiki bool) {
task, err := models.GetUpdateTaskByUUID(uuid)
if err != nil {
if models.IsErrUpdateTaskNotExist(err) {
@@ -95,19 +95,21 @@ func handleUpdateTask(uuid string, user *models.User, repoUserName, repoName str
return
}
log.GitLogger.Fatal(2, "GetUpdateTaskByUUID: %v", err)
+ } else if err = models.DeleteUpdateTaskByUUID(uuid); err != nil {
+ log.GitLogger.Fatal(2, "DeleteUpdateTaskByUUID: %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 isWiki {
+ return
}
- if err = models.DeleteUpdateTaskByUUID(uuid); err != nil {
- log.GitLogger.Fatal(2, "DeleteUpdateTaskByUUID: %v", err)
+ if err = models.Update(task.RefName, task.OldCommitID, task.NewCommitID,
+ user.Name, username, reponame, user.Id); err != nil {
+ log.GitLogger.Error(2, "Update: %v", err)
}
// Ask for running deliver hook and test pull request tasks.
- reqURL := setting.AppUrl + repoUserName + "/" + repoName + "/tasks/trigger?branch=" +
+ reqURL := setting.AppUrl + username + "/" + reponame + "/tasks/trigger?branch=" +
strings.TrimPrefix(task.RefName, "refs/heads/")
log.GitLogger.Trace("Trigger task: %s", reqURL)
@@ -147,21 +149,27 @@ func runServ(c *cli.Context) {
if len(rr) != 2 {
fail("Invalid repository path", "Invalid repository path: %v", args)
}
- repoUserName := strings.ToLower(rr[0])
- repoName := strings.ToLower(strings.TrimSuffix(rr[1], ".git"))
+ username := strings.ToLower(rr[0])
+ reponame := strings.ToLower(strings.TrimSuffix(rr[1], ".git"))
+
+ isWiki := false
+ if strings.HasSuffix(reponame, ".wiki") {
+ isWiki = true
+ reponame = reponame[:len(reponame)-5]
+ }
- repoUser, err := models.GetUserByName(repoUserName)
+ repoUser, err := models.GetUserByName(username)
if err != nil {
if models.IsErrUserNotExist(err) {
- fail("Repository owner does not exist", "Unregistered owner: %s", repoUserName)
+ fail("Repository owner does not exist", "Unregistered owner: %s", username)
}
- fail("Internal error", "Failed to get repository owner(%s): %v", repoUserName, err)
+ fail("Internal error", "Failed to get repository owner(%s): %v", username, err)
}
- repo, err := models.GetRepositoryByName(repoUser.Id, repoName)
+ repo, err := models.GetRepositoryByName(repoUser.Id, reponame)
if err != nil {
if models.IsErrRepoNotExist(err) {
- fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", repoUser.Name, repoName)
+ fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", repoUser.Name, reponame)
}
fail("Internal error", "Failed to get repository: %v", err)
}
@@ -258,7 +266,7 @@ func runServ(c *cli.Context) {
}
if requestedMode == models.ACCESS_MODE_WRITE {
- handleUpdateTask(uuid, user, repoUserName, repoName)
+ handleUpdateTask(uuid, user, username, reponame, isWiki)
}
// Update user key activity.