diff options
author | Unknwon <u@gogs.io> | 2015-11-30 20:45:55 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-30 20:45:55 -0500 |
commit | 830d00066785d131413d1de11ce301bf1f0b818a (patch) | |
tree | dd22bc4ecc89692146776d335d08c04722650f3f /cmd/serve.go | |
parent | 5d1f5f32d069ee58a9eb89072231d92dc9ec5f74 (diff) | |
download | gitea-830d00066785d131413d1de11ce301bf1f0b818a.tar.gz gitea-830d00066785d131413d1de11ce301bf1f0b818a.zip |
finish wiki
Diffstat (limited to 'cmd/serve.go')
-rw-r--r-- | cmd/serve.go | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/cmd/serve.go b/cmd/serve.go index dc952cd1d6..f319a73e58 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. |