From 25f755cb588dfbb1834f0c8630ae9a4c448e494f Mon Sep 17 00:00:00 2001 From: sudoforge Date: Tue, 8 Apr 2025 03:13:05 -0700 Subject: [PATCH] fix: set GitLastTag to an empty string when git-describe errors (#1355) This change refactors the call to `git-describe` made in `//:Makefile`, such that if the call made to populate the `GitLastTag` build argument fails for any reason, the value is an empty string. This resolves a fairly common situation in CI, and reproducible elsewhere, if the local repository does not have any tags. Change-Id: Ie8e06360d5a4016596b96c6371ce4e32ad6a8afb --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8acd2c654715c36250b39e169496cddece4ff601..404612dc34ab673a276c2714a44813f5b8087e6b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ all: build GIT_COMMIT:=$(shell git rev-list -1 HEAD) -GIT_LAST_TAG:=$(shell git describe --abbrev=0 --tags) +GIT_LAST_TAG:=$(shell git describe --abbrev=0 --tags 2>/dev/null || true) GIT_EXACT_TAG:=$(shell git name-rev --name-only --tags HEAD) UNAME_S := $(shell uname -s) XARGS:=xargs -r @@ -10,9 +10,9 @@ ifeq ($(UNAME_S),Darwin) endif COMMANDS_PATH:=github.com/git-bug/git-bug/commands -LDFLAGS:=-X ${COMMANDS_PATH}.GitCommit=${GIT_COMMIT} \ - -X ${COMMANDS_PATH}.GitLastTag=${GIT_LAST_TAG} \ - -X ${COMMANDS_PATH}.GitExactTag=${GIT_EXACT_TAG} +LDFLAGS:=-X ${COMMANDS_PATH}.GitCommit="${GIT_COMMIT}" \ + -X ${COMMANDS_PATH}.GitLastTag="${GIT_LAST_TAG}" \ + -X ${COMMANDS_PATH}.GitExactTag="${GIT_EXACT_TAG}" .PHONY: build build: