mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								build.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								build.go
									
									
									
									
									
								
							@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,3 +1,4 @@
 | 
			
		||||
//go:build ignore
 | 
			
		||||
// +build ignore
 | 
			
		||||
 | 
			
		||||
package main
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
//go:build ignore
 | 
			
		||||
// +build ignore
 | 
			
		||||
 | 
			
		||||
package main
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,3 +1,4 @@
 | 
			
		||||
//go:build pam
 | 
			
		||||
// +build pam
 | 
			
		||||
 | 
			
		||||
// Copyright 2014 The Gogs Authors. All rights reserved.
 | 
			
		||||
 
 | 
			
		||||
@@ -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,3 +1,4 @@
 | 
			
		||||
//go:build pam
 | 
			
		||||
// +build pam
 | 
			
		||||
 | 
			
		||||
// Copyright 2021 The Gitea Authors. All rights reserved.
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
		})
 | 
			
		||||
 
 | 
			
		||||
@@ -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 (
 | 
			
		||||
 
 | 
			
		||||
@@ -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 (
 | 
			
		||||
 
 | 
			
		||||
@@ -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 (
 | 
			
		||||
 
 | 
			
		||||
@@ -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"
 | 
			
		||||
 
 | 
			
		||||
@@ -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 (
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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")
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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,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,3 +1,4 @@
 | 
			
		||||
//go:build bindata
 | 
			
		||||
// +build bindata
 | 
			
		||||
 | 
			
		||||
// Copyright 2016 The Gitea Authors. All rights reserved.
 | 
			
		||||
 
 | 
			
		||||
@@ -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,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,3 +1,4 @@
 | 
			
		||||
//go:build bindata
 | 
			
		||||
// +build bindata
 | 
			
		||||
 | 
			
		||||
// Copyright 2016 The Gitea Authors. All rights reserved.
 | 
			
		||||
 
 | 
			
		||||
@@ -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,3 +1,4 @@
 | 
			
		||||
//go:build sqlite
 | 
			
		||||
// +build sqlite
 | 
			
		||||
 | 
			
		||||
// Copyright 2014 The Gogs Authors. All rights reserved.
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,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,3 +1,4 @@
 | 
			
		||||
//go:build bindata
 | 
			
		||||
// +build bindata
 | 
			
		||||
 | 
			
		||||
// Copyright 2016 The Gitea Authors. All rights reserved.
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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 (
 | 
			
		||||
 
 | 
			
		||||
@@ -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 (
 | 
			
		||||
 
 | 
			
		||||
@@ -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{
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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")
 | 
			
		||||
 
 | 
			
		||||
@@ -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())
 | 
			
		||||
 
 | 
			
		||||
@@ -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")
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user