File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
20
20
21
21
"github.com/Unknwon/com"
22
22
"github.com/go-xorm/xorm"
23
+ "github.com/mcuadros/go-version"
23
24
)
24
25
25
26
// MirrorQueue holds an UniqueQueue object of the mirror
@@ -70,7 +71,17 @@ func (m *Mirror) ScheduleNextUpdate() {
70
71
}
71
72
72
73
func remoteAddress (repoPath string ) (string , error ) {
73
- cmd := git .NewCommand ("remote" , "get-url" , "origin" )
74
+ var cmd * git.Command
75
+ binVersion , err := git .BinVersion ()
76
+ if err != nil {
77
+ return "" , err
78
+ }
79
+ if version .Compare (binVersion , "2.7" , ">=" ) {
80
+ cmd = git .NewCommand ("remote" , "get-url" , "origin" )
81
+ } else {
82
+ cmd = git .NewCommand ("config" , "--get" , "remote.origin.url" )
83
+ }
84
+
74
85
result , err := cmd .RunInDir (repoPath )
75
86
if err != nil {
76
87
if strings .HasPrefix (err .Error (), "exit status 128 - fatal: No such remote " ) {
You can’t perform that action at this time.
0 commit comments