]> source.dussan.org Git - gitea.git/commitdiff
Refactor editorconfig middleware 84/head
authorAndrey Nering <andrey.nering@gmail.com>
Sat, 5 Nov 2016 15:58:53 +0000 (13:58 -0200)
committerAndrey Nering <andrey.nering@gmail.com>
Sat, 5 Nov 2016 17:44:14 +0000 (15:44 -0200)
cmd/web.go
routers/repo/commit.go
routers/repo/middlewares.go
routers/repo/pull.go
routers/repo/view.go

index a43dae38f35b49a514236a138c62724dcaf54a31..d80c2096c54406172f146f0c04f4a9a15cb39b93 100644 (file)
@@ -520,7 +520,8 @@ func runWeb(ctx *cli.Context) error {
                        ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
                })
 
-               m.Combo("/compare/*", repo.MustAllowPulls).Get(repo.CompareAndPullRequest).
+               m.Combo("/compare/*", repo.MustAllowPulls, repo.SetEditorconfigIfExists).
+                       Get(repo.CompareAndPullRequest).
                        Post(bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost)
 
                m.Group("", func() {
@@ -579,15 +580,15 @@ func runWeb(ctx *cli.Context) error {
 
                m.Group("/pulls/:index", func() {
                        m.Get("/commits", context.RepoRef(), repo.ViewPullCommits)
-                       m.Get("/files", context.RepoRef(), repo.ViewPullFiles)
+                       m.Get("/files", context.RepoRef(), repo.SetEditorconfigIfExists, repo.ViewPullFiles)
                        m.Post("/merge", reqRepoWriter, repo.MergePullRequest)
                }, repo.MustAllowPulls)
 
                m.Group("", func() {
-                       m.Get("/src/*", repo.Home)
+                       m.Get("/src/*", repo.SetEditorconfigIfExists, repo.Home)
                        m.Get("/raw/*", repo.SingleDownload)
                        m.Get("/commits/*", repo.RefCommits)
-                       m.Get("/commit/:sha([a-f0-9]{7,40})$", repo.Diff)
+                       m.Get("/commit/:sha([a-f0-9]{7,40})$", repo.SetEditorconfigIfExists, repo.Diff)
                        m.Get("/forks", repo.Forks)
                }, context.RepoRef())
                m.Get("/commit/:sha([a-f0-9]{7,40})\\.:ext(patch|diff)", repo.RawDiff)
@@ -601,8 +602,8 @@ func runWeb(ctx *cli.Context) error {
 
        m.Group("/:username", func() {
                m.Group("/:reponame", func() {
-                       m.Get("", repo.Home)
-                       m.Get("\\.git$", repo.Home)
+                       m.Get("", repo.SetEditorconfigIfExists, repo.Home)
+                       m.Get("\\.git$", repo.SetEditorconfigIfExists, repo.Home)
                }, ignSignIn, context.RepoAssignment(true), context.RepoRef())
 
                m.Group("/:reponame", func() {
index 4a4d4b12319dfdb795f8b51ca90812254315acf1..041247939c3ed1790af93df225a20353b2d2c99f 100644 (file)
@@ -179,11 +179,6 @@ func Diff(ctx *context.Context) {
                }
        }
 
-       setEditorconfigIfExists(ctx)
-       if ctx.Written() {
-               return
-       }
-
        ctx.Data["CommitID"] = commitID
        ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split"
        ctx.Data["Username"] = userName
index f025765cb91d3327e44428890d167f0cedb336de..7e1f95d4171f95d5eea44f9e139ab9c255d35df8 100644 (file)
@@ -8,7 +8,7 @@ import (
        "github.com/gogits/git-module"
 )
 
-func setEditorconfigIfExists(ctx *context.Context) {
+func SetEditorconfigIfExists(ctx *context.Context) {
        ec, err := ctx.Repo.GetEditorconfig()
 
        if err != nil && !git.IsErrNotExist(err) {
index 6dbb2b6025c9d2d16ad363fdfa6d65afdc172470..62162af67bb110ac33f3ce18ce74c53e47bc012c 100644 (file)
@@ -368,11 +368,6 @@ func ViewPullFiles(ctx *context.Context) {
                return
        }
 
-       setEditorconfigIfExists(ctx)
-       if ctx.Written() {
-               return
-       }
-
        headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name)
        ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split"
        ctx.Data["Username"] = pull.HeadUserName
@@ -625,11 +620,6 @@ func CompareAndPullRequest(ctx *context.Context) {
                }
        }
 
-       setEditorconfigIfExists(ctx)
-       if ctx.Written() {
-               return
-       }
-
        ctx.HTML(200, COMPARE_PULL)
 }
 
index ee49d4da15ab75a7df9ebdfd8558fc3fc0419200..e8b8d1e0020aa705884d7aa5f405a2c826ffb1da 100644 (file)
@@ -245,11 +245,6 @@ func Home(ctx *context.Context) {
                return
        }
 
-       setEditorconfigIfExists(ctx)
-       if ctx.Written() {
-               return
-       }
-
        var treeNames []string
        paths := make([]string, 0, 5)
        if len(ctx.Repo.TreePath) > 0 {