X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=scripts%2Fextra-version-git.sh;fp=scripts%2Fextra-version-git.sh;h=e5a3e176699d59d956d550318ff0bf97adfa27d6;hb=6c27a5ccba05b088fbfcf8cd982c25649838298d;hp=0000000000000000000000000000000000000000;hpb=1c124020c743254923d8e76ab5dcd1f69709982e;p=lttng-modules.git diff --git a/scripts/extra-version-git.sh b/scripts/extra-version-git.sh new file mode 100755 index 00000000..e5a3e176 --- /dev/null +++ b/scripts/extra-version-git.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the lttng modules sources. +TOP_LTTNG_MODULES_DIR="$1" + +GIT_VERSION="0" + +if test -x "$(which git 2>&1;true)" && test -r "${TOP_LTTNG_MODULES_DIR}/.git"; then + GIT_VERSION_STR="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --dirty)" + GIT_CURRENT_TAG="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --exact-match --match="v[0-9]*" HEAD 2> /dev/null)" + + GIT_VERSION="${GIT_VERSION_STR}" + + if ! echo "${GIT_VERSION_STR}" | grep -- "-dirty" >/dev/null && test "x$GIT_CURRENT_TAG" != "x"; then + GIT_VERSION="0" + fi +fi + +echo "${GIT_VERSION}"