Skip to content

Commit

Permalink
return version even if not using git sources
Browse files Browse the repository at this point in the history
Downloading the source tarball from GitHub lacks .git structure and the version will be blank.  This fixes it by using the directory name which contains the version.
  • Loading branch information
jonathanspw authored Apr 29, 2024
1 parent e4d0b12 commit 1db8e2a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
set -eu

cd "$(dirname "$0")/../"
test -d .git || exit 1

if git describe --tags --match 'jq-*' >/dev/null 2>&1; then
git describe --tags --match 'jq-*' --dirty | sed 's/^jq-//'
if test -d .git; then
if git describe --tags --match 'jq-*' >/dev/null 2>&1; then
git describe --tags --match 'jq-*' --dirty | sed 's/^jq-//'
else
branch=$(git rev-parse --abbrev-ref HEAD)
commit=$(git describe --always --dirty)
echo "${branch}-${commit}"
fi
elif [[ "$(basename $(pwd))" =~ ^jq-jq-([0-9]+\.[0-9]+(\.[0-9]+)?)$ ]]; then
echo ${BASH_REMATCH[1]}
else
branch=$(git rev-parse --abbrev-ref HEAD)
commit=$(git describe --always --dirty)
echo "${branch}-${commit}"
exit 1
fi

0 comments on commit 1db8e2a

Please sign in to comment.