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