From 181914504db9f40d1b737095d5a1aeda8c896a1e Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 18 Feb 2022 09:24:23 -0500 Subject: meson: Fix up version generation heursitics They were all broken before for the tarball case and I didn't notice because I was checking the tarball in a subdirectory of the git repo so it was just exercising the git path. This commit makes one more attempt at fixing the issue, and also provides some protection against users that does shallow clones. https://gitlab.freedesktop.org/accountsservice/accountsservice/-/issues/99 --- generate-version.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/generate-version.sh b/generate-version.sh index c2ccef7..0eb492d 100755 --- a/generate-version.sh +++ b/generate-version.sh @@ -1,8 +1,13 @@ #!/bin/sh +exec 3>&2 2> /dev/null +CWD=$(realpath "$PWD") +TOPLEVEL_WORKING_DIR=$(realpath "$(git rev-parse --show-toplevel)") +exec 2>&3 + # If it's not from a git checkout, assume it's from a tarball -if [ "$(git rev-parse c5339c5779a67330afbb9406135a7148922478ae)" != "c5339c5779a67330afbb9406135a7148922478ae" ]; then - VERSION_FROM_DIR_NAME=$(dirname $PWD/.. | sed -n 's/^accountsservice-\([^-]*\)$/\1/p') +if [ "$TOPLEVEL_WORKING_DIR" != "$CWD" ]; then + VERSION_FROM_DIR_NAME=$(basename "$CWD" | sed -n 's/^accountsservice-\([^-]*\)$/\1/p') if [ -n "$VERSION_FROM_DIR_NAME" ]; then echo "$VERSION_FROM_DIR_NAME" -- cgit v1.2.3