c572fcfe04
Rename the Go module path from code.gitea.io/gitea to git.mokoconsulting.tech/MokoConsulting/MokoGitea across the entire codebase. Scope: - go.mod module declaration - 2,235 Go source files (import paths) - Dockerfile WORKDIR and COPY paths - Swagger API templates - golangci.yml linter config External dependencies (code.gitea.io/gitea-vet, code.gitea.io/sdk/gitea, gitea.com/gitea/act, etc.) are intentionally NOT renamed — they are separate upstream modules. Closes #132 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
41 lines
1.5 KiB
Go
41 lines
1.5 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package gitcmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
|
|
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/log"
|
|
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/setting"
|
|
)
|
|
|
|
var GitExecutable = "git" // the command name of git, will be updated to an absolute path during initialization
|
|
|
|
// SetExecutablePath changes the path of git executable and checks the file permission and version.
|
|
func SetExecutablePath(path string) error {
|
|
// If path is empty, we use the default value of GitExecutable "git" to search for the location of git.
|
|
if path != "" {
|
|
GitExecutable = path
|
|
}
|
|
absPath, err := exec.LookPath(GitExecutable)
|
|
if err != nil {
|
|
return fmt.Errorf("git not found: %w", err)
|
|
}
|
|
GitExecutable = absPath
|
|
return nil
|
|
}
|
|
|
|
// HomeDir is the home dir for git to store the global config file used by Gitea internally
|
|
func HomeDir() string {
|
|
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 might not obviously show messages to users/developers.
|
|
// for example: if there is gitea git hook code calling NewCommand before git.InitXxx, the integration test won't show the real failure reasons.
|
|
log.Fatal("Unable to init Git's HomeDir, incorrect initialization of the setting and git modules")
|
|
return ""
|
|
}
|
|
return setting.Git.HomePath
|
|
}
|