mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-11 05:41:50 +09:00
Backport #39703 by @silverwind Gitea's default `gc.reflogExpire = 90` is parsed by git as `1990-<month>-<day>`, currently `1990-10-09`, so reachable reflog entries never expired. Since git 2.54, auto maintenance runs its reflog-expire task in the foreground of every push, and its trigger ignores reachability, so busy repos rerun `git reflog expire --all` on every push without pruning anything, stalling large repos for over a minute. - Stop setting `gc.reflogExpire` so git's own defaults apply, and remove the `90` written by earlier versions - Treat the legacy `[git.reflog] EXPIRATION` as days, as documented The next push to each repo prunes the accumulated entries once. Fixes: https://github.com/go-gitea/gitea/issues/39693 Co-authored-by: silverwind <me@silverwind.io>
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/modules/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGitConfig(t *testing.T) {
|
|
oldGit := Git
|
|
oldGitConfig := GitConfig
|
|
defer func() {
|
|
Git = oldGit
|
|
GitConfig = oldGitConfig
|
|
}()
|
|
|
|
cfg, err := NewConfigProviderFromData(`
|
|
[git.config]
|
|
a.b = 1
|
|
`)
|
|
assert.NoError(t, err)
|
|
loadGitFrom(cfg)
|
|
assert.Equal(t, "1", GitConfig.Options["a.b"])
|
|
assert.Equal(t, "histogram", GitConfig.Options["diff.algorithm"])
|
|
|
|
cfg, err = NewConfigProviderFromData(`
|
|
[git.config]
|
|
diff.algorithm = other
|
|
`)
|
|
assert.NoError(t, err)
|
|
loadGitFrom(cfg)
|
|
assert.Equal(t, "other", GitConfig.Options["diff.algorithm"])
|
|
}
|
|
|
|
func TestGitReflog(t *testing.T) {
|
|
defer test.MockVariableValue(&Git)()
|
|
defer test.MockVariableValue(&GitConfig)()
|
|
|
|
// default reflog config without legacy options
|
|
cfg, err := NewConfigProviderFromData(``)
|
|
assert.NoError(t, err)
|
|
loadGitFrom(cfg)
|
|
|
|
assert.Equal(t, "true", GitConfig.GetOption("core.logAllRefUpdates"))
|
|
assert.Empty(t, GitConfig.GetOption("gc.reflogExpire"))
|
|
|
|
// custom reflog config by legacy options
|
|
cfg, err = NewConfigProviderFromData(`
|
|
[git.reflog]
|
|
ENABLED = false
|
|
EXPIRATION = 123
|
|
`)
|
|
assert.NoError(t, err)
|
|
loadGitFrom(cfg)
|
|
|
|
assert.Equal(t, "false", GitConfig.GetOption("core.logAllRefUpdates"))
|
|
assert.Equal(t, "123.days", GitConfig.GetOption("gc.reflogExpire"))
|
|
}
|