Fix version scripts for some shallow clone situations (fix #1549) (#2608)

This commit is contained in:
itchyny authored and GitHub committed 2023-06-14 07:33:25 +09:00
1 parent 5cebe86a7b
commit 433b79dddf
2 files changed
+9 -11

No files matched your search

+8 -7
View File
@@ -1,10 +1,11 @@
#!/bin/sh
set -e
cd `dirname "$0"`
if git rev-parse --verify -q jq-1.0 > /dev/null 2>&1; then
git describe --tags --match 'jq-*' --dirty | sed 's/^jq-//'
set -eu
cd "$(dirname "$0")"
if git describe --tags --match 'jq-*' >/dev/null 2>&1; then
git describe --tags --match 'jq-*' --dirty | sed 's/^jq-//'
else
b=`git rev-parse --abbrev-ref HEAD`
c=`git describe --always --dirty`
echo "${b}-${c}"
branch=$(git rev-parse --abbrev-ref HEAD)
commit=$(git describe --always --dirty)
echo "${branch}-${commit}"
fi