diff --git a/fix-version-output.patch b/fix-version-output.patch new file mode 100644 index 0000000..ff2a4ee --- /dev/null +++ b/fix-version-output.patch @@ -0,0 +1,38 @@ +From 1db8e2a9c58b9b1630cd7af47d6f11a8b6cb756a Mon Sep 17 00:00:00 2001 +From: Jonathan Wright +Date: Mon, 29 Apr 2024 13:06:37 -0500 +Subject: [PATCH] return version even if not using git sources + +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. +--- + scripts/version | 17 +++++++++++------ + 1 file changed, 11 insertions(+), 6 deletions(-) + +diff --git a/scripts/version b/scripts/version +index ba59e6b6aa..d9204cd1be 100755 +--- a/scripts/version ++++ b/scripts/version +@@ -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 diff --git a/jq.spec b/jq.spec index 6449084..80a34ee 100644 --- a/jq.spec +++ b/jq.spec @@ -23,6 +23,9 @@ BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool +# https://github.com/jqlang/jq/pull/3099 +# fixes jq --version +Patch: fix-version-output.patch %description lightweight and flexible command-line JSON processor