master
mk 21 lines 1 KB
Raw
1 # First try to "describe" the state. This tells us if the state is dirty.
2 # If that fails (e.g., we're building a docker image and have an empty objects
3 # directory), assume the source isn't dirty and build anyways.
4 git-hash:=$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
5
6 # Detect if HEAD is a clean, tagged release. Used to omit redundant commit
7 # hash from the libp2p user agent (the version number suffices).
8 ifeq ($(findstring dirty,$(git-hash)),)
9 git-tag:=$(shell git tag --points-at HEAD 2>/dev/null | grep '^v' | head -1)
10 else
11 git-tag:=
12 endif
13
14 # Normalize `origin` to `host/org/repo` for runtime fork detection via
15 # Version.AgentSuffix. Handles ssh and https forms, strips `.git`, drops
16 # userinfo. Empty when no git, no `origin`, or git is unavailable.
17 git-origin:=$(shell git remote get-url origin 2>/dev/null \
18 | sed -E -e 's|^git@([^:]+):|\1/|' \
19 -e 's|^[a-z]+://||' \
20 -e 's|^[^/]+@||' \
21 -e 's|\.git$$||')