website-build: avoid unnecessary git fetch

When we already have the right untitled revision checked out, we don't
need to try to fetch its revision again. This also enable offline
builds in that case.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Acked-by: Adrien 'neox' Bourmault <neox@gnu.org>
This commit is contained in:
Denis 'GNUtoo' Carikli 2023-11-17 10:14:35 +01:00 committed by Adrien 'neox' Bourmault
parent e3de822f48
commit cabc1cac08
Signed by: neox
GPG Key ID: 2974E1D5F25DFCC8
1 changed files with 7 additions and 2 deletions

View File

@ -51,12 +51,17 @@ sync_repo()
git -C "${dst_path}" checkout "${src_revision}"
fi
elif [ -z "${src_path}" ] ; then
localrev="$(git --no-pager log --oneline HEAD -1 --format='%H')"
git -C "${dst_path}" remote get-url origin || \
git -C "${dst_path}" remote add origin "${src_uri}"
git -C "${dst_path}" remote set-url origin "${src_uri}"
git -C "${dst_path}" clean -dfx
if [ "${localrev}" != "${src_revision}" ] ; then
git -C "${dst_path}" fetch origin
git -C "${dst_path}" checkout "${src_revision}"
fi
else
rm -rf "${dst_path}"