diff options
author | itchyny <itchyny@cybozu.co.jp> | 2023-06-14 07:33:25 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-14 07:33:25 +0900 |
commit | 433b79dddf81554ff6e542a6b93f116fe68885b5 (patch) | |
tree | cc9899d997327dd97e0af466805769da9dd49ab7 | |
parent | 5cebe86a7b90e5718077c5e1d5c2165939d3f3cb (diff) |
Fix version scripts for some shallow clone situations (fix #1549) (#2608)
-rw-r--r-- | configure.ac | 5 | ||||
-rwxr-xr-x | scripts/version | 15 |
2 files changed, 9 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac index 73a73de7..78383a6d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,4 @@ -m4_define([jq_version], - m4_esyscmd_s([(git rev-parse --verify -q jq-1.0 > /dev/null && - (git describe --tags --dirty --match 'jq-*'|sed 's/^jq-//')) || - echo `git rev-parse --abbrev-ref HEAD`-`git describe --always --dirty`]))) +m4_define([jq_version], m4_esyscmd_s([scripts/version]))) AC_INIT([jq], [jq_version], [https://github.com/jqlang/jq/issues], [jq], [https://jqlang.github.io/jq]) diff --git a/scripts/version b/scripts/version index 0e8094c2..d56dd9a7 100755 --- a/scripts/version +++ b/scripts/version @@ -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 |