]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Allow GITVERSION to be specified as an environment variable
authorMichael Brown <mcb30@ipxe.org>
Sun, 25 Jan 2026 09:30:34 +0000 (09:30 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sun, 25 Jan 2026 11:27:14 +0000 (11:27 +0000)
When using GitHub Actions with a job container that does not have the
git tools installed, the actions/checkout step will download a
snapshot instead of performing a git clone, and will therefore not
create a .git directory.  Allow the GITVERSION variable to be
specified externally, so that the test suite logs can still display
the commit of the build being tested.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/Makefile

index b93c08f9d9b2e69ebfd097a0dc6bf4058f3183de..6d7df0e2cf6c103fffe20c0580d3ace563abb0e1 100644 (file)
@@ -215,27 +215,24 @@ VERSION_MINOR     := 21
 VERSION_PATCH  := 1
 EXTRAVERSION   := +
 ifneq ($(wildcard ../.git/HEAD),)
-GITHEAD                := $(shell cat ../.git/HEAD)
-ifneq ($(firstword $(GITHEAD)),ref:)
-GITCOMMIT      := $(GITHEAD)
-else
-GITREF         := $(word 2,$(GITHEAD))
+GITVERSION     := $(shell cat ../.git/HEAD)
+ifeq ($(firstword $(GITVERSION)),ref:)
+GITREF         := $(word 2,$(GITVERSION))
 ifneq ($(wildcard ../.git/$(GITREF)),)
-GITCOMMIT      := $(shell cat ../.git/$(GITREF))
+GITVERSION     := $(shell cat ../.git/$(GITREF))
 else
-GITCOMMIT      := $(shell awk -v ref="$(GITREF)" '$$2 == ref { print $1 }' \
+GITVERSION     := $(shell awk -v ref="$(GITREF)" '$$2 == ref { print $1 }' \
                           ../.git/packed-refs)
 endif
 endif
-ifeq ($(GITCOMMIT),)
+ifeq ($(GITVERSION),)
 $(error Unable to determine git commit ID)
 endif
-GITVERSION     := g$(shell echo "$(GITCOMMIT)" | cut -c1-5)
 endif
 MM_VERSION     = $(VERSION_MAJOR).$(VERSION_MINOR)
 VERSION                = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
 ifneq ($(GITVERSION),)
-VERSION                += ($(GITVERSION))
+VERSION                += (g$(shell echo "$(GITVERSION)" | cut -c1-5))
 endif
 version :
        @$(ECHO) "$(VERSION)"