Bail out of update-version script when commit hash already matches

epel8
Benjamin A. Beasley 4 years ago
parent df5ad5fa2d
commit 970981741d

@ -33,6 +33,27 @@ fi
SRCDIR="$(cd "$(dirname "$0")"; pwd)" SRCDIR="$(cd "$(dirname "$0")"; pwd)"
SPEC="${SRCDIR}/gn.spec" SPEC="${SRCDIR}/gn.spec"
SPEC_COMMIT="$(
awk '/^%global[[:blank:]]+commit[[:blank:]]+[[:xdigit:]]{40}[[:blank:]]*$/ {
print $3; exit
}' "${SPEC}"
)"
check_equal_commits() {
if [ "${1}" = "${SPEC_COMMIT}" ]
then
cat 1>&2 <<EOF
Spec file is already up to date at ${SPEC_COMMIT}.
EOF
exit
fi
}
if echo "${COMMIT}" | grep -E '^[[:xdigit:]]{40}$' >/dev/null
then
check_equal_commits "${COMMIT}"
fi
tmpd="$(mktemp -d)" tmpd="$(mktemp -d)"
trap "rm -rf '${tmpd}'" INT TERM EXIT trap "rm -rf '${tmpd}'" INT TERM EXIT
@ -42,6 +63,7 @@ cd gn
if ! echo "${COMMIT}" | grep -E '^[[:xdigit:]]{40}$' >/dev/null if ! echo "${COMMIT}" | grep -E '^[[:xdigit:]]{40}$' >/dev/null
then then
COMMIT="$(git rev-parse "${COMMIT}")" COMMIT="$(git rev-parse "${COMMIT}")"
check_equal_commits "${COMMIT}"
fi fi
git checkout "${COMMIT}" git checkout "${COMMIT}"
python3 './build/gen.py' python3 './build/gen.py'

Loading…
Cancel
Save