File: extra-version-git.sh

package info (click to toggle)
lttng-modules 2.14.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,808 kB
  • sloc: ansic: 74,851; sh: 548; makefile: 62
file content (21 lines) | stat: -rwxr-xr-x 717 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
# SPDX-FileCopyrightText: 2018-2019 EfficiOS Inc.

# 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 2> /dev/null)"
	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}"