Skip to content

Commit

Permalink
Magic Git tag transformations are awesome too
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Sep 16, 2016
1 parent 469bcee commit d451518
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (info Info) LastSemanticVersion() string {
parts = parts[:len(parts)-1]
}
// strip the Git commit
if len(parts) > 1 && reCommitSegment.MatchString(parts[len(parts)-1]) {
if len(parts) > 0 && reCommitSegment.MatchString(parts[len(parts)-1]) {
parts[len(parts)-1] = reCommitSegment.ReplaceAllString(parts[len(parts)-1], "")
if len(parts[len(parts)-1]) == 0 {
parts = parts[:len(parts)-1]
Expand Down
2 changes: 2 additions & 0 deletions pkg/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func TestLastSemanticVersion(t *testing.T) {
{"v1.3-11+abcdef-dirty", "v1.3"},
{"v1.3-11+abcdef", "v1.3"},
{"v1.3-11", "v1.3-11"},
{"v1.3.0+abcdef", "v1.3.0"},
{"v1.3+abcdef", "v1.3"},
{"v1.3.0-alpha.1", "v1.3.0-alpha.1"},
{"v1.3.0-alpha.1-dirty", "v1.3.0-alpha.1"},
{"v1.3.0-alpha.1+abc-dirty", "v1.3.0-alpha.1+abc"},
Expand Down

0 comments on commit d451518

Please sign in to comment.