1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00

refactor: use git tag --points-at (#1796)

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2020-09-08 10:11:59 -03:00 committed by GitHub
parent cfd53dc728
commit 01942ae60d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,11 +148,26 @@ func getFullCommit() (string, error) {
}
func getTag() (string, error) {
if tag := os.Getenv("GORELEASER_CURRENT_TAG"); tag != "" {
return tag, nil
var tag string
var err error
for _, fn := range []func() (string, error){
func() (string, error) {
return os.Getenv("GORELEASER_CURRENT_TAG"), nil
},
func() (string, error) {
return git.Clean(git.Run("tag", "--points-at", "HEAD", "--sort", "-version:creatordate"))
},
func() (string, error) {
return git.Clean(git.Run("describe", "--tags", "--abbrev=0"))
},
} {
tag, err = fn()
if tag != "" || err != nil {
return tag, err
}
}
return git.Clean(git.Run("describe", "--tags", "--abbrev=0"))
return tag, err
}
func getURL() (string, error) {