aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_mirror.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-05-29 06:49:08 +0100
committerGitHub <noreply@github.com>2019-05-29 06:49:08 +0100
commit57b2ce03d5081bdf7996879be2da300e8f4c6f58 (patch)
tree9cb70e1bdbf9c3170f7a6aef33df858191441cda /models/repo_mirror.go
parentd01e728090c72ea7f8949107958aa0aa085b6f23 (diff)
downloadgitea-57b2ce03d5081bdf7996879be2da300e8f4c6f58.tar.gz
gitea-57b2ce03d5081bdf7996879be2da300e8f4c6f58.zip
Handle early git version's lack of get-url (#7065)
Diffstat (limited to 'models/repo_mirror.go')
-rw-r--r--models/repo_mirror.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/models/repo_mirror.go b/models/repo_mirror.go
index b58fa05dfe..7579231d8c 100644
--- a/models/repo_mirror.go
+++ b/models/repo_mirror.go
@@ -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 ") {