kubo/mk/git.mk
Marcin Rataj bbefaea82e fix(version): produce shorter user agent for tagged release builds
when building from a version-tagged commit with a clean tree, omit the
redundant git commit hash from the libp2p user agent string, saving
bytes in HTTP requests and libp2p identify. `ipfs version --commit`
still reports the full commit hash.

before (tagged release): kubo/0.37.0/6898472
after  (tagged release): kubo/0.37.0

non-tagged and dirty builds are unaffected.
2026-02-19 01:31:03 +01:00

13 lines
621 B
Makefile

# First try to "describe" the state. This tells us if the state is dirty.
# If that fails (e.g., we're building a docker image and have an empty objects
# directory), assume the source isn't dirty and build anyways.
git-hash:=$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
# Detect if HEAD is a clean, tagged release. Used to omit redundant commit
# hash from the libp2p user agent (the version number suffices).
ifeq ($(findstring dirty,$(git-hash)),)
git-tag:=$(shell git tag --points-at HEAD 2>/dev/null | grep '^v' | head -1)
else
git-tag:=
endif