mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-28 00:17:00 +00:00
Support git.PATH entry in app.ini (#6772)
This commit is contained in:
parent
8d9d6aa903
commit
f88aa1d215
@ -670,6 +670,8 @@ SCHEDULE = @every 24h
|
|||||||
UPDATE_EXISTING = true
|
UPDATE_EXISTING = true
|
||||||
|
|
||||||
[git]
|
[git]
|
||||||
|
; The path of git executable. If empty, Gitea searches through the PATH environment.
|
||||||
|
PATH =
|
||||||
; Disables highlight of added and removed changes
|
; Disables highlight of added and removed changes
|
||||||
DISABLE_DIFF_HIGHLIGHT = false
|
DISABLE_DIFF_HIGHLIGHT = false
|
||||||
; Max number of lines allowed in a single file in diff view
|
; Max number of lines allowed in a single file in diff view
|
||||||
|
@ -409,6 +409,7 @@ NB: You must `REDIRECT_MACARON_LOG` and have `DISABLE_ROUTER_LOG` set to `false`
|
|||||||
|
|
||||||
## Git (`git`)
|
## Git (`git`)
|
||||||
|
|
||||||
|
- `PATH`: **""**: The path of git executable. If empty, Gitea searches through the PATH environment.
|
||||||
- `MAX_GIT_DIFF_LINES`: **100**: Max number of lines allowed of a single file in diff view.
|
- `MAX_GIT_DIFF_LINES`: **100**: Max number of lines allowed of a single file in diff view.
|
||||||
- `MAX_GIT_DIFF_LINE_CHARACTERS`: **5000**: Max character count per line highlighted in diff view.
|
- `MAX_GIT_DIFF_LINE_CHARACTERS`: **5000**: Max character count per line highlighted in diff view.
|
||||||
- `MAX_GIT_DIFF_FILES`: **100**: Max number of files shown in diff view.
|
- `MAX_GIT_DIFF_FILES`: **100**: Max number of files shown in diff view.
|
||||||
|
@ -77,20 +77,27 @@ func BinVersion() (string, error) {
|
|||||||
return gitVersion, nil
|
return gitVersion, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
// 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)
|
absPath, err := exec.LookPath(GitExecutable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Git not found: %v", err))
|
return fmt.Errorf("Git not found: %v", err)
|
||||||
}
|
}
|
||||||
GitExecutable = absPath
|
GitExecutable = absPath
|
||||||
|
|
||||||
gitVersion, err := BinVersion()
|
gitVersion, err := BinVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Git version missing: %v", err))
|
return fmt.Errorf("Git version missing: %v", err)
|
||||||
}
|
}
|
||||||
if version.Compare(gitVersion, GitVersionRequired, "<") {
|
if version.Compare(gitVersion, GitVersionRequired, "<") {
|
||||||
panic(fmt.Sprintf("Git version not supported. Requires version > %v", GitVersionRequired))
|
return fmt.Errorf("Git version not supported. Requires version > %v", GitVersionRequired)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes git module
|
// Init initializes git module
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
// Git settings
|
// Git settings
|
||||||
Git = struct {
|
Git = struct {
|
||||||
|
Path string
|
||||||
DisableDiffHighlight bool
|
DisableDiffHighlight bool
|
||||||
MaxGitDiffLines int
|
MaxGitDiffLines int
|
||||||
MaxGitDiffLineCharacters int
|
MaxGitDiffLineCharacters int
|
||||||
@ -59,6 +60,9 @@ func newGit() {
|
|||||||
if err := Cfg.Section("git").MapTo(&Git); err != nil {
|
if err := Cfg.Section("git").MapTo(&Git); err != nil {
|
||||||
log.Fatal("Failed to map Git settings: %v", err)
|
log.Fatal("Failed to map Git settings: %v", err)
|
||||||
}
|
}
|
||||||
|
if err := git.SetExecutablePath(Git.Path); err != nil {
|
||||||
|
log.Fatal("Failed to initialize Git settings", err)
|
||||||
|
}
|
||||||
git.DefaultCommandExecutionTimeout = time.Duration(Git.Timeout.Default) * time.Second
|
git.DefaultCommandExecutionTimeout = time.Duration(Git.Timeout.Default) * time.Second
|
||||||
|
|
||||||
binVersion, err := git.BinVersion()
|
binVersion, err := git.BinVersion()
|
||||||
|
Loading…
Reference in New Issue
Block a user