Skip to content

Commit

Permalink
Refactor the version string
Browse files Browse the repository at this point in the history
  • Loading branch information
okushchenko committed Oct 9, 2017
1 parent 6da4394 commit 2e1b45c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,4 @@
echo "Building confd..."
mkdir -p bin

GIT_COMMIT=$(git rev-parse --short HEAD)
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
GIT_COMMIT=${GIT_COMMIT}-dirty
fi

go build -ldflags "-X main.GitCommit=$GIT_COMMIT" -o bin/confd .
go build -ldflags "-X main.GitSHA=$(git rev-parse --short HEAD)" -o bin/confd .
2 changes: 1 addition & 1 deletion confd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func main() {
flag.Parse()
if printVersion {
fmt.Printf("confd %s (Git commit: %s, Go version: %s)\n", Version, GitCommit, runtime.Version())
fmt.Printf("confd %s (Git SHA: %s, Go Version: %s)\n", Version, GitSHA, runtime.Version())
os.Exit(0)
}
if err := initConfig(); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package main

const Version = "0.14.0-dev"

// We want to replace this variable at build time with "-ldflags -X main.GitCommit=xxx", where const is not supported.
var GitCommit = ""
// We want to replace this variable at build time with "-ldflags -X main.GitSHA=xxx", where const is not supported.
var GitSHA = ""

0 comments on commit 2e1b45c

Please sign in to comment.