diff --git a/build.sh b/build.sh index 031df64c..400f72ce 100755 --- a/build.sh +++ b/build.sh @@ -6,7 +6,9 @@ PROTECTED_MODE="no" # Hardcode some values to the core package LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.Version=${VERSION}" -LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.GitSHA=$(git rev-parse --short HEAD)" +if [ -d ".git" ]; then + LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.GitSHA=$(git rev-parse --short HEAD)" +fi LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.BuildTime=$(date +%FT%T%z)" if [ "$PROTECTED_MODE" == "no" ]; then LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.ProtectedMode=no" diff --git a/cmd/tile38-server/main.go b/cmd/tile38-server/main.go index 5c62249a..5be0e9bf 100644 --- a/cmd/tile38-server/main.go +++ b/cmd/tile38-server/main.go @@ -73,6 +73,10 @@ func main() { if host != "" { hostd = "Addr: " + host + ", " } + gitsha := " (" + core.GitSHA + ")" + if gitsha == " (0000000)" { + gitsha = "" + } // _____ _ _ ___ ___ // |_ _|_| |___|_ | . | @@ -82,12 +86,12 @@ func main() { fmt.Fprintf(logw, ` _______ _______ | | | - |____ | _ | Tile38 %s (%s) %d bit (%s/%s) + |____ | _ | Tile38 %s%s %d bit (%s/%s) | | | %sPort: %d, PID: %d |____ | _ | | | | tile38.com |_______|_______| -`+"\n", core.Version, core.GitSHA, strconv.IntSize, runtime.GOARCH, runtime.GOOS, hostd, port, os.Getpid()) +`+"\n", core.Version, gitsha, strconv.IntSize, runtime.GOARCH, runtime.GOOS, hostd, port, os.Getpid()) if err := controller.ListenAndServe(host, port, dir); err != nil { log.Fatal(err)