mirror of
https://github.com/go-gitea/gitea
synced 2025-08-16 06:28:27 +00:00
Before, in #19732, the old home directory is not correct. This PR introduces a new config option for git home: git.HOME_PATH, which is default to %(APP_DATA_PATH)/home And pass env GNUPGHOME to git command, force Gitea to use a stable GNUPGHOME directory
This commit is contained in:
@@ -105,23 +105,36 @@ type RunOpts struct {
|
||||
PipelineFunc func(context.Context, context.CancelFunc) error
|
||||
}
|
||||
|
||||
func commonBaseEnvs() []string {
|
||||
// at the moment, do not set "GIT_CONFIG_NOSYSTEM", users may have put some configs like "receive.certNonceSeed" in it
|
||||
envs := []string{
|
||||
"HOME=" + HomeDir(), // make Gitea use internal git config only, to prevent conflicts with user's git config
|
||||
"GIT_NO_REPLACE_OBJECTS=1", // ignore replace references (https://git-scm.com/docs/git-replace)
|
||||
}
|
||||
|
||||
// some environment variables should be passed to git command
|
||||
passThroughEnvKeys := []string{
|
||||
"GNUPGHOME", // git may call gnupg to do commit signing
|
||||
}
|
||||
for _, key := range passThroughEnvKeys {
|
||||
if val, ok := os.LookupEnv(key); ok {
|
||||
envs = append(envs, key+"="+val)
|
||||
}
|
||||
}
|
||||
return envs
|
||||
}
|
||||
|
||||
// CommonGitCmdEnvs returns the common environment variables for a "git" command.
|
||||
func CommonGitCmdEnvs() []string {
|
||||
// at the moment, do not set "GIT_CONFIG_NOSYSTEM", users may have put some configs like "receive.certNonceSeed" in it
|
||||
return []string{
|
||||
fmt.Sprintf("LC_ALL=%s", DefaultLocale),
|
||||
"GIT_TERMINAL_PROMPT=0", // avoid prompting for credentials interactively, supported since git v2.3
|
||||
"GIT_NO_REPLACE_OBJECTS=1", // ignore replace references (https://git-scm.com/docs/git-replace)
|
||||
"HOME=" + HomeDir(), // make Gitea use internal git config only, to prevent conflicts with user's git config
|
||||
}
|
||||
return append(commonBaseEnvs(), []string{
|
||||
"LC_ALL=" + DefaultLocale,
|
||||
"GIT_TERMINAL_PROMPT=0", // avoid prompting for credentials interactively, supported since git v2.3
|
||||
}...)
|
||||
}
|
||||
|
||||
// CommonCmdServEnvs is like CommonGitCmdEnvs but it only returns minimal required environment variables for the "gitea serv" command
|
||||
func CommonCmdServEnvs() []string {
|
||||
return []string{
|
||||
"GIT_NO_REPLACE_OBJECTS=1", // ignore replace references (https://git-scm.com/docs/git-replace)
|
||||
"HOME=" + HomeDir(), // make Gitea use internal git config only, to prevent conflicts with user's git config
|
||||
}
|
||||
return commonBaseEnvs()
|
||||
}
|
||||
|
||||
// Run runs the command with the RunOpts
|
||||
|
Reference in New Issue
Block a user