Merge pull request #2956 from kolyshkin/version

Fix/improve runc -v
This commit is contained in:
Akihiro Suda
2021-05-26 13:09:15 +09:00
committed by GitHub
2 changed files with 6 additions and 9 deletions
+1 -2
View File
@@ -10,8 +10,7 @@ GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
RUNC_IMAGE := runc_dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN))
PROJECT := github.com/opencontainers/runc
BUILDTAGS ?= seccomp
COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),"$(COMMIT_NO)-dirty","$(COMMIT_NO)")
COMMIT ?= $(shell git describe --dirty --long --always)
VERSION := $(shell cat ./VERSION)
# TODO: rm -mod=vendor once go 1.13 is unsupported
+5 -7
View File
@@ -15,9 +15,9 @@ import (
"github.com/urfave/cli"
)
// version will be populated by the Makefile, read from
// VERSION file of the source code.
var version = ""
// version must be set from the contents of VERSION file by go build's
// -X main.version= option in the Makefile.
var version = "unknown"
// gitCommit will be the hash that the binary was built from
// and will be populated by the Makefile
@@ -55,10 +55,8 @@ func main() {
app.Name = "runc"
app.Usage = usage
var v []string
if version != "" {
v = append(v, version)
}
v := []string{version}
if gitCommit != "" {
v = append(v, "commit: "+gitCommit)
}