summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-07-19 13:05:11 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2024-07-22 12:04:40 +0200
commit944faf65986f36d7ed3a4ba5cb4cc763011f0f77 (patch)
tree22eed0f654453f5e433d4958c31c98909cffd0c1 /tools
parentzsh/_networkctl: remove duplicated argument for completion (#31926) (diff)
downloadsystemd-944faf65986f36d7ed3a4ba5cb4cc763011f0f77.tar.xz
systemd-944faf65986f36d7ed3a4ba5cb4cc763011f0f77.zip
Make vcs-tag do something useful for non-developer mode as well
When building packages of arbitrary commits of systemd-stable, distributors might want to include a git sha of the exact commit they're on. Let's extend vcs-tag a little to make this possible. If we're on a commit matching a tag, don't generate a git sha at all. If we're not on a commit matching a tag, generate a vcs tag as usually. However, if we're not in developer mode, don't append a '^' if the tree is dirty to accomodate package builds applying various patches to the tree which shouldn't be considered as "dirty" edits.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/vcs-tag.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/vcs-tag.sh b/tools/vcs-tag.sh
new file mode 100755
index 0000000000..5da39cc539
--- /dev/null
+++ b/tools/vcs-tag.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -e
+
+MODE="$1"
+
+if ! [[ -d .git ]] || git describe --tags --exact-match &>/dev/null; then
+ exit 0
+fi
+
+if [[ "$MODE" == "developer" ]]; then
+ DIRTY="--dirty=^"
+else
+ DIRTY=""
+fi
+
+echo "-g$(git describe --abbrev=7 --match="" --always $DIRTY)"