Add git commit to version output
This commit is contained in:
parent
1a7b665376
commit
94cc596afa
4
Makefile
4
Makefile
@ -12,9 +12,11 @@ else
|
||||
endif
|
||||
|
||||
LUME_VERSION ?= $(shell git describe --tags --always)
|
||||
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
||||
LDFLAGS := $(LDFLAGS) \
|
||||
-X git.kill0.net/chill9/lume/cmd.Version=$(LUME_VERSION) \
|
||||
-X git.kill0.net/chill9/lume/cmd.BuildDate=$(BUILD_DATE)
|
||||
-X git.kill0.net/chill9/lume/cmd.BuildDate=$(BUILD_DATE) \
|
||||
-X git.kill0.net/chill9/lume/cmd.GitCommit=$(GIT_COMMIT)
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
|
@ -29,8 +29,9 @@ func init() {
|
||||
RegisterCommand(NewCmdVersion())
|
||||
}
|
||||
|
||||
var Version string = "0.1.0-pre"
|
||||
var Version string
|
||||
var BuildDate string
|
||||
var GitCommit string
|
||||
|
||||
const lumercFile string = ".lumerc"
|
||||
|
||||
|
@ -2,7 +2,7 @@ package lumecmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func NewCmdVersion() Command {
|
||||
@ -16,11 +16,18 @@ func NewCmdVersion() Command {
|
||||
}
|
||||
|
||||
func VersionCmd(args CmdArgs) (int, error) {
|
||||
fmt.Printf("lume %s\n", Version)
|
||||
fmt.Printf(" os/arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
|
||||
fmt.Printf(" go version: %s\n", runtime.Version())
|
||||
if BuildDate != "" {
|
||||
fmt.Printf(" build date: %s\n", BuildDate)
|
||||
var b strings.Builder
|
||||
|
||||
fmt.Fprintf(&b, "lume %s", Version)
|
||||
b.WriteString(" ")
|
||||
if GitCommit != "" {
|
||||
fmt.Fprintf(&b, "(git: %s)", GitCommit)
|
||||
b.WriteString(" ")
|
||||
}
|
||||
if BuildDate != "" {
|
||||
fmt.Fprintf(&b, "build_date: %s", BuildDate)
|
||||
}
|
||||
|
||||
fmt.Println(b.String())
|
||||
return ExitSuccess, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user