mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-28 05:05:25 +08:00
Pass --global
when calling git config --get
, for consistency with git config --set
(#23157)
This arose out of #22451; it seems we are checking using non-global settings to see if a config value is set, in order to decide whether to call another global(-indeed) configuration command. This PR changes it so that both the check and the set are for global configuration.
This commit is contained in:
parent
f5987c24e2
commit
cbbd3726b4
@ -312,7 +312,7 @@ func CheckGitVersionAtLeast(atLeast string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func configSet(key, value string) error {
|
func configSet(key, value string) error {
|
||||||
stdout, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key).RunStdString(nil)
|
stdout, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
|
||||||
if err != nil && !err.IsExitCode(1) {
|
if err != nil && !err.IsExitCode(1) {
|
||||||
return fmt.Errorf("failed to get git config %s, err: %w", key, err)
|
return fmt.Errorf("failed to get git config %s, err: %w", key, err)
|
||||||
}
|
}
|
||||||
@ -331,7 +331,7 @@ func configSet(key, value string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func configSetNonExist(key, value string) error {
|
func configSetNonExist(key, value string) error {
|
||||||
_, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key).RunStdString(nil)
|
_, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// already exist
|
// already exist
|
||||||
return nil
|
return nil
|
||||||
@ -349,7 +349,7 @@ func configSetNonExist(key, value string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func configAddNonExist(key, value string) error {
|
func configAddNonExist(key, value string) error {
|
||||||
_, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil)
|
_, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// already exist
|
// already exist
|
||||||
return nil
|
return nil
|
||||||
@ -366,7 +366,7 @@ func configAddNonExist(key, value string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func configUnsetAll(key, value string) error {
|
func configUnsetAll(key, value string) error {
|
||||||
_, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key).RunStdString(nil)
|
_, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// exist, need to remove
|
// exist, need to remove
|
||||||
_, _, err = NewCommand(DefaultContext, "config", "--global", "--unset-all").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil)
|
_, _, err = NewCommand(DefaultContext, "config", "--global", "--unset-all").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user