From a70bfb87d0d387f2246c13f3457bbcdf933720bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 31 Aug 2022 14:27:53 +0200 Subject: [PATCH] Make: prevent repeating version strings In the case where the current git HEAD matches the latest release tag, the version reported by Flamenco was something like `3.0-beta2-3.0-beta2`, where the first is `$VERSION` and the other is `$GITHASH`. This is now prevented, and `$GITHASH` will always be something that's not a repeat of `$VERSION`. --- Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e42b0a2e..c769387e 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,18 @@ PKG := git.blender.org/flamenco VERSION := 3.0-beta2 RELEASE_CYCLE := beta -GITHASH := $(subst v${VERSION}-,,$(shell git describe --dirty --always)) +# _GIT_DESCRIPTION_OR_TAG is either something like '16-123abc' (when we're 16 +# commits since the last tag) or it's something like `v3.0-beta2` (when exactly +# on a tagged version). +_GIT_DESCRIPTION_OR_TAG := $(subst v${VERSION}-,,$(shell git describe --dirty --always)) +# In the above cases, GITHASH is either `16-123abc` (in the same case above) or +# `123abc` (when the tag matches the current commit exactly) or `dirty` (when +# the tag matches the current commit exactly, and there are subsequent +# uncommitted changes). This is done to prevent repetition of the same tag +# in the "extended version" of Flamenco, which combines ${VERSION} and +# ${GITHASH}. +GITHASH := $(subst v${VERSION},$(shell git rev-parse --short HEAD),${_GIT_DESCRIPTION_OR_TAG}) + LDFLAGS := -X ${PKG}/internal/appinfo.ApplicationVersion=${VERSION} \ -X ${PKG}/internal/appinfo.ApplicationGitHash=${GITHASH} \ -X ${PKG}/internal/appinfo.ReleaseCycle=${RELEASE_CYCLE}