Skip to content

Commit c8c3d7c

Browse files
tisonkunLinkinStars
authored andcommitted
build: tolerate build without git repo
Signed-off-by: tison <[email protected]>
1 parent da490d4 commit c8c3d7c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DIR_SRC=./cmd/answer
66
DOCKER_CMD=docker
77

88
GO_ENV=CGO_ENABLED=0 GO111MODULE=on
9-
Revision=$(shell git rev-parse --short HEAD)
9+
Revision=$(shell git rev-parse --short HEAD 2&>/dev/null || echo "")
1010
GO_FLAGS=-ldflags="-X github.com/apache/incubator-answer/cmd.Version=$(VERSION) -X 'github.com/apache/incubator-answer/cmd.Revision=$(Revision)' -X 'github.com/apache/incubator-answer/cmd.Time=`date +%s`' -extldflags -static"
1111
GO=$(GO_ENV) $(shell which go)
1212

cmd/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ var (
4444
// Version is the version of the project
4545
Version = "0.0.0"
4646
// Revision is the git short commit revision number
47-
Revision = "-"
47+
// If built without a Git repository, this field will be empty.
48+
Revision = ""
4849
// Time is the build time of the project
49-
Time = "-"
50+
Time = ""
5051
// GoVersion is the go version of the project
5152
GoVersion = "1.19"
5253
// log level

0 commit comments

Comments
 (0)