summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2022-02-18 09:24:23 -0500
committerRay Strode <rstrode@redhat.com>2022-02-19 18:17:57 -0500
commit181914504db9f40d1b737095d5a1aeda8c896a1e (patch)
tree006c3ef397c2ba77e10940121ae5036389bf60a9
parent9b773f11b537dd236ef4bd1f5a7658f9898c6efd (diff)
meson: Fix up version generation heursitics22.07.5
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
-rwxr-xr-xgenerate-version.sh9
1 files 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"