2 # SPDX-License-Identifier: LGPL-2.1-or-later
11 if [ -n "${version_tag}" ]; then
12 # If -Dversion_tag= was used, just use that without further changes.
15 # Check that we have either .git/ (a normal clone) or a .git file (a work-tree)
16 # and that we don't get confused if a tarball is extracted in a higher-level
19 # If the working tree has no tags (CI builds), the first git-describe will fail
20 # and we fall back to project_version-commitid instead.
23 if [ -e "${dir}/.git" ]; then
24 c
="$(git -C "$dir" describe --abbrev=7 --dirty=^ 2>/dev/null)"
26 # This call might still fail with permission issues
27 suffix
="$(git -C "$dir" describe --always --abbrev=7 --dirty=^ 2>/dev/null)"
28 [ -n "$suffix" ] && c
="${fallback}-${suffix}"
31 [ -z "$c" ] && c
="${fallback}"
32 echo "$c" |
sed 's/^v//; s/-rc/~rc/'