Browse Source

Handle early git version's lack of get-url (#7065)

tags/v1.9.0-rc1
zeripath 5 years ago
parent
commit
57b2ce03d5
No account linked to committer's email address
1 changed files with 12 additions and 1 deletions
  1. 12
    1
      models/repo_mirror.go

+ 12
- 1
models/repo_mirror.go View File

@@ -20,6 +20,7 @@ import (

"github.com/Unknwon/com"
"github.com/go-xorm/xorm"
"github.com/mcuadros/go-version"
)

// MirrorQueue holds an UniqueQueue object of the mirror
@@ -70,7 +71,17 @@ func (m *Mirror) ScheduleNextUpdate() {
}

func remoteAddress(repoPath string) (string, error) {
cmd := git.NewCommand("remote", "get-url", "origin")
var cmd *git.Command
binVersion, err := git.BinVersion()
if err != nil {
return "", err
}
if version.Compare(binVersion, "2.7", ">=") {
cmd = git.NewCommand("remote", "get-url", "origin")
} else {
cmd = git.NewCommand("config", "--get", "remote.origin.url")
}

result, err := cmd.RunInDir(repoPath)
if err != nil {
if strings.HasPrefix(err.Error(), "exit status 128 - fatal: No such remote ") {

Loading…
Cancel
Save