forked from forgejo/forgejo
Add git.HOME_PATH
This commit is contained in:
parent
55a22d1136
commit
7f4b6893ec
7 changed files with 31 additions and 13 deletions
|
@ -126,8 +126,8 @@ func VersionInfo() string {
|
|||
}
|
||||
|
||||
func checkInit() error {
|
||||
if setting.RepoRootPath == "" {
|
||||
return errors.New("can not init Git's HomeDir (RepoRootPath is empty), the setting and git modules are not initialized correctly")
|
||||
if setting.Git.HomePath == "" {
|
||||
return errors.New("can not init Git's HomeDir, the setting and git modules are not initialized correctly")
|
||||
}
|
||||
if DefaultContext != nil {
|
||||
log.Warn("git module has been initialized already, duplicate init should be fixed")
|
||||
|
@ -137,14 +137,14 @@ func checkInit() error {
|
|||
|
||||
// HomeDir is the home dir for git to store the global config file used by Gitea internally
|
||||
func HomeDir() string {
|
||||
if setting.RepoRootPath == "" {
|
||||
if setting.Git.HomePath == "" {
|
||||
// strict check, make sure the git module is initialized correctly.
|
||||
// attention: when the git module is called in gitea sub-command (serv/hook), the log module is not able to show messages to users.
|
||||
// for example: if there is gitea git hook code calling git.NewCommand before git.InitXxx, the integration test won't show the real failure reasons.
|
||||
log.Fatal("can not get Git's HomeDir (RepoRootPath is empty), the setting and git modules are not initialized correctly")
|
||||
log.Fatal("can not get Git's HomeDir, the setting and git modules are not initialized correctly")
|
||||
return ""
|
||||
}
|
||||
return setting.RepoRootPath
|
||||
return setting.Git.HomePath
|
||||
}
|
||||
|
||||
// InitSimple initializes git module with a very simple step, no config changes, no global command arguments.
|
||||
|
@ -206,7 +206,7 @@ func InitOnceWithSync(ctx context.Context) (err error) {
|
|||
// syncGitConfig only modifies gitconfig, won't change global variables (otherwise there will be data-race problem)
|
||||
func syncGitConfig() (err error) {
|
||||
if err = os.MkdirAll(HomeDir(), os.ModePerm); err != nil {
|
||||
return fmt.Errorf("unable to create directory %s, err: %w", setting.RepoRootPath, err)
|
||||
return fmt.Errorf("unable to prepare git home directory %s, err: %w", HomeDir(), err)
|
||||
}
|
||||
|
||||
// Git requires setting user.name and user.email in order to commit changes - old comment: "if they're not set just add some defaults"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue