Skip to content

Commit

Permalink
bug: fix version without tag (#288)
Browse files Browse the repository at this point in the history
* fix version

* add

* fix
  • Loading branch information
VoVAllen authored Jun 12, 2022
1 parent ef3886c commit 2bc13df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ DEBUG_DIR := ./debug-bin
BUILD_DIR := ./build

# Current version of the project.
VERSION ?= $(shell git describe --match 'v[0-9]*' --always)
VERSION ?= $(shell git describe --match 'v[0-9]*' --always --tags)
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_TAG=$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi)
Expand Down
7 changes: 6 additions & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"regexp"
"runtime"
"strings"
"sync"
)

Expand Down Expand Up @@ -67,7 +68,11 @@ func GetVersion() Version {
} else {
// otherwise formulate a version string based on as much metadata
// information we have available.
versionStr = "v" + version
if strings.HasPrefix(version, "v") {
versionStr = version
} else {
versionStr = "v" + version
}
if len(gitCommit) >= 7 {
versionStr += "+" + gitCommit[0:7]
if gitTreeState != "clean" {
Expand Down

0 comments on commit 2bc13df

Please sign in to comment.