mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 06:30:28 +09:00
@@ -12,31 +12,29 @@ func getTag(match ...string) (string, *semver.PRVersion) {
|
|||||||
args := append([]string{
|
args := append([]string{
|
||||||
"describe", "--tags",
|
"describe", "--tags",
|
||||||
}, match...)
|
}, match...)
|
||||||
var tag []byte
|
if tag, err := exec.Command("git", args...).Output(); err != nil {
|
||||||
var err error
|
return "", nil
|
||||||
if tag, err = exec.Command("git", args...).Output(); err != nil {
|
} else {
|
||||||
if _, err := exec.Command("git", "fetch", "--tags").Output(); err != nil {
|
tagParts := strings.Split(string(tag), "-")
|
||||||
return "", nil
|
if len(tagParts) == 3 {
|
||||||
|
if ahead, err := semver.NewPRVersion(tagParts[1]); err == nil {
|
||||||
|
return tagParts[0], &ahead
|
||||||
|
}
|
||||||
|
} else if len(tagParts) == 4 {
|
||||||
|
if ahead, err := semver.NewPRVersion(tagParts[2]); err == nil {
|
||||||
|
return tagParts[0] + "-" + tagParts[1], &ahead
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if tag, err = exec.Command("git", args...).Output(); err != nil {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tagParts := strings.Split(string(tag), "-")
|
|
||||||
if len(tagParts) == 3 {
|
|
||||||
if ahead, err := semver.NewPRVersion(tagParts[1]); err == nil {
|
|
||||||
return tagParts[0], &ahead
|
|
||||||
}
|
|
||||||
} else if len(tagParts) == 4 {
|
|
||||||
if ahead, err := semver.NewPRVersion(tagParts[2]); err == nil {
|
|
||||||
return tagParts[0] + "-" + tagParts[1], &ahead
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(tag), nil
|
return string(tag), nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if tags, err := exec.Command("git", "tag").Output(); err != nil || len(tags) == 0 {
|
||||||
|
// no tags found -- fetch them
|
||||||
|
exec.Command("git", "fetch", "--tags").Run()
|
||||||
|
}
|
||||||
// Find the last vX.X.X Tag and get how many builds we are ahead of it.
|
// Find the last vX.X.X Tag and get how many builds we are ahead of it.
|
||||||
versionStr, ahead := getTag("--match", "v*")
|
versionStr, ahead := getTag("--match", "v*")
|
||||||
version, err := semver.ParseTolerant(versionStr)
|
version, err := semver.ParseTolerant(versionStr)
|
||||||
|
|||||||
Reference in New Issue
Block a user