From cabc1cac08cb41777caa5674a1fd229d1e89bceb Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Fri, 17 Nov 2023 10:14:35 +0100 Subject: [PATCH] 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 Acked-by: Adrien 'neox' Bourmault --- website-build/build.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/website-build/build.sh b/website-build/build.sh index f018409..89a6902 100755 --- a/website-build/build.sh +++ b/website-build/build.sh @@ -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 - git -C "${dst_path}" fetch origin - git -C "${dst_path}" checkout "${src_revision}" + + if [ "${localrev}" != "${src_revision}" ] ; then + git -C "${dst_path}" fetch origin + git -C "${dst_path}" checkout "${src_revision}" + fi else rm -rf "${dst_path}"