From 8642d0e9aa7652b78e9b8053325297e1eb9f1fe8 Mon Sep 17 00:00:00 2001 From: Bart Van Bos Date: Sun, 8 Nov 2026 09:05:32 +0100 Subject: [PATCH] fix(make): mark the commit -dirty for uncommitted changes make build injected the bare HEAD SHA, so a build from a tree with changes reported a clean-looking commit, while go build marks it -dirty. The Makefile now appends -dirty on the same test Go uses for vcs.modified (git status --porcelain). Release builds are unchanged: the release workflow sets COMMIT itself. Co-Authored-By: Claude Opus 5.5 --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bb97740..0a62b61 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,10 @@ BIN_DIR := bin # they stay empty and the binary reports dev. COMMIT is the full SHA. TAG ?= $(shell git describe --tags --exact-match 2>/dev/null) VERSION ?= $(patsubst v%,%,$(TAG)) -COMMIT := $(shell git rev-parse HEAD 2>/dev/null) +# -dirty when the working tree has changes, as Go itself marks vcs.modified +# (git status --porcelain, untracked files included); empty outside git. +DIRTY := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] || echo -dirty) +COMMIT := $(shell git rev-parse HEAD 2>/dev/null)$(DIRTY) BUILD_DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -s -w -X main.version=$(VERSION) -X main.tag=$(TAG) -X main.commit=$(COMMIT) -X main.date=$(BUILD_DATE)