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 2 years ago
parent
commit
ea0fe83888
No account linked to committer's email address
96 changed files with 139 additions and 64 deletions
  1. 0
    1
      .golangci.yml
  2. 2
    1
      build.go
  3. 1
    0
      build/generate-bindata.go
  4. 1
    0
      build/generate-emoji.go
  5. 1
    0
      build/generate-gitignores.go
  6. 1
    0
      build/generate-licenses.go
  7. 1
    0
      build/gocovmerge.go
  8. 5
    1
      cmd/docs.go
  9. 1
    0
      cmd/embedded.go
  10. 1
    0
      cmd/embedded_stub.go
  11. 8
    1
      models/migrations/migrations.go
  12. 1
    0
      modules/auth/pam/pam.go
  13. 3
    2
      modules/auth/pam/pam_stub.go
  14. 1
    0
      modules/auth/pam/pam_test.go
  15. 1
    0
      modules/git/blob_gogit.go
  16. 1
    0
      modules/git/blob_nogogit.go
  17. 1
    0
      modules/git/command_test.go
  18. 1
    0
      modules/git/commit_convert_gogit.go
  19. 1
    0
      modules/git/commit_info_gogit.go
  20. 1
    0
      modules/git/commit_info_nogogit.go
  21. 1
    0
      modules/git/last_commit_cache_gogit.go
  22. 1
    0
      modules/git/last_commit_cache_nogogit.go
  23. 1
    0
      modules/git/notes_gogit.go
  24. 1
    0
      modules/git/notes_nogogit.go
  25. 1
    0
      modules/git/parse_gogit.go
  26. 1
    0
      modules/git/parse_gogit_test.go
  27. 1
    0
      modules/git/parse_nogogit.go
  28. 1
    0
      modules/git/parse_nogogit_test.go
  29. 1
    0
      modules/git/pipeline/lfs.go
  30. 1
    0
      modules/git/pipeline/lfs_nogogit.go
  31. 1
    0
      modules/git/repo_base_gogit.go
  32. 1
    0
      modules/git/repo_base_nogogit.go
  33. 1
    0
      modules/git/repo_blob_gogit.go
  34. 1
    0
      modules/git/repo_blob_nogogit.go
  35. 1
    0
      modules/git/repo_branch_gogit.go
  36. 1
    0
      modules/git/repo_branch_nogogit.go
  37. 1
    0
      modules/git/repo_commit_gogit.go
  38. 1
    0
      modules/git/repo_commit_nogogit.go
  39. 1
    0
      modules/git/repo_commitgraph_gogit.go
  40. 1
    0
      modules/git/repo_language_stats_gogit.go
  41. 1
    0
      modules/git/repo_language_stats_nogogit.go
  42. 1
    0
      modules/git/repo_ref_gogit.go
  43. 1
    0
      modules/git/repo_ref_nogogit.go
  44. 1
    0
      modules/git/repo_tag_gogit.go
  45. 1
    0
      modules/git/repo_tag_nogogit.go
  46. 1
    0
      modules/git/repo_tree_gogit.go
  47. 1
    0
      modules/git/repo_tree_nogogit.go
  48. 1
    0
      modules/git/sha1_gogit.go
  49. 1
    0
      modules/git/sha1_nogogit.go
  50. 1
    0
      modules/git/signature_gogit.go
  51. 1
    0
      modules/git/signature_nogogit.go
  52. 1
    3
      modules/git/submodule.go
  53. 1
    0
      modules/git/tree_blob_gogit.go
  54. 1
    0
      modules/git/tree_blob_nogogit.go
  55. 1
    0
      modules/git/tree_entry_gogit.go
  56. 1
    0
      modules/git/tree_entry_nogogit.go
  57. 1
    0
      modules/git/tree_entry_test.go
  58. 1
    0
      modules/git/tree_gogit.go
  59. 1
    0
      modules/git/tree_nogogit.go
  60. 3
    5
      modules/gitgraph/graph_models.go
  61. 3
    2
      modules/graceful/manager_unix.go
  62. 3
    2
      modules/graceful/manager_windows.go
  63. 3
    2
      modules/graceful/net_unix.go
  64. 3
    2
      modules/graceful/net_windows.go
  65. 3
    2
      modules/graceful/restart_unix.go
  66. 4
    0
      modules/indexer/code/bleve.go
  67. 4
    1
      modules/indexer/code/elastic_search.go
  68. 0
    6
      modules/indexer/code/indexer.go
  69. 1
    1
      modules/indexer/stats/queue.go
  70. 1
    3
      modules/lfs/endpoint.go
  71. 1
    0
      modules/lfs/pointer_scanner_gogit.go
  72. 1
    0
      modules/lfs/pointer_scanner_nogogit.go
  73. 1
    1
      modules/markup/common/footnote.go
  74. 3
    2
      modules/options/dynamic.go
  75. 2
    1
      modules/options/options_bindata.go
  76. 1
    0
      modules/options/static.go
  77. 3
    2
      modules/public/dynamic.go
  78. 2
    1
      modules/public/public_bindata.go
  79. 1
    0
      modules/public/static.go
  80. 1
    1
      modules/repository/adopt.go
  81. 1
    0
      modules/setting/database_sqlite.go
  82. 1
    0
      modules/svg/discover_bindata.go
  83. 1
    0
      modules/svg/discover_nobindata.go
  84. 3
    2
      modules/templates/dynamic.go
  85. 1
    0
      modules/templates/static.go
  86. 2
    1
      modules/templates/templates_bindata.go
  87. 3
    2
      routers/private/manager_unix.go
  88. 3
    2
      routers/private/manager_windows.go
  89. 0
    8
      routers/web/base.go
  90. 1
    1
      routers/web/user/setting/adopt.go
  91. 1
    1
      routers/web/user/setting/profile.go
  92. 1
    0
      services/auth/placeholder.go
  93. 1
    1
      services/pull/check.go
  94. 2
    2
      services/pull/merge.go
  95. 1
    1
      services/repository/push.go
  96. 1
    0
      tools/fuzz.go

+ 0
- 1
.golangci.yml View File

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

+ 2
- 1
build.go View File

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

//+build vendor
//go:build vendor
// +build vendor

package main


+ 1
- 0
build/generate-bindata.go View File

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

//go:build ignore
// +build ignore

package main

+ 1
- 0
build/generate-emoji.go View File

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

//go:build ignore
// +build ignore

package main

+ 1
- 0
build/generate-gitignores.go View File

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

package main

+ 1
- 0
build/generate-licenses.go View File

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

package main

+ 1
- 0
build/gocovmerge.go View File

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

//go:build ignore
// +build ignore

package main

+ 5
- 1
cmd/docs.go View File

@@ -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.
// It affects markdown output (even though the issue is referring to man pages)
// 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

+ 1
- 0
cmd/embedded.go View File

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

//go:build bindata
// +build bindata

package cmd

+ 1
- 0
cmd/embedded_stub.go View File

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

//go:build !bindata
// +build !bindata

package cmd

+ 8
- 1
models/migrations/migrations.go View File

@@ -7,6 +7,7 @@ package migrations

import (
"context"
"errors"
"fmt"
"os"
"reflect"
@@ -762,8 +763,14 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
}
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
tableSQL = tableSQL[strings.Index(tableSQL, "("):]
tableSQL = tableSQL[columnDefinitionsIndex:]

// Remove the required columnNames
for _, name := range columnNames {

+ 1
- 0
modules/auth/pam/pam.go View File

@@ -1,3 +1,4 @@
//go:build pam
// +build pam

// Copyright 2014 The Gogs Authors. All rights reserved.

+ 3
- 2
modules/auth/pam/pam_stub.go View File

@@ -1,9 +1,10 @@
// +build !pam

// Copyright 2014 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//go:build !pam
// +build !pam

package pam

import (

+ 1
- 0
modules/auth/pam/pam_test.go View File

@@ -1,3 +1,4 @@
//go:build pam
// +build pam

// Copyright 2021 The Gitea Authors. All rights reserved.

+ 1
- 0
modules/git/blob_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/blob_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/command_test.go View File

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

//go:build race
// +build race

package git

+ 1
- 0
modules/git/commit_convert_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/commit_info_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/commit_info_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/last_commit_cache_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/last_commit_cache_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/notes_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/notes_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/parse_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/parse_gogit_test.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/parse_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/parse_nogogit_test.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/pipeline/lfs.go View File

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

//go:build gogit
// +build gogit

package pipeline

+ 1
- 0
modules/git/pipeline/lfs_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package pipeline

+ 1
- 0
modules/git/repo_base_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/repo_base_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/repo_blob_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/repo_blob_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/repo_branch_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/repo_branch_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/repo_commit_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/repo_commit_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/repo_commitgraph_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/repo_language_stats_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/repo_language_stats_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/repo_ref_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/repo_ref_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/repo_tag_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/repo_tag_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/repo_tree_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/repo_tree_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/sha1_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/sha1_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/signature_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/signature_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 3
modules/git/submodule.go View File

@@ -52,9 +52,7 @@ func getRefURL(refURL, urlPrefix, repoFullName, sshDomain string) string {
urlPrefixHostname = prefixURL.Host
}

if strings.HasSuffix(urlPrefix, "/") {
urlPrefix = urlPrefix[:len(urlPrefix)-1]
}
urlPrefix = strings.TrimSuffix(urlPrefix, "/")

// FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules
// Relative url prefix check (according to git submodule documentation)

+ 1
- 0
modules/git/tree_blob_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/tree_blob_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/tree_entry_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/tree_entry_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 1
- 0
modules/git/tree_entry_test.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/tree_gogit.go View File

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

//go:build gogit
// +build gogit

package git

+ 1
- 0
modules/git/tree_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package git

+ 3
- 5
modules/gitgraph/graph_models.go View File

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

refs = append(refs, git.Reference{
Name: refName,
})

+ 3
- 2
modules/graceful/manager_unix.go View File

@@ -1,9 +1,10 @@
// +build !windows

// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//go:build !windows
// +build !windows

package graceful

import (

+ 3
- 2
modules/graceful/manager_windows.go View File

@@ -1,10 +1,11 @@
// +build windows

// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// This code is heavily inspired by the archived gofacebook/gracenet/net.go handler

//go:build windows
// +build windows

package graceful

import (

+ 3
- 2
modules/graceful/net_unix.go View File

@@ -1,10 +1,11 @@
// +build !windows

// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// This code is heavily inspired by the archived gofacebook/gracenet/net.go handler

//go:build !windows
// +build !windows

package graceful

import (

+ 3
- 2
modules/graceful/net_windows.go View File

@@ -1,10 +1,11 @@
// +build windows

// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// This code is heavily inspired by the archived gofacebook/gracenet/net.go handler

//go:build windows
// +build windows

package graceful

import "net"

+ 3
- 2
modules/graceful/restart_unix.go View File

@@ -1,10 +1,11 @@
// +build !windows

// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// This code is heavily inspired by the archived gofacebook/gracenet/net.go handler

//go:build !windows
// +build !windows

package graceful

import (

+ 4
- 0
modules/indexer/code/bleve.go View File

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


+ 4
- 1
modules/indexer/code/elastic_search.go View File

@@ -83,7 +83,10 @@ func NewElasticSearchIndexer(url, indexerName string) (*ElasticSearchIndexer, bo
indexerAliasName: indexerName,
}
exists, err := indexer.init()

if err != nil {
indexer.Close()
return nil, false, err
}
return indexer, !exists, err
}


+ 0
- 6
modules/indexer/code/indexer.go View File

@@ -188,9 +188,6 @@ func Init() {

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

rIndexer, populate, err = NewElasticSearchIndexer(setting.Indexer.RepoConnStr, setting.Indexer.RepoIndexerName)
if err != nil {
if rIndexer != nil {
rIndexer.Close()
}
cancel()
indexer.Close()
close(waitChannel)

+ 1
- 1
modules/indexer/stats/queue.go View File

@@ -27,7 +27,7 @@ func handle(data ...queue.Data) {
}

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 {
return fmt.Errorf("Unable to create repo_stats_update Queue")
}

+ 1
- 3
modules/lfs/endpoint.go View File

@@ -29,9 +29,7 @@ func endpointFromCloneURL(rawurl string) *url.URL {
return ep
}

if strings.HasSuffix(ep.Path, "/") {
ep.Path = ep.Path[:len(ep.Path)-1]
}
ep.Path = strings.TrimSuffix(ep.Path, "/")

if ep.Scheme == "file" {
return ep

+ 1
- 0
modules/lfs/pointer_scanner_gogit.go View File

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

//go:build gogit
// +build gogit

package lfs

+ 1
- 0
modules/lfs/pointer_scanner_nogogit.go View File

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

//go:build !gogit
// +build !gogit

package lfs

+ 1
- 1
modules/markup/common/footnote.go View File

@@ -126,7 +126,7 @@ type Footnote struct {
func (n *Footnote) Dump(source []byte, level int) {
m := map[string]string{}
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)
ast.DumpHelper(n, source, level, m, nil)
}

+ 3
- 2
modules/options/dynamic.go View File

@@ -1,9 +1,10 @@
// +build !bindata

// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//go:build !bindata
// +build !bindata

package options

import (

+ 2
- 1
modules/options/options_bindata.go View File

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

//+build bindata
//go:build bindata
// +build bindata

package options


+ 1
- 0
modules/options/static.go View File

@@ -1,3 +1,4 @@
//go:build bindata
// +build bindata

// Copyright 2016 The Gitea Authors. All rights reserved.

+ 3
- 2
modules/public/dynamic.go View File

@@ -1,9 +1,10 @@
// +build !bindata

// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//go:build !bindata
// +build !bindata

package public

import (

+ 2
- 1
modules/public/public_bindata.go View File

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

//+build bindata
//go:build bindata
// +build bindata

package public


+ 1
- 0
modules/public/static.go View File

@@ -1,3 +1,4 @@
//go:build bindata
// +build bindata

// Copyright 2016 The Gitea Authors. All rights reserved.

+ 1
- 1
modules/repository/adopt.go View File

@@ -152,7 +152,7 @@ func ListUnadoptedRepositories(query string, opts *models.ListOptions) ([]string
count := 0

// 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 != nil {
return err

+ 1
- 0
modules/setting/database_sqlite.go View File

@@ -1,3 +1,4 @@
//go:build sqlite
// +build sqlite

// Copyright 2014 The Gogs Authors. All rights reserved.

+ 1
- 0
modules/svg/discover_bindata.go View File

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

//go:build bindata
// +build bindata

package svg

+ 1
- 0
modules/svg/discover_nobindata.go View File

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

//go:build !bindata
// +build !bindata

package svg

+ 3
- 2
modules/templates/dynamic.go View File

@@ -1,9 +1,10 @@
// +build !bindata

// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//go:build !bindata
// +build !bindata

package templates

import (

+ 1
- 0
modules/templates/static.go View File

@@ -1,3 +1,4 @@
//go:build bindata
// +build bindata

// Copyright 2016 The Gitea Authors. All rights reserved.

+ 2
- 1
modules/templates/templates_bindata.go View File

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

//+build bindata
//go:build bindata
// +build bindata

package templates


+ 3
- 2
routers/private/manager_unix.go View File

@@ -1,9 +1,10 @@
// +build !windows

// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//go:build !windows
// +build !windows

package private

import (

+ 3
- 2
routers/private/manager_windows.go View File

@@ -1,9 +1,10 @@
// +build windows

// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//go:build windows
// +build windows

package private

import (

+ 0
- 8
routers/web/base.go View File

@@ -130,14 +130,6 @@ func Recovery() func(next http.Handler) http.Handler {
log.Error("%v", combinedErr)

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 store = dataStore{

+ 1
- 1
routers/web/user/setting/adopt.go View File

@@ -27,7 +27,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
action := ctx.Query("action")

ctxUser := ctx.User
root := filepath.Join(models.UserPath(ctxUser.LowerName))
root := models.UserPath(ctxUser.LowerName)

// check not a repo
has, err := models.IsRepositoryExist(ctxUser, dir)

+ 1
- 1
routers/web/user/setting/profile.go View File

@@ -246,7 +246,7 @@ func Repos(ctx *context.Context) {
repoNames := make([]string, 0, setting.UI.Admin.UserPagingNum)
repos := map[string]*models.Repository{}
// 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 != nil {
if os.IsNotExist(err) {

+ 1
- 0
services/auth/placeholder.go View File

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

//go:build !windows
// +build !windows

package auth

+ 1
- 1
services/pull/check.go View File

@@ -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
func Init() error {
prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "").(queue.UniqueQueue)
prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "")

if prQueue == nil {
return fmt.Errorf("Unable to create pr_patch_checker Queue")

+ 2
- 2
services/pull/merge.go View File

@@ -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
}
for _, failingCommitPath := range failingCommitPaths {
if _, statErr := os.Stat(filepath.Join(failingCommitPath)); statErr == nil {
commitShaBytes, readErr := ioutil.ReadFile(filepath.Join(failingCommitPath))
if _, statErr := os.Stat(failingCommitPath); statErr == nil {
commitShaBytes, readErr := ioutil.ReadFile(failingCommitPath)
if readErr != nil {
// 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())

+ 1
- 1
services/repository/push.go View File

@@ -36,7 +36,7 @@ func handle(data ...queue.Data) {
}

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 {
return fmt.Errorf("Unable to create push_update Queue")
}

+ 1
- 0
tools/fuzz.go View File

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

//go:build gofuzz
// +build gofuzz

package fuzz

Loading…
Cancel
Save