Support changing git config through app.ini
, use diff.algorithm=histogram
by default (#24860)
Close #13454 , Close #23255, Close #14697 (and maybe more related issues) Many users have the requirement to customize the git config. This PR introduces an easy way: put the options in Gitea's app.ini `[git.config]`, then the config options will be applied to git config. And it can support more flexible default config values, eg: now `diff.algorithm=histogram` by default. According to: https://stackoverflow.com/a/32367597/4754037 , `histogram diff` is efficient and doesn't like to cause server-side problems. --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
parent
910bf31546
commit
8080ace6fc
7 changed files with 134 additions and 38 deletions
|
@ -42,14 +42,14 @@ func TestMain(m *testing.M) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGitConfig(t *testing.T) {
|
||||
gitConfigContains := func(sub string) bool {
|
||||
if b, err := os.ReadFile(HomeDir() + "/.gitconfig"); err == nil {
|
||||
return strings.Contains(string(b), sub)
|
||||
}
|
||||
return false
|
||||
func gitConfigContains(sub string) bool {
|
||||
if b, err := os.ReadFile(HomeDir() + "/.gitconfig"); err == nil {
|
||||
return strings.Contains(string(b), sub)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestGitConfig(t *testing.T) {
|
||||
assert.False(t, gitConfigContains("key-a"))
|
||||
|
||||
assert.NoError(t, configSetNonExist("test.key-a", "val-a"))
|
||||
|
@ -81,3 +81,15 @@ func TestGitConfig(t *testing.T) {
|
|||
assert.NoError(t, configUnsetAll("test.key-x", "*"))
|
||||
assert.False(t, gitConfigContains("key-x = *"))
|
||||
}
|
||||
|
||||
func TestSyncConfig(t *testing.T) {
|
||||
oldGitConfig := setting.GitConfig
|
||||
defer func() {
|
||||
setting.GitConfig = oldGitConfig
|
||||
}()
|
||||
|
||||
setting.GitConfig.Options["sync-test.cfg-key-a"] = "CfgValA"
|
||||
assert.NoError(t, syncGitConfig())
|
||||
assert.True(t, gitConfigContains("[sync-test]"))
|
||||
assert.True(t, gitConfigContains("cfg-key-a = CfgValA"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue