mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-22 02:53:56 +09:00
Backport #39898 by @wxiaoguang fix #39892 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
+7
-3
@@ -71,12 +71,12 @@ func DefaultFeatures() *Features {
|
||||
func loadGitVersionFeatures() (*Features, error) {
|
||||
stdout, _, runErr := gitcmd.NewCommand("version").RunStdString(context.Background())
|
||||
if runErr != nil {
|
||||
return nil, runErr
|
||||
return nil, fmt.Errorf(`failed to run command "git version": %w`, runErr)
|
||||
}
|
||||
|
||||
ver, err := parseGitVersionLine(strings.TrimSpace(stdout))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf(`failed to parse output of command "git version": %w`, err)
|
||||
}
|
||||
|
||||
features := &Features{gitVersion: ver, UsingGogit: isGogit}
|
||||
@@ -108,7 +108,11 @@ func parseGitVersionLine(s string) (*version.Version, error) {
|
||||
if len(versionFields) > 3 {
|
||||
versionFields = versionFields[:3]
|
||||
}
|
||||
return version.NewVersion(strings.Join(versionFields, "."))
|
||||
ver, err := version.NewVersion(strings.Join(versionFields, "."))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid git version: %q: %w", s, err)
|
||||
}
|
||||
return ver, nil
|
||||
}
|
||||
|
||||
func checkGitVersionCompatibility(gitVer *version.Version) error {
|
||||
|
||||
Reference in New Issue
Block a user