Browse Source

Fix golangci-lint warnings (#17598 et al) (#17668)

Backport #17598 
Backport #17606 
Backport #17608 
Backport #17609

- Since https://gitea.com/gitea/test-env/pulls/10 the golangci-lint has been upgraded and is erroring about new warnings in the code, this PR fixes those warnings.
tags/v1.15.7
Gusted 4 years ago committed by GitHub
parent
commit
ea0fe83888
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .golangci.yml
  2. 3
      build.go
  3. 1
      build/generate-bindata.go
  4. 1
      build/generate-emoji.go
  5. 1
      build/generate-gitignores.go
  6. 1
      build/generate-licenses.go
  7. 1
      build/gocovmerge.go
  8. 6
      cmd/docs.go
  9. 1
      cmd/embedded.go
  10. 1
      cmd/embedded_stub.go
  11. 9
      models/migrations/migrations.go
  12. 1
      modules/auth/pam/pam.go
  13. 5
      modules/auth/pam/pam_stub.go
  14. 1
      modules/auth/pam/pam_test.go
  15. 1
      modules/git/blob_gogit.go
  16. 1
      modules/git/blob_nogogit.go
  17. 1
      modules/git/command_test.go
  18. 1
      modules/git/commit_convert_gogit.go
  19. 1
      modules/git/commit_info_gogit.go
  20. 1
      modules/git/commit_info_nogogit.go
  21. 1
      modules/git/last_commit_cache_gogit.go
  22. 1
      modules/git/last_commit_cache_nogogit.go
  23. 1
      modules/git/notes_gogit.go
  24. 1
      modules/git/notes_nogogit.go
  25. 1
      modules/git/parse_gogit.go
  26. 1
      modules/git/parse_gogit_test.go
  27. 1
      modules/git/parse_nogogit.go
  28. 1
      modules/git/parse_nogogit_test.go
  29. 1
      modules/git/pipeline/lfs.go
  30. 1
      modules/git/pipeline/lfs_nogogit.go
  31. 1
      modules/git/repo_base_gogit.go
  32. 1
      modules/git/repo_base_nogogit.go
  33. 1
      modules/git/repo_blob_gogit.go
  34. 1
      modules/git/repo_blob_nogogit.go
  35. 1
      modules/git/repo_branch_gogit.go
  36. 1
      modules/git/repo_branch_nogogit.go
  37. 1
      modules/git/repo_commit_gogit.go
  38. 1
      modules/git/repo_commit_nogogit.go
  39. 1
      modules/git/repo_commitgraph_gogit.go
  40. 1
      modules/git/repo_language_stats_gogit.go
  41. 1
      modules/git/repo_language_stats_nogogit.go
  42. 1
      modules/git/repo_ref_gogit.go
  43. 1
      modules/git/repo_ref_nogogit.go
  44. 1
      modules/git/repo_tag_gogit.go
  45. 1
      modules/git/repo_tag_nogogit.go
  46. 1
      modules/git/repo_tree_gogit.go
  47. 1
      modules/git/repo_tree_nogogit.go
  48. 1
      modules/git/sha1_gogit.go
  49. 1
      modules/git/sha1_nogogit.go
  50. 1
      modules/git/signature_gogit.go
  51. 1
      modules/git/signature_nogogit.go
  52. 4
      modules/git/submodule.go
  53. 1
      modules/git/tree_blob_gogit.go
  54. 1
      modules/git/tree_blob_nogogit.go
  55. 1
      modules/git/tree_entry_gogit.go
  56. 1
      modules/git/tree_entry_nogogit.go
  57. 1
      modules/git/tree_entry_test.go
  58. 1
      modules/git/tree_gogit.go
  59. 1
      modules/git/tree_nogogit.go
  60. 8
      modules/gitgraph/graph_models.go
  61. 5
      modules/graceful/manager_unix.go
  62. 5
      modules/graceful/manager_windows.go
  63. 5
      modules/graceful/net_unix.go
  64. 5
      modules/graceful/net_windows.go
  65. 5
      modules/graceful/restart_unix.go
  66. 4
      modules/indexer/code/bleve.go
  67. 5
      modules/indexer/code/elastic_search.go
  68. 6
      modules/indexer/code/indexer.go
  69. 2
      modules/indexer/stats/queue.go
  70. 4
      modules/lfs/endpoint.go
  71. 1
      modules/lfs/pointer_scanner_gogit.go
  72. 1
      modules/lfs/pointer_scanner_nogogit.go
  73. 2
      modules/markup/common/footnote.go
  74. 5
      modules/options/dynamic.go
  75. 3
      modules/options/options_bindata.go
  76. 1
      modules/options/static.go
  77. 5
      modules/public/dynamic.go
  78. 3
      modules/public/public_bindata.go
  79. 1
      modules/public/static.go
  80. 2
      modules/repository/adopt.go
  81. 1
      modules/setting/database_sqlite.go
  82. 1
      modules/svg/discover_bindata.go
  83. 1
      modules/svg/discover_nobindata.go
  84. 5
      modules/templates/dynamic.go
  85. 1
      modules/templates/static.go
  86. 3
      modules/templates/templates_bindata.go
  87. 5
      routers/private/manager_unix.go
  88. 5
      routers/private/manager_windows.go
  89. 8
      routers/web/base.go
  90. 2
      routers/web/user/setting/adopt.go
  91. 2
      routers/web/user/setting/profile.go
  92. 1
      services/auth/placeholder.go
  93. 2
      services/pull/check.go
  94. 4
      services/pull/merge.go
  95. 2
      services/repository/push.go
  96. 1
      tools/fuzz.go

1
.golangci.yml

@ -9,7 +9,6 @@ linters:
- unused - unused
- structcheck - structcheck
- varcheck - varcheck
- golint
- dupl - dupl
#- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time. #- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
- gofmt - gofmt

3
build.go

@ -2,7 +2,8 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//+build vendor //go:build vendor
// +build vendor
package main package main

1
build/generate-bindata.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ignore
// +build ignore // +build ignore
package main package main

1
build/generate-emoji.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ignore
// +build ignore // +build ignore
package main package main

1
build/generate-gitignores.go

@ -1,3 +1,4 @@
//go:build ignore
// +build ignore // +build ignore
package main package main

1
build/generate-licenses.go

@ -1,3 +1,4 @@
//go:build ignore
// +build ignore // +build ignore
package main package main

1
build/gocovmerge.go

@ -6,6 +6,7 @@
// gocovmerge takes the results from multiple `go test -coverprofile` runs and // gocovmerge takes the results from multiple `go test -coverprofile` runs and
// merges them into one profile // merges them into one profile
//go:build ignore
// +build ignore // +build ignore
package main package main

6
cmd/docs.go

@ -43,7 +43,11 @@ func runDocs(ctx *cli.Context) error {
// Clean up markdown. The following bug was fixed in v2, but is present in v1. // Clean up markdown. The following bug was fixed in v2, but is present in v1.
// It affects markdown output (even though the issue is referring to man pages) // It affects markdown output (even though the issue is referring to man pages)
// https://github.com/urfave/cli/issues/1040 // https://github.com/urfave/cli/issues/1040
docs = docs[strings.Index(docs, "#"):] firstHashtagIndex := strings.Index(docs, "#")
if firstHashtagIndex > 0 {
docs = docs[firstHashtagIndex:]
}
} }
out := os.Stdout out := os.Stdout

1
cmd/embedded.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build bindata
// +build bindata // +build bindata
package cmd package cmd

1
cmd/embedded_stub.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !bindata
// +build !bindata // +build !bindata
package cmd package cmd

9
models/migrations/migrations.go

@ -7,6 +7,7 @@ package migrations
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"os" "os"
"reflect" "reflect"
@ -762,8 +763,14 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
} }
tableSQL := string(res[0]["sql"]) tableSQL := string(res[0]["sql"])
// Get the string offset for column definitions: `CREATE TABLE ( column-definitions... )`
columnDefinitionsIndex := strings.Index(tableSQL, "(")
if columnDefinitionsIndex < 0 {
return errors.New("couldn't find column definitions")
}
// Separate out the column definitions // Separate out the column definitions
tableSQL = tableSQL[strings.Index(tableSQL, "("):] tableSQL = tableSQL[columnDefinitionsIndex:]
// Remove the required columnNames // Remove the required columnNames
for _, name := range columnNames { for _, name := range columnNames {

1
modules/auth/pam/pam.go

@ -1,3 +1,4 @@
//go:build pam
// +build pam // +build pam
// Copyright 2014 The Gogs Authors. All rights reserved. // Copyright 2014 The Gogs Authors. All rights reserved.

5
modules/auth/pam/pam_stub.go

@ -1,9 +1,10 @@
// +build !pam
// Copyright 2014 The Gogs Authors. All rights reserved. // Copyright 2014 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !pam
// +build !pam
package pam package pam
import ( import (

1
modules/auth/pam/pam_test.go

@ -1,3 +1,4 @@
//go:build pam
// +build pam // +build pam
// Copyright 2021 The Gitea Authors. All rights reserved. // Copyright 2021 The Gitea Authors. All rights reserved.

1
modules/git/blob_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/blob_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/command_test.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build race
// +build race // +build race
package git package git

1
modules/git/commit_convert_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/commit_info_gogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/commit_info_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/last_commit_cache_gogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/last_commit_cache_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/notes_gogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/notes_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/parse_gogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/parse_gogit_test.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/parse_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/parse_nogogit_test.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/pipeline/lfs.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package pipeline package pipeline

1
modules/git/pipeline/lfs_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package pipeline package pipeline

1
modules/git/repo_base_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/repo_base_nogogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/repo_blob_gogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/repo_blob_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/repo_branch_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/repo_branch_nogogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/repo_commit_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/repo_commit_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/repo_commitgraph_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/repo_language_stats_gogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/repo_language_stats_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/repo_ref_gogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/repo_ref_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/repo_tag_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/repo_tag_nogogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/repo_tree_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/repo_tree_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/sha1_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/sha1_nogogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/signature_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/signature_nogogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

4
modules/git/submodule.go

@ -52,9 +52,7 @@ func getRefURL(refURL, urlPrefix, repoFullName, sshDomain string) string {
urlPrefixHostname = prefixURL.Host urlPrefixHostname = prefixURL.Host
} }
if strings.HasSuffix(urlPrefix, "/") { urlPrefix = strings.TrimSuffix(urlPrefix, "/")
urlPrefix = urlPrefix[:len(urlPrefix)-1]
}
// FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules // FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules
// Relative url prefix check (according to git submodule documentation) // Relative url prefix check (according to git submodule documentation)

1
modules/git/tree_blob_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/tree_blob_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/tree_entry_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/tree_entry_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

1
modules/git/tree_entry_test.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/tree_gogit.go

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

1
modules/git/tree_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

8
modules/gitgraph/graph_models.go

@ -217,11 +217,9 @@ func newRefsFromRefNames(refNames []byte) []git.Reference {
continue continue
} }
refName := string(refNameBytes) refName := string(refNameBytes)
if strings.HasPrefix(refName, "tag: ") { refName = strings.TrimPrefix(refName, "tag: ")
refName = strings.TrimPrefix(refName, "tag: ") refName = strings.TrimPrefix(refName, "HEAD -> ")
} else if strings.HasPrefix(refName, "HEAD -> ") {
refName = strings.TrimPrefix(refName, "HEAD -> ")
}
refs = append(refs, git.Reference{ refs = append(refs, git.Reference{
Name: refName, Name: refName,
}) })

5
modules/graceful/manager_unix.go

@ -1,9 +1,10 @@
// +build !windows
// Copyright 2019 The Gitea Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !windows
// +build !windows
package graceful package graceful
import ( import (

5
modules/graceful/manager_windows.go

@ -1,10 +1,11 @@
// +build windows
// Copyright 2019 The Gitea Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// This code is heavily inspired by the archived gofacebook/gracenet/net.go handler // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler
//go:build windows
// +build windows
package graceful package graceful
import ( import (

5
modules/graceful/net_unix.go

@ -1,10 +1,11 @@
// +build !windows
// Copyright 2019 The Gitea Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// This code is heavily inspired by the archived gofacebook/gracenet/net.go handler // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler
//go:build !windows
// +build !windows
package graceful package graceful
import ( import (

5
modules/graceful/net_windows.go

@ -1,10 +1,11 @@
// +build windows
// Copyright 2019 The Gitea Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// This code is heavily inspired by the archived gofacebook/gracenet/net.go handler // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler
//go:build windows
// +build windows
package graceful package graceful
import "net" import "net"

5
modules/graceful/restart_unix.go

@ -1,10 +1,11 @@
// +build !windows
// Copyright 2019 The Gitea Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// This code is heavily inspired by the archived gofacebook/gracenet/net.go handler // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler
//go:build !windows
// +build !windows
package graceful package graceful
import ( import (

4
modules/indexer/code/bleve.go

@ -174,6 +174,10 @@ func NewBleveIndexer(indexDir string) (*BleveIndexer, bool, error) {
indexDir: indexDir, indexDir: indexDir,
} }
created, err := indexer.init() created, err := indexer.init()
if err != nil {
indexer.Close()
return nil, false, err
}
return indexer, created, err return indexer, created, err
} }

5
modules/indexer/code/elastic_search.go

@ -83,7 +83,10 @@ func NewElasticSearchIndexer(url, indexerName string) (*ElasticSearchIndexer, bo
indexerAliasName: indexerName, indexerAliasName: indexerName,
} }
exists, err := indexer.init() exists, err := indexer.init()
if err != nil {
indexer.Close()
return nil, false, err
}
return indexer, !exists, err return indexer, !exists, err
} }

6
modules/indexer/code/indexer.go

@ -188,9 +188,6 @@ func Init() {
rIndexer, populate, err = NewBleveIndexer(setting.Indexer.RepoPath) rIndexer, populate, err = NewBleveIndexer(setting.Indexer.RepoPath)
if err != nil { if err != nil {
if rIndexer != nil {
rIndexer.Close()
}
cancel() cancel()
indexer.Close() indexer.Close()
close(waitChannel) close(waitChannel)
@ -208,9 +205,6 @@ func Init() {
rIndexer, populate, err = NewElasticSearchIndexer(setting.Indexer.RepoConnStr, setting.Indexer.RepoIndexerName) rIndexer, populate, err = NewElasticSearchIndexer(setting.Indexer.RepoConnStr, setting.Indexer.RepoIndexerName)
if err != nil { if err != nil {
if rIndexer != nil {
rIndexer.Close()
}
cancel() cancel()
indexer.Close() indexer.Close()
close(waitChannel) close(waitChannel)

2
modules/indexer/stats/queue.go

@ -27,7 +27,7 @@ func handle(data ...queue.Data) {
} }
func initStatsQueue() error { func initStatsQueue() error {
statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0)).(queue.UniqueQueue) statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0))
if statsQueue == nil { if statsQueue == nil {
return fmt.Errorf("Unable to create repo_stats_update Queue") return fmt.Errorf("Unable to create repo_stats_update Queue")
} }

4
modules/lfs/endpoint.go

@ -29,9 +29,7 @@ func endpointFromCloneURL(rawurl string) *url.URL {
return ep return ep
} }
if strings.HasSuffix(ep.Path, "/") { ep.Path = strings.TrimSuffix(ep.Path, "/")
ep.Path = ep.Path[:len(ep.Path)-1]
}
if ep.Scheme == "file" { if ep.Scheme == "file" {
return ep return ep

1
modules/lfs/pointer_scanner_gogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package lfs package lfs

1
modules/lfs/pointer_scanner_nogogit.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package lfs package lfs

2
modules/markup/common/footnote.go

@ -126,7 +126,7 @@ type Footnote struct {
func (n *Footnote) Dump(source []byte, level int) { func (n *Footnote) Dump(source []byte, level int) {
m := map[string]string{} m := map[string]string{}
m["Index"] = fmt.Sprintf("%v", n.Index) m["Index"] = fmt.Sprintf("%v", n.Index)
m["Ref"] = fmt.Sprintf("%s", n.Ref) m["Ref"] = string(n.Ref)
m["Name"] = fmt.Sprintf("%v", n.Name) m["Name"] = fmt.Sprintf("%v", n.Name)
ast.DumpHelper(n, source, level, m, nil) ast.DumpHelper(n, source, level, m, nil)
} }

5
modules/options/dynamic.go

@ -1,9 +1,10 @@
// +build !bindata
// Copyright 2016 The Gitea Authors. All rights reserved. // Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !bindata
// +build !bindata
package options package options
import ( import (

3
modules/options/options_bindata.go

@ -2,7 +2,8 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//+build bindata //go:build bindata
// +build bindata
package options package options

1
modules/options/static.go

@ -1,3 +1,4 @@
//go:build bindata
// +build bindata // +build bindata
// Copyright 2016 The Gitea Authors. All rights reserved. // Copyright 2016 The Gitea Authors. All rights reserved.

5
modules/public/dynamic.go

@ -1,9 +1,10 @@
// +build !bindata
// Copyright 2016 The Gitea Authors. All rights reserved. // Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !bindata
// +build !bindata
package public package public
import ( import (

3
modules/public/public_bindata.go

@ -2,7 +2,8 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//+build bindata //go:build bindata
// +build bindata
package public package public

1
modules/public/static.go

@ -1,3 +1,4 @@
//go:build bindata
// +build bindata // +build bindata
// Copyright 2016 The Gitea Authors. All rights reserved. // Copyright 2016 The Gitea Authors. All rights reserved.

2
modules/repository/adopt.go

@ -152,7 +152,7 @@ func ListUnadoptedRepositories(query string, opts *models.ListOptions) ([]string
count := 0 count := 0
// We're going to iterate by pagesize. // We're going to iterate by pagesize.
root := filepath.Join(setting.RepoRootPath) root := filepath.Clean(setting.RepoRootPath)
if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil { if err != nil {
return err return err

1
modules/setting/database_sqlite.go

@ -1,3 +1,4 @@
//go:build sqlite
// +build sqlite // +build sqlite
// Copyright 2014 The Gogs Authors. All rights reserved. // Copyright 2014 The Gogs Authors. All rights reserved.

1
modules/svg/discover_bindata.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build bindata
// +build bindata // +build bindata
package svg package svg

1
modules/svg/discover_nobindata.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !bindata
// +build !bindata // +build !bindata
package svg package svg

5
modules/templates/dynamic.go

@ -1,9 +1,10 @@
// +build !bindata
// Copyright 2016 The Gitea Authors. All rights reserved. // Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !bindata
// +build !bindata
package templates package templates
import ( import (

1
modules/templates/static.go

@ -1,3 +1,4 @@
//go:build bindata
// +build bindata // +build bindata
// Copyright 2016 The Gitea Authors. All rights reserved. // Copyright 2016 The Gitea Authors. All rights reserved.

3
modules/templates/templates_bindata.go

@ -2,7 +2,8 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//+build bindata //go:build bindata
// +build bindata
package templates package templates

5
routers/private/manager_unix.go

@ -1,9 +1,10 @@
// +build !windows
// Copyright 2020 The Gitea Authors. All rights reserved. // Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !windows
// +build !windows
package private package private
import ( import (

5
routers/private/manager_windows.go

@ -1,9 +1,10 @@
// +build windows
// Copyright 2020 The Gitea Authors. All rights reserved. // Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build windows
// +build windows
package private package private
import ( import (

8
routers/web/base.go

@ -130,14 +130,6 @@ func Recovery() func(next http.Handler) http.Handler {
log.Error("%v", combinedErr) log.Error("%v", combinedErr)
sessionStore := session.GetSession(req) sessionStore := session.GetSession(req)
if sessionStore == nil {
if setting.IsProd() {
http.Error(w, http.StatusText(500), 500)
} else {
http.Error(w, combinedErr, 500)
}
return
}
var lc = middleware.Locale(w, req) var lc = middleware.Locale(w, req)
var store = dataStore{ var store = dataStore{

2
routers/web/user/setting/adopt.go

@ -27,7 +27,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
action := ctx.Query("action") action := ctx.Query("action")
ctxUser := ctx.User ctxUser := ctx.User
root := filepath.Join(models.UserPath(ctxUser.LowerName)) root := models.UserPath(ctxUser.LowerName)
// check not a repo // check not a repo
has, err := models.IsRepositoryExist(ctxUser, dir) has, err := models.IsRepositoryExist(ctxUser, dir)

2
routers/web/user/setting/profile.go

@ -246,7 +246,7 @@ func Repos(ctx *context.Context) {
repoNames := make([]string, 0, setting.UI.Admin.UserPagingNum) repoNames := make([]string, 0, setting.UI.Admin.UserPagingNum)
repos := map[string]*models.Repository{} repos := map[string]*models.Repository{}
// We're going to iterate by pagesize. // We're going to iterate by pagesize.
root := filepath.Join(models.UserPath(ctxUser.Name)) root := models.UserPath(ctxUser.Name)
if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil { if err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {

1
services/auth/placeholder.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !windows
// +build !windows // +build !windows
package auth package auth

2
services/pull/check.go

@ -254,7 +254,7 @@ func CheckPrsForBaseBranch(baseRepo *models.Repository, baseBranchName string) e
// Init runs the task queue to test all the checking status pull requests // Init runs the task queue to test all the checking status pull requests
func Init() error { func Init() error {
prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "").(queue.UniqueQueue) prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "")
if prQueue == nil { if prQueue == nil {
return fmt.Errorf("Unable to create pr_patch_checker Queue") return fmt.Errorf("Unable to create pr_patch_checker Queue")

4
services/pull/merge.go

@ -273,8 +273,8 @@ func rawMerge(pr *models.PullRequest, doer *models.User, mergeStyle models.Merge
filepath.Join(tmpBasePath, ".git", "rebase-merge", "stopped-sha"), // Git >= 2.26 filepath.Join(tmpBasePath, ".git", "rebase-merge", "stopped-sha"), // Git >= 2.26
} }
for _, failingCommitPath := range failingCommitPaths { for _, failingCommitPath := range failingCommitPaths {
if _, statErr := os.Stat(filepath.Join(failingCommitPath)); statErr == nil { if _, statErr := os.Stat(failingCommitPath); statErr == nil {
commitShaBytes, readErr := ioutil.ReadFile(filepath.Join(failingCommitPath)) commitShaBytes, readErr := ioutil.ReadFile(failingCommitPath)
if readErr != nil { if readErr != nil {
// Abandon this attempt to handle the error // Abandon this attempt to handle the error
log.Error("git rebase staging on to base [%s:%s -> %s:%s]: %v\n%s\n%s", pr.HeadRepo.FullName(), pr.HeadBranch, pr.BaseRepo.FullName(), pr.BaseBranch, err, outbuf.String(), errbuf.String()) log.Error("git rebase staging on to base [%s:%s -> %s:%s]: %v\n%s\n%s", pr.HeadRepo.FullName(), pr.HeadBranch, pr.BaseRepo.FullName(), pr.BaseBranch, err, outbuf.String(), errbuf.String())

2
services/repository/push.go

@ -36,7 +36,7 @@ func handle(data ...queue.Data) {
} }
func initPushQueue() error { func initPushQueue() error {
pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{}).(queue.Queue) pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{})
if pushQueue == nil { if pushQueue == nil {
return fmt.Errorf("Unable to create push_update Queue") return fmt.Errorf("Unable to create push_update Queue")
} }

1
tools/fuzz.go

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gofuzz
// +build gofuzz // +build gofuzz
package fuzz package fuzz

Loading…
Cancel
Save