Skip to content

Commit ddc7293

Browse files
committed
fix get version on widnows
1 parent 2a390ae commit ddc7293

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

git.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111
)
1212

13-
const _VERSION = "0.2.1"
13+
const _VERSION = "0.2.2"
1414

1515
func Version() string {
1616
return _VERSION
@@ -49,18 +49,18 @@ func BinVersion() (string, error) {
4949
return "", err
5050
}
5151

52-
// Handle special case on Windows.
53-
i := strings.Index(stdout, "windows")
54-
if i >= 1 {
55-
gitVersion = stdout[:i-1]
56-
return gitVersion, nil
57-
}
58-
5952
fields := strings.Fields(stdout)
6053
if len(fields) < 3 {
6154
return "", fmt.Errorf("not enough output: %s", stdout)
6255
}
6356

57+
// Handle special case on Windows.
58+
i := strings.Index(fields[2], "windows")
59+
if i >= 1 {
60+
gitVersion = fields[2][:i-1]
61+
return gitVersion, nil
62+
}
63+
6464
gitVersion = fields[2]
6565
return gitVersion, nil
6666
}

0 commit comments

Comments
 (0)