Get the SHA1 when no tag is present

The 'git describe' command finds the most recent tag instead of the
SHA1. When trying to build from a repository without any tags, for
example in a fork, this causes the build to fail.

Use the '--always' option to fallback to the SHA1 in case no tag is
present.

Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
This commit is contained in:
Jef Driesen 2025-01-21 20:34:33 +01:00
parent 71ebee8ab6
commit b358c71ade
2 changed files with 2 additions and 2 deletions

View file

@ -379,7 +379,7 @@ for ARCH in $ARCHITECTURES ; do
make install
popd
CURRENT_SHA=$(cd "$SUBSURFACE_SOURCE"/libdivecomputer ; git describe)
CURRENT_SHA=$(cd "$SUBSURFACE_SOURCE"/libdivecomputer ; git describe --always --long)
PREVIOUS_SHA=$(cat "libdivecomputer-${ARCH}.SHA" 2>/dev/null || echo)
if [ ! "$CURRENT_SHA" = "$PREVIOUS_SHA" ] || [ ! -e "$PKG_CONFIG_PATH/libdivecomputer.pc" ] ; then
mkdir -p libdivecomputer-build-"$ARCH"

View file

@ -264,7 +264,7 @@ if [ "$QUICK" != "1" ] ; then
if [ ! -f "${PARENT_DIR}/libdivecomputer-build-${ARCH}/git.SHA" ] ; then
echo "" > "${PARENT_DIR}/libdivecomputer-build-${ARCH}/git.SHA"
fi
CURRENT_SHA=$(cd "${SUBSURFACE_SOURCE}/libdivecomputer" ; git describe)
CURRENT_SHA=$(cd "${SUBSURFACE_SOURCE}/libdivecomputer" ; git describe --always --long)
PREVIOUS_SHA=$(cat "${PARENT_DIR}/libdivecomputer-build-${ARCH}/git.SHA")
if [ ! "$CURRENT_SHA" = "$PREVIOUS_SHA" ] ; then
echo "$CURRENT_SHA" > "${PARENT_DIR}/libdivecomputer-build-${ARCH}/git.SHA"