Browse Source

Merge branch 'master' into feature/goimports

Sandro Santilli 3 years ago
parent
commit
f36544f98d
5 changed files with 8 additions and 27 deletions
  1. 7 6
      cmd/web.go
  2. 0 5
      routers/repo/commit.go
  3. 1 1
      routers/repo/middlewares.go
  4. 0 10
      routers/repo/pull.go
  5. 0 5
      routers/repo/view.go

+ 7 - 6
cmd/web.go

@@ -518,7 +518,8 @@ func runWeb(ctx *cli.Context) error {
518 518
 			ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
519 519
 		})
520 520
 
521
-		m.Combo("/compare/*", repo.MustAllowPulls).Get(repo.CompareAndPullRequest).
521
+		m.Combo("/compare/*", repo.MustAllowPulls, repo.SetEditorconfigIfExists).
522
+			Get(repo.CompareAndPullRequest).
522 523
 			Post(bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost)
523 524
 
524 525
 		m.Group("", func() {
@@ -577,15 +578,15 @@ func runWeb(ctx *cli.Context) error {
577 578
 
578 579
 		m.Group("/pulls/:index", func() {
579 580
 			m.Get("/commits", context.RepoRef(), repo.ViewPullCommits)
580
-			m.Get("/files", context.RepoRef(), repo.ViewPullFiles)
581
+			m.Get("/files", context.RepoRef(), repo.SetEditorconfigIfExists, repo.ViewPullFiles)
581 582
 			m.Post("/merge", reqRepoWriter, repo.MergePullRequest)
582 583
 		}, repo.MustAllowPulls)
583 584
 
584 585
 		m.Group("", func() {
585
-			m.Get("/src/*", repo.Home)
586
+			m.Get("/src/*", repo.SetEditorconfigIfExists, repo.Home)
586 587
 			m.Get("/raw/*", repo.SingleDownload)
587 588
 			m.Get("/commits/*", repo.RefCommits)
588
-			m.Get("/commit/:sha([a-f0-9]{7,40})$", repo.Diff)
589
+			m.Get("/commit/:sha([a-f0-9]{7,40})$", repo.SetEditorconfigIfExists, repo.Diff)
589 590
 			m.Get("/forks", repo.Forks)
590 591
 		}, context.RepoRef())
591 592
 		m.Get("/commit/:sha([a-f0-9]{7,40})\\.:ext(patch|diff)", repo.RawDiff)
@@ -599,8 +600,8 @@ func runWeb(ctx *cli.Context) error {
599 600
 
600 601
 	m.Group("/:username", func() {
601 602
 		m.Group("/:reponame", func() {
602
-			m.Get("", repo.Home)
603
-			m.Get("\\.git$", repo.Home)
603
+			m.Get("", repo.SetEditorconfigIfExists, repo.Home)
604
+			m.Get("\\.git$", repo.SetEditorconfigIfExists, repo.Home)
604 605
 		}, ignSignIn, context.RepoAssignment(true), context.RepoRef())
605 606
 
606 607
 		m.Group("/:reponame", func() {

+ 0 - 5
routers/repo/commit.go

@@ -177,11 +177,6 @@ func Diff(ctx *context.Context) {
177 177
 		}
178 178
 	}
179 179
 
180
-	setEditorconfigIfExists(ctx)
181
-	if ctx.Written() {
182
-		return
183
-	}
184
-
185 180
 	ctx.Data["CommitID"] = commitID
186 181
 	ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split"
187 182
 	ctx.Data["Username"] = userName

+ 1 - 1
routers/repo/middlewares.go

@@ -8,7 +8,7 @@ import (
8 8
 	git "github.com/gogits/git-module"
9 9
 )
10 10
 
11
-func setEditorconfigIfExists(ctx *context.Context) {
11
+func SetEditorconfigIfExists(ctx *context.Context) {
12 12
 	ec, err := ctx.Repo.GetEditorconfig()
13 13
 
14 14
 	if err != nil && !git.IsErrNotExist(err) {

+ 0 - 10
routers/repo/pull.go

@@ -366,11 +366,6 @@ func ViewPullFiles(ctx *context.Context) {
366 366
 		return
367 367
 	}
368 368
 
369
-	setEditorconfigIfExists(ctx)
370
-	if ctx.Written() {
371
-		return
372
-	}
373
-
374 369
 	headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name)
375 370
 	ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split"
376 371
 	ctx.Data["Username"] = pull.HeadUserName
@@ -623,11 +618,6 @@ func CompareAndPullRequest(ctx *context.Context) {
623 618
 		}
624 619
 	}
625 620
 
626
-	setEditorconfigIfExists(ctx)
627
-	if ctx.Written() {
628
-		return
629
-	}
630
-
631 621
 	ctx.HTML(200, COMPARE_PULL)
632 622
 }
633 623
 

+ 0 - 5
routers/repo/view.go

@@ -243,11 +243,6 @@ func Home(ctx *context.Context) {
243 243
 		return
244 244
 	}
245 245
 
246
-	setEditorconfigIfExists(ctx)
247
-	if ctx.Written() {
248
-		return
249
-	}
250
-
251 246
 	var treeNames []string
252 247
 	paths := make([]string, 0, 5)
253 248
 	if len(ctx.Repo.TreePath) > 0 {