mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-19 06:05:18 +02:00
Merge remote-tracking branch 'upstream/main' into limit-repo-size
This commit is contained in:
+18
-18
@@ -1,28 +1,28 @@
|
||||
linters:
|
||||
enable:
|
||||
- gosimple
|
||||
- deadcode
|
||||
- typecheck
|
||||
- govet
|
||||
- errcheck
|
||||
- staticcheck
|
||||
- unused
|
||||
- structcheck
|
||||
- varcheck
|
||||
- dupl
|
||||
#- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
|
||||
- gofmt
|
||||
- gocritic
|
||||
- bidichk
|
||||
- ineffassign
|
||||
- revive
|
||||
- gofumpt
|
||||
# - deadcode # deprecated - https://github.com/golangci/golangci-lint/issues/1841
|
||||
- depguard
|
||||
- dupl
|
||||
- errcheck
|
||||
- gocritic
|
||||
# - gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- nakedret
|
||||
- unconvert
|
||||
- wastedassign
|
||||
- nolintlint
|
||||
- revive
|
||||
- staticcheck
|
||||
# - structcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
|
||||
- stylecheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
# - varcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
|
||||
# - wastedassign # disabled - https://github.com/golangci/golangci-lint/issues/2649
|
||||
enable-all: false
|
||||
disable-all: true
|
||||
fast: false
|
||||
|
||||
@@ -26,15 +26,15 @@ COMMA := ,
|
||||
XGO_VERSION := go-1.19.x
|
||||
|
||||
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.40.4
|
||||
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.5.0
|
||||
ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@v1.6.1
|
||||
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.3.1
|
||||
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.0
|
||||
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.6.0
|
||||
ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@v1.6.2
|
||||
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.4.0
|
||||
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
|
||||
GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10
|
||||
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4
|
||||
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.0
|
||||
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.3
|
||||
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.3.0
|
||||
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.5.0
|
||||
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@latest
|
||||
|
||||
DOCKER_IMAGE ?= gitea/gitea
|
||||
|
||||
@@ -403,6 +403,9 @@ LOG_SQL = false ; if unset defaults to true
|
||||
;;
|
||||
;; Database maximum number of open connections, default is 0 meaning no maximum
|
||||
;MAX_OPEN_CONNS = 0
|
||||
;;
|
||||
;; Whether execute database models migrations automatically
|
||||
;AUTO_MIGRATION = true
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
@@ -444,6 +444,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
|
||||
- `MAX_OPEN_CONNS` **0**: Database maximum open connections - default is 0, meaning there is no limit.
|
||||
- `MAX_IDLE_CONNS` **2**: Max idle database connections on connection pool, default is 2 - this will be capped to `MAX_OPEN_CONNS`.
|
||||
- `CONN_MAX_LIFETIME` **0 or 3s**: Sets the maximum amount of time a DB connection may be reused - default is 0, meaning there is no limit (except on MySQL where it is 3s - see #6804 & #7071).
|
||||
- `AUTO_MIGRATION` **true**: Whether execute database models migrations automatically.
|
||||
|
||||
Please see #8540 & #8273 for further discussion of the appropriate values for `MAX_OPEN_CONNS`, `MAX_IDLE_CONNS` & `CONN_MAX_LIFETIME` and their
|
||||
relation to port exhaustion.
|
||||
|
||||
@@ -21,8 +21,10 @@ type contextKey struct {
|
||||
}
|
||||
|
||||
// enginedContextKey is a context key. It is used with context.Value() to get the current Engined for the context
|
||||
var enginedContextKey = &contextKey{"engined"}
|
||||
var _ Engined = &Context{}
|
||||
var (
|
||||
enginedContextKey = &contextKey{"engined"}
|
||||
_ Engined = &Context{}
|
||||
)
|
||||
|
||||
// Context represents a db context
|
||||
type Context struct {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models/pull"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
// This migration added non-ideal indices to the action table which on larger datasets slowed things down
|
||||
// it has been superceded by v218.go
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
packages_model "code.gitea.io/gitea/models/packages"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"encoding/base32"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"encoding/base32"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_17 // nolint
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_18 // nolint
|
||||
package v1_18 //nolint
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_18 // nolint
|
||||
package v1_18 //nolint
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_18 // nolint
|
||||
package v1_18 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_18 // nolint
|
||||
package v1_18 //nolint
|
||||
|
||||
import (
|
||||
"xorm.io/builder"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_18 // nolint
|
||||
package v1_18 //nolint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_18 // nolint
|
||||
package v1_18 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_18 // nolint
|
||||
package v1_18 //nolint
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_19 // nolint
|
||||
package v1_19 //nolint
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_19 // nolint
|
||||
package v1_19 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_6 // nolint
|
||||
package v1_6 //nolint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_6 // nolint
|
||||
package v1_6 //nolint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_6 // nolint
|
||||
package v1_6 //nolint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_7 // nolint
|
||||
package v1_7 //nolint
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_7 // nolint
|
||||
package v1_7 //nolint
|
||||
|
||||
import "xorm.io/xorm"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_7 // nolint
|
||||
package v1_7 //nolint
|
||||
|
||||
import (
|
||||
"xorm.io/builder"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_8 // nolint
|
||||
package v1_8 //nolint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_8 // nolint
|
||||
package v1_8 //nolint
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_8 // nolint
|
||||
package v1_8 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_8 // nolint
|
||||
package v1_8 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_8 // nolint
|
||||
package v1_8 //nolint
|
||||
|
||||
import "xorm.io/xorm"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_8 // nolint
|
||||
package v1_8 //nolint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_9 // nolint
|
||||
package v1_9 //nolint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -6,6 +6,7 @@ package repo
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
@@ -43,7 +44,7 @@ func (stats LanguageStatList) LoadAttributes() {
|
||||
|
||||
func (stats LanguageStatList) getLanguagePercentages() map[string]float32 {
|
||||
langPerc := make(map[string]float32)
|
||||
var otherPerc float32 = 100
|
||||
var otherPerc float32
|
||||
var total int64
|
||||
|
||||
for _, stat := range stats {
|
||||
@@ -51,21 +52,52 @@ func (stats LanguageStatList) getLanguagePercentages() map[string]float32 {
|
||||
}
|
||||
if total > 0 {
|
||||
for _, stat := range stats {
|
||||
perc := float32(math.Round(float64(stat.Size)/float64(total)*1000) / 10)
|
||||
perc := float32(float64(stat.Size) / float64(total) * 100)
|
||||
if perc <= 0.1 {
|
||||
otherPerc += perc
|
||||
continue
|
||||
}
|
||||
otherPerc -= perc
|
||||
langPerc[stat.Language] = perc
|
||||
}
|
||||
otherPerc = float32(math.Round(float64(otherPerc)*10) / 10)
|
||||
}
|
||||
if otherPerc > 0 {
|
||||
langPerc["other"] = otherPerc
|
||||
}
|
||||
roundByLargestRemainder(langPerc, 100)
|
||||
return langPerc
|
||||
}
|
||||
|
||||
// Rounds to 1 decimal point, target should be the expected sum of percs
|
||||
func roundByLargestRemainder(percs map[string]float32, target float32) {
|
||||
leftToDistribute := int(target * 10)
|
||||
|
||||
keys := make([]string, 0, len(percs))
|
||||
|
||||
for k, v := range percs {
|
||||
percs[k] = v * 10
|
||||
floored := math.Floor(float64(percs[k]))
|
||||
leftToDistribute -= int(floored)
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
// Sort the keys by the largest remainder
|
||||
sort.SliceStable(keys, func(i, j int) bool {
|
||||
_, remainderI := math.Modf(float64(percs[keys[i]]))
|
||||
_, remainderJ := math.Modf(float64(percs[keys[j]]))
|
||||
return remainderI > remainderJ
|
||||
})
|
||||
|
||||
// Increment the values in order of largest remainder
|
||||
for _, k := range keys {
|
||||
percs[k] = float32(math.Floor(float64(percs[k])))
|
||||
if leftToDistribute > 0 {
|
||||
percs[k]++
|
||||
leftToDistribute--
|
||||
}
|
||||
percs[k] /= 10
|
||||
}
|
||||
}
|
||||
|
||||
// GetLanguageStats returns the language statistics for a repository
|
||||
func GetLanguageStats(ctx context.Context, repo *Repository) (LanguageStatList, error) {
|
||||
stats := make(LanguageStatList, 0, 6)
|
||||
|
||||
@@ -239,7 +239,7 @@ func (counts runeCountType) needsEscape() bool {
|
||||
type runeType int
|
||||
|
||||
const (
|
||||
basicASCIIRuneType runeType = iota //nolint // <- This is technically deadcode but its self-documenting so it should stay
|
||||
basicASCIIRuneType runeType = iota // <- This is technically deadcode but its self-documenting so it should stay
|
||||
brokenRuneType
|
||||
nonBasicASCIIRuneType
|
||||
ambiguousRuneType
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func checkDBVersion(ctx context.Context, logger log.Logger, autofix bool) error {
|
||||
logger.Info("Expected database version: %d", migrations.ExpectedVersion())
|
||||
if err := db.InitEngineWithMigration(ctx, migrations.EnsureUpToDate); err != nil {
|
||||
if !autofix {
|
||||
logger.Critical("Error: %v during ensure up to date", err)
|
||||
|
||||
@@ -6,7 +6,7 @@ package log
|
||||
import "unsafe"
|
||||
|
||||
//go:linkname runtime_getProfLabel runtime/pprof.runtime_getProfLabel
|
||||
func runtime_getProfLabel() unsafe.Pointer // nolint
|
||||
func runtime_getProfLabel() unsafe.Pointer //nolint
|
||||
|
||||
type labelMap map[string]string
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ var (
|
||||
MaxOpenConns int
|
||||
ConnMaxLifetime time.Duration
|
||||
IterateBufferSize int
|
||||
AutoMigration bool
|
||||
}{
|
||||
Timeout: 500,
|
||||
IterateBufferSize: 50,
|
||||
@@ -105,6 +106,7 @@ func InitDBConfig() {
|
||||
Database.LogSQL = sec.Key("LOG_SQL").MustBool(true)
|
||||
Database.DBConnectRetries = sec.Key("DB_RETRIES").MustInt(10)
|
||||
Database.DBConnectBackoff = sec.Key("DB_RETRY_BACKOFF").MustDuration(3 * time.Second)
|
||||
Database.AutoMigration = sec.Key("AUTO_MIGRATION").MustBool(true)
|
||||
}
|
||||
|
||||
// DBConnStr returns database connection string
|
||||
|
||||
@@ -941,7 +941,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
|
||||
if SecretKey == "" {
|
||||
// FIXME: https://github.com/go-gitea/gitea/issues/16832
|
||||
// Until it supports rotating an existing secret key, we shouldn't move users off of the widely used default value
|
||||
SecretKey = "!#@FDEWREWR&*(" // nolint:gosec
|
||||
SecretKey = "!#@FDEWREWR&*(" //nolint:gosec
|
||||
}
|
||||
|
||||
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
|
||||
|
||||
@@ -1021,7 +1021,7 @@ unstar = Unstar
|
||||
star = Star
|
||||
fork = Fork
|
||||
download_archive = Download Repository
|
||||
more_actions = More Actions
|
||||
more_operations = More Operations
|
||||
|
||||
no_desc = No Description
|
||||
quick_guide = Quick Guide
|
||||
@@ -1176,7 +1176,7 @@ commits.signed_by_untrusted_user_unmatched = Signed by untrusted user who does n
|
||||
commits.gpg_key_id = GPG Key ID
|
||||
commits.ssh_key_fingerprint = SSH Key Fingerprint
|
||||
|
||||
commit.actions = Actions
|
||||
commit.operations = Operations
|
||||
commit.revert = Revert
|
||||
commit.revert-header = Revert: %s
|
||||
commit.revert-content = Select branch to revert onto:
|
||||
@@ -2992,7 +2992,7 @@ monitor.queue.pool.cancel_desc = Leaving a queue without any worker groups may c
|
||||
|
||||
notices.system_notice_list = System Notices
|
||||
notices.view_detail_header = View Notice Details
|
||||
notices.actions = Actions
|
||||
notices.operations = Operations
|
||||
notices.select_all = Select All
|
||||
notices.deselect_all = Deselect All
|
||||
notices.inverse_selection = Inverse Selection
|
||||
|
||||
@@ -21,8 +21,10 @@ import (
|
||||
)
|
||||
|
||||
// https://peps.python.org/pep-0426/#name
|
||||
var normalizer = strings.NewReplacer(".", "-", "_", "-")
|
||||
var nameMatcher = regexp.MustCompile(`\A(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\.\-_]*[a-zA-Z0-9])\z`)
|
||||
var (
|
||||
normalizer = strings.NewReplacer(".", "-", "_", "-")
|
||||
nameMatcher = regexp.MustCompile(`\A(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\.\-_]*[a-zA-Z0-9])\z`)
|
||||
)
|
||||
|
||||
// https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions
|
||||
var versionMatcher = regexp.MustCompile(`\Av?` +
|
||||
|
||||
+20
-1
@@ -12,6 +12,8 @@ import (
|
||||
"code.gitea.io/gitea/models/migrations"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
// InitDBEngine In case of problems connecting to DB, retry connection. Eg, PGSQL in Docker Container on Synology
|
||||
@@ -24,7 +26,7 @@ func InitDBEngine(ctx context.Context) (err error) {
|
||||
default:
|
||||
}
|
||||
log.Info("ORM engine initialization attempt #%d/%d...", i+1, setting.Database.DBConnectRetries)
|
||||
if err = db.InitEngineWithMigration(ctx, migrations.Migrate); err == nil {
|
||||
if err = db.InitEngineWithMigration(ctx, migrateWithSetting); err == nil {
|
||||
break
|
||||
} else if i == setting.Database.DBConnectRetries-1 {
|
||||
return err
|
||||
@@ -36,3 +38,20 @@ func InitDBEngine(ctx context.Context) (err error) {
|
||||
db.HasEngine = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func migrateWithSetting(x *xorm.Engine) error {
|
||||
if setting.Database.AutoMigration {
|
||||
return migrations.Migrate(x)
|
||||
}
|
||||
|
||||
if current, err := migrations.GetCurrentDBVersion(x); err != nil {
|
||||
return err
|
||||
} else if current < 0 {
|
||||
// execute migrations when the database isn't initialized even if AutoMigration is false
|
||||
return migrations.Migrate(x)
|
||||
} else if expected := migrations.ExpectedVersion(); current != expected {
|
||||
log.Fatal(`"database.AUTO_MIGRATION" is disabled, but current database version %d is not equal to the expected version %d.`+
|
||||
`You can set "database.AUTO_MIGRATION" to true or migrate manually by running "gitea [--config /path/to/app.ini] migrate"`, current, expected)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div class="ui floating upward dropdown small button">
|
||||
<span class="text">{{.locale.Tr "admin.notices.actions"}}</span>
|
||||
<span class="text">{{.locale.Tr "admin.notices.operations"}}</span>
|
||||
<div class="menu">
|
||||
<div class="item select action" data-action="select-all">
|
||||
{{.locale.Tr "admin.notices.select_all"}}
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
{{.locale.Tr "repo.diff.browse_source"}}
|
||||
</a>
|
||||
{{if and ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}{{- /* */ -}}
|
||||
<div class="ui primary tiny floating dropdown icon button">{{.locale.Tr "repo.commit.actions"}}
|
||||
<div class="ui primary tiny floating dropdown icon button">{{.locale.Tr "repo.commit.operations"}}
|
||||
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
||||
<div class="menu">
|
||||
<div class="ui header">{{.locale.Tr "repo.commit.actions"}}</div>
|
||||
<div class="ui header">{{.locale.Tr "repo.commit.operations"}}</div>
|
||||
<div class="divider"></div>
|
||||
<div class="item show-create-branch-modal"
|
||||
data-content="{{$.locale.Tr "repo.branch.new_branch_from" (.CommitID)}}"
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
{{if eq $n 0}}
|
||||
<div class="ui action tiny input" id="clone-panel">
|
||||
{{template "repo/clone_buttons" .}}
|
||||
<button id="more-btn" class="ui basic small compact jump dropdown icon button tooltip" data-content="{{.locale.Tr "repo.more_actions"}}" data-position="top right">
|
||||
<button id="more-btn" class="ui basic small compact jump dropdown icon button tooltip" data-content="{{.locale.Tr "repo.more_operations"}}" data-position="top right">
|
||||
{{svg "octicon-kebab-horizontal"}}
|
||||
<div class="menu">
|
||||
{{if not $.DisableDownloadSourceArchives}}
|
||||
|
||||
@@ -36,21 +36,21 @@
|
||||
</h3>
|
||||
<div class="download df ac">
|
||||
{{if $.Permission.CanRead $.UnitTypeCode}}
|
||||
<a class="mr-3 mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
|
||||
<a class="mr-3 mono muted" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
|
||||
{{if not $.DisableDownloadSourceArchives}}
|
||||
<a class="archive-link mr-3" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}ZIP</a>
|
||||
<a class="archive-link mr-3" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}TAR.GZ</a>
|
||||
<a class="archive-link mr-3 muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}ZIP</a>
|
||||
<a class="archive-link mr-3 muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}TAR.GZ</a>
|
||||
{{end}}
|
||||
{{if (and $.CanCreateRelease $release.IsTag)}}
|
||||
<a class="mr-3" href="{{$.RepoLink}}/releases/new?tag={{.TagName}}">{{svg "octicon-tag" 16 "mr-2"}}{{$.locale.Tr "repo.release.new_release"}}</a>
|
||||
<a class="mr-3 muted" href="{{$.RepoLink}}/releases/new?tag={{.TagName}}">{{svg "octicon-tag" 16 "mr-2"}}{{$.locale.Tr "repo.release.new_release"}}</a>
|
||||
{{end}}
|
||||
{{if (and ($.Permission.CanWrite $.UnitTypeCode) $release.IsTag)}}
|
||||
<a class="ui red delete-button mr-3" data-url="{{$.RepoLink}}/tags/delete" data-id="{{.ID}}">
|
||||
<a class="ui delete-button mr-3 muted" data-url="{{$.RepoLink}}/tags/delete" data-id="{{.ID}}">
|
||||
{{svg "octicon-trash" 16 "mr-2"}}{{$.locale.Tr "repo.release.delete_tag"}}
|
||||
</a>
|
||||
{{end}}
|
||||
{{if (not $release.IsTag)}}
|
||||
<a class="mr-3" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{svg "octicon-tag" 16 "mr-2"}}{{$.locale.Tr "repo.release.detail"}}</a>
|
||||
<a class="mr-3 muted" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{svg "octicon-tag" 16 "mr-2"}}{{$.locale.Tr "repo.release.detail"}}</a>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -69,19 +69,10 @@
|
||||
{{if .IsTag}}
|
||||
{{if .CreatedUnix}}<span class="time">{{TimeSinceUnix .CreatedUnix $.locale}}</span>{{end}}
|
||||
{{else}}
|
||||
{{if .IsDraft}}
|
||||
<span class="ui yellow label">{{$.locale.Tr "repo.release.draft"}}</span>
|
||||
{{else if .IsPrerelease}}
|
||||
<span class="ui orange label">{{$.locale.Tr "repo.release.prerelease"}}</span>
|
||||
{{else}}
|
||||
<span class="ui green label">{{$.locale.Tr "repo.release.stable"}}</span>
|
||||
{{end}}
|
||||
<span class="tag text blue">
|
||||
<a class="df ac je" href="{{if not .Sha1}}#{{else}}{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "mr-2"}}{{.TagName}}</a>
|
||||
</span>
|
||||
<a class="df ac je muted" href="{{if not .Sha1}}#{{else}}{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "mr-2"}}{{.TagName}}</a>
|
||||
{{if .Sha1}}
|
||||
<span class="commit">
|
||||
<a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
|
||||
<a class="mono muted" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
|
||||
</span>
|
||||
{{template "repo/branch_dropdown" dict "root" $ "release" .}}
|
||||
{{end}}
|
||||
@@ -89,36 +80,56 @@
|
||||
</div>
|
||||
<div class="ui twelve wide column detail">
|
||||
{{if .IsTag}}
|
||||
<h4>
|
||||
<a href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{svg "octicon-tag" 16 "mr-2"}}{{.TagName}}</a>
|
||||
</h4>
|
||||
<div class="df ac sb fw mb-3">
|
||||
<h4 class="release-list-title df ac">
|
||||
<a class="df ac" href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{svg "octicon-tag" 24 "mr-3"}}{{.TagName}}</a>
|
||||
</h4>
|
||||
</div>
|
||||
<p class="text grey">
|
||||
{{if gt .Publisher.ID 0}}
|
||||
<span class="author">
|
||||
{{avatar .Publisher 20}}
|
||||
<a href="{{.Publisher.HomeLink}}">{{.Publisher.Name}}</a>
|
||||
</span>
|
||||
<span class="released">
|
||||
{{$.locale.Tr "repo.released_this"}}
|
||||
</span>
|
||||
{{if .CreatedUnix}}
|
||||
<span class="time">{{TimeSinceUnix .CreatedUnix $.locale}}</span>
|
||||
{{end}}
|
||||
|
|
||||
{{end}}
|
||||
<span class="ahead"><a href="{{$.RepoLink}}/compare/{{.TagName | PathEscapeSegments}}{{if .Target}}...{{.Target | PathEscapeSegments}}{{end}}">{{$.locale.Tr "repo.release.ahead.commits" .NumCommitsBehind | Str2html}}</a> {{$.locale.Tr "repo.release.ahead.target" $.DefaultBranch}}</span>
|
||||
</p>
|
||||
<div class="download">
|
||||
{{if $.Permission.CanRead $.UnitTypeCode}}
|
||||
<a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
|
||||
<a class="mono muted" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
|
||||
{{if not $.DisableDownloadSourceArchives}}
|
||||
<a class="archive-link" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip"}} ZIP</a>
|
||||
<a class="archive-link" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}} TAR.GZ</a>
|
||||
<a class="archive-link muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip"}} ZIP</a>
|
||||
<a class="archive-link muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}} TAR.GZ</a>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
<h4 class="release-list-title df ac">
|
||||
<a href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{.Title}}</a>
|
||||
{{if $.CanCreateRelease}}
|
||||
<small class="ml-2">
|
||||
(<a href="{{$.RepoLink}}/releases/edit/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{$.locale.Tr "repo.release.edit"}}</a>)
|
||||
</small>
|
||||
{{end}}
|
||||
</h4>
|
||||
<div class="df ac sb fw mb-3">
|
||||
<h4 class="release-list-title df ac">
|
||||
<a href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{.Title}}</a>
|
||||
{{if .IsDraft}}
|
||||
<span class="ui yellow label ml-3 mt-1">{{$.locale.Tr "repo.release.draft"}}</span>
|
||||
{{else if .IsPrerelease}}
|
||||
<span class="ui orange label ml-3 mt-1">{{$.locale.Tr "repo.release.prerelease"}}</span>
|
||||
{{else if not .IsTag}}
|
||||
<span class="ui green label ml-3 mt-1">{{$.locale.Tr "repo.release.stable"}}</span>
|
||||
{{end}}
|
||||
</h4>
|
||||
<div class="df ac">
|
||||
{{if $.CanCreateRelease}}
|
||||
<a class="muted tooltip ml-3 df ac" data-content="{{$.locale.Tr "repo.release.edit"}}" href="{{$.RepoLink}}/releases/edit/{{.TagName | PathEscapeSegments}}" rel="nofollow">
|
||||
{{svg "octicon-pencil"}}
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<p class="text grey">
|
||||
<span class="author">
|
||||
{{if .OriginalAuthor}}
|
||||
|
||||
@@ -53,7 +53,7 @@ func checkLatestReleaseAndCount(t *testing.T, session *TestSession, repoURL, ver
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
labelText := htmlDoc.doc.Find("#release-list > li .meta .label").First().Text()
|
||||
labelText := htmlDoc.doc.Find("#release-list > li .detail .label").First().Text()
|
||||
assert.EqualValues(t, label, labelText)
|
||||
titleText := htmlDoc.doc.Find("#release-list > li .detail h4 a").First().Text()
|
||||
assert.EqualValues(t, version, titleText)
|
||||
|
||||
+30
-1
@@ -108,6 +108,8 @@
|
||||
--color-diff-inactive: #f2f2f2;
|
||||
--color-error-border: #e0b4b4;
|
||||
--color-error-bg: #fff6f6;
|
||||
--color-error-bg-active: #fbb;
|
||||
--color-error-bg-hover: #fdd;
|
||||
--color-error-text: #9f3a38;
|
||||
--color-success-border: #a3c293;
|
||||
--color-success-bg: #fcfff5;
|
||||
@@ -1293,6 +1295,11 @@ a.ui.card:hover,
|
||||
.ui.form .fields.error .field input[type="text"],
|
||||
.ui.form .fields.error .field input[type="file"],
|
||||
.ui.form .fields.error .field input[type="url"],
|
||||
.ui.form .fields.error .field .ui.dropdown,
|
||||
.ui.form .fields.error .field .ui.dropdown .item,
|
||||
.ui.form .field.error .ui.dropdown,
|
||||
.ui.form .field.error .ui.dropdown .text,
|
||||
.ui.form .field.error .ui.dropdown .item,
|
||||
.ui.form .field.error textarea,
|
||||
.ui.form .field.error select,
|
||||
.ui.form .field.error input:not([type]),
|
||||
@@ -1321,10 +1328,32 @@ a.ui.card:hover,
|
||||
.ui.form .field.error input[type="file"]:focus,
|
||||
.ui.form .field.error input[type="url"]:focus {
|
||||
background-color: var(--color-error-bg);
|
||||
border: 1px solid var(--color-error-border);
|
||||
border-color: var(--color-error-border);
|
||||
color: var(--color-error-text);
|
||||
}
|
||||
|
||||
.ui.form .fields.error .field .ui.dropdown,
|
||||
.ui.form .field.error .ui.dropdown,
|
||||
.ui.form .fields.error .field .ui.dropdown:hover,
|
||||
.ui.form .field.error .ui.dropdown:hover {
|
||||
border-color: var(--color-error-border) !important;
|
||||
}
|
||||
|
||||
.ui.form .fields.error .field .ui.dropdown .menu .item:hover,
|
||||
.ui.form .field.error .ui.dropdown .menu .item:hover {
|
||||
background-color: var(--color-error-bg-hover);
|
||||
}
|
||||
|
||||
.ui.form .fields.error .field .ui.dropdown .menu .active.item,
|
||||
.ui.form .field.error .ui.dropdown .menu .active.item {
|
||||
background-color: var(--color-error-bg-active) !important;
|
||||
}
|
||||
|
||||
.ui.form .fields.error .dropdown .menu,
|
||||
.ui.form .field.error .dropdown .menu {
|
||||
border-color: var(--color-error-border) !important;
|
||||
}
|
||||
|
||||
.ui.loading.loading.input > i.icon svg {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
@@ -1855,11 +1855,13 @@
|
||||
border-top: 1px solid var(--color-secondary);
|
||||
margin-top: 20px;
|
||||
padding-top: 15px;
|
||||
padding-left: 0;
|
||||
|
||||
.release-list-title {
|
||||
font-size: 2rem;
|
||||
font-weight: normal;
|
||||
margin-top: -6px;
|
||||
margin-top: -4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
> li {
|
||||
@@ -1879,11 +1881,6 @@
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.tag:not(.icon) {
|
||||
display: block;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.commit {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
@@ -1903,7 +1900,7 @@
|
||||
|
||||
.author {
|
||||
img {
|
||||
margin-bottom: -3px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1966,7 +1963,7 @@
|
||||
}
|
||||
|
||||
.release-tag-name {
|
||||
font-size: 20px;
|
||||
font-size: 18px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,8 @@
|
||||
--color-diff-inactive: #353846;
|
||||
--color-error-border: #a04141;
|
||||
--color-error-bg: #522;
|
||||
--color-error-bg-active: #744;
|
||||
--color-error-bg-hover: #633;
|
||||
--color-error-text: #f9cbcb;
|
||||
--color-success-border: #458a57;
|
||||
--color-success-bg: #284034;
|
||||
|
||||
Reference in New Issue
Block a user