-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support changing git config through
app.ini
, use `diff.algorithm=hi…
…stogram` 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>
- Loading branch information
1 parent
910bf31
commit 8080ace
Showing
7 changed files
with
134 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2019 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package setting | ||
|
||
import ( | ||
"testing" | ||
|
||
"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.Len(t, GitConfig.Options, 2) | ||
assert.EqualValues(t, "1", GitConfig.Options["a.b"]) | ||
assert.EqualValues(t, "histogram", GitConfig.Options["diff.algorithm"]) | ||
|
||
cfg, err = NewConfigProviderFromData(` | ||
[git.config] | ||
diff.algorithm = other | ||
`) | ||
assert.NoError(t, err) | ||
loadGitFrom(cfg) | ||
|
||
assert.Len(t, GitConfig.Options, 1) | ||
assert.EqualValues(t, "other", GitConfig.Options["diff.algorithm"]) | ||
} |