mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix: getTag return incorrect tag, if we have more than 1 tag for 1 commit (#1164)
* fix strategy of getting latest tag * add git -c "versionsort.suffix=-" * fix test * fix tests * add more details about change
This commit is contained in:
parent
39d07c375d
commit
2403a40979
@ -74,7 +74,7 @@ func getGitInfo() (context.GitInfo, error) {
|
||||
return context.GitInfo{}, errors.Wrap(err, "couldn't get remote URL")
|
||||
}
|
||||
tag, err := getTag()
|
||||
if err != nil {
|
||||
if err != nil || tag == "" {
|
||||
return context.GitInfo{
|
||||
Commit: full,
|
||||
FullCommit: full,
|
||||
@ -135,7 +135,12 @@ func getFullCommit() (string, error) {
|
||||
}
|
||||
|
||||
func getTag() (string, error) {
|
||||
return git.Clean(git.Run("describe", "--tags", "--abbrev=0"))
|
||||
// Even when version sort is used in git-tag[1], tagnames with the same base version
|
||||
// but different suffixes are still sorted lexicographically, resulting e.g. in prerelease tags
|
||||
// appearing after the main release (e.g. "1.0-rc1" after "1.0").
|
||||
// This variable can be specified to determine the sorting order of tags with different suffixes.
|
||||
// https://git-scm.com/docs/git-config/2.19.2#git-config-versionsortsuffix
|
||||
return git.Clean(git.Run("-c", "versionsort.suffix=-", "tag", "-l", "--sort=-v:refname"))
|
||||
}
|
||||
|
||||
func getURL() (string, error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user