Browse Source

print out git version

tags/v1.21.12.1
Unknwon 10 years ago
parent
commit
6a6e43f964
2 changed files with 6 additions and 0 deletions
  1. +1
    -0
      models/repo.go
  2. +5
    -0
      modules/git/version.go

+ 1
- 0
models/repo.go View File

@@ -105,6 +105,7 @@ func NewRepoContext() {
if ver.LessThan(reqVer) {
log.Fatal(4, "Gogs requires Git version greater or equal to 1.7.1")
}
log.Info("Git version: %s", ver.String())

// Git requires setting user.name and user.email in order to commit changes.
for configKey, defaultValue := range map[string]string{"user.name": "Gogs", "user.email": "gogs@fake.local"} {


+ 5
- 0
modules/git/version.go View File

@@ -6,6 +6,7 @@ package git

import (
"errors"
"fmt"
"strings"

"github.com/Unknwon/com"
@@ -78,6 +79,10 @@ func (v *Version) AtLeast(that *Version) bool {
return v.Compare(that) >= 0
}

func (v *Version) String() string {
return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch)
}

// GetVersion returns current Git version installed.
func GetVersion() (*Version, error) {
if gitVer != nil {


Loading…
Cancel
Save