Commit | Line | Data |
---|---|---|
101215b7 MJ |
1 | #!/bin/sh |
2 | # SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) | |
3 | ||
4 | # First argument is the path to the lttng modules sources. | |
5 | TOP_LTTNG_MODULES_DIR="$1" | |
6 | ||
7 | GIT_VERSION="0" | |
8 | ||
9 | if test -x "$(which git 2>&1;true)" && test -r "${TOP_LTTNG_MODULES_DIR}/.git"; then | |
5716babb | 10 | GIT_VERSION_STR="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --dirty 2> /dev/null)" |
101215b7 MJ |
11 | GIT_CURRENT_TAG="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --exact-match --match="v[0-9]*" HEAD 2> /dev/null)" |
12 | ||
13 | GIT_VERSION="${GIT_VERSION_STR}" | |
14 | ||
15 | if ! echo "${GIT_VERSION_STR}" | grep -- "-dirty" >/dev/null && test "x$GIT_CURRENT_TAG" != "x"; then | |
16 | GIT_VERSION="0" | |
17 | fi | |
18 | fi | |
19 | ||
20 | echo "${GIT_VERSION}" |