diff options
author | Unknwon <u@gogs.io> | 2015-11-30 20:46:19 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-30 20:46:19 -0500 |
commit | dcb391d3415a84ec893d11b788f776ea89c301c3 (patch) | |
tree | d83263075dbbe416cc79691fd87cc1255226ddf5 /cmd | |
parent | 5a14c3cf9854b2762a82ef6bdd781810380ab666 (diff) | |
parent | 830d00066785d131413d1de11ce301bf1f0b818a (diff) | |
download | gitea-dcb391d3415a84ec893d11b788f776ea89c301c3.tar.gz gitea-dcb391d3415a84ec893d11b788f776ea89c301c3.zip |
Merge branch 'feature/wiki' into develop
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/serve.go | 38 | ||||
-rw-r--r-- | cmd/web.go | 24 |
2 files changed, 42 insertions, 20 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. diff --git a/cmd/web.go b/cmd/web.go index 791183fdb4..07fceae404 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -378,6 +378,7 @@ func runWeb(ctx *cli.Context) { } reqRepoAdmin := middleware.RequireRepoAdmin() + reqRepoPusher := middleware.RequireRepoPusher() // ***** START: Organization ***** m.Group("/org", func() { @@ -470,7 +471,7 @@ func runWeb(ctx *cli.Context) { }, func(ctx *middleware.Context) { ctx.Data["PageIsSettings"] = true }) - }, reqSignIn, middleware.RepoAssignment(true), reqRepoAdmin, middleware.RepoRef()) + }, reqSignIn, middleware.RepoAssignment(), reqRepoAdmin, middleware.RepoRef()) m.Group("/:username/:reponame", func() { m.Get("/action/:action", repo.Action) @@ -516,7 +517,7 @@ func runWeb(ctx *cli.Context) { m.Combo("/compare/*").Get(repo.CompareAndPullRequest). Post(bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost) - }, reqSignIn, middleware.RepoAssignment(true)) + }, reqSignIn, middleware.RepoAssignment()) m.Group("/:username/:reponame", func() { m.Group("", func() { @@ -530,7 +531,20 @@ func runWeb(ctx *cli.Context) { }) m.Get("/^:type(issues|pulls)$/:index", repo.ViewIssue) - m.Get("/branches", repo.Branches) + // m.Get("/branches", repo.Branches) + + m.Group("/wiki", func() { + m.Get("/?:page", repo.Wiki) + m.Get("/_pages", repo.WikiPages) + + m.Group("", func() { + m.Combo("/_new").Get(repo.NewWiki). + Post(bindIgnErr(auth.NewWikiForm{}), repo.NewWikiPost) + m.Combo("/:page/_edit").Get(repo.EditWiki). + Post(bindIgnErr(auth.NewWikiForm{}), repo.EditWikiPost) + }, reqSignIn, reqRepoPusher) + }, middleware.RepoRef()) + m.Get("/archive/*", repo.Download) m.Group("/pulls/:index", func() { @@ -550,13 +564,13 @@ func runWeb(ctx *cli.Context) { }, middleware.RepoRef()) m.Get("/compare/:before([a-z0-9]{40})...:after([a-z0-9]{40})", repo.CompareDiff) - }, ignSignIn, middleware.RepoAssignment(true)) + }, ignSignIn, middleware.RepoAssignment()) m.Group("/:username", func() { m.Group("/:reponame", func() { m.Get("", repo.Home) m.Get("\\.git$", repo.Home) - }, ignSignIn, middleware.RepoAssignment(true, true), middleware.RepoRef()) + }, ignSignIn, middleware.RepoAssignment(true), middleware.RepoRef()) m.Group("/:reponame", func() { m.Any("/*", ignSignInAndCsrf, repo.HTTP) |