From 0ef17277de8eaf79b445f26f9ad131eef33b45a6 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Wed, 11 Oct 2023 14:12:08 +0200 Subject: [PATCH] website-build: Enable to use specific revisions for git repositories. This for instance enable users to manually override the revisions to test branches of git repositories. Signed-off-by: Denis 'GNUtoo' Carikli Acked-by: Adrien 'neox' Bourmault --- website-build/build.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/website-build/build.sh b/website-build/build.sh index 1d13245..706cbed 100755 --- a/website-build/build.sh +++ b/website-build/build.sh @@ -52,19 +52,29 @@ sync_repo() dst_path="$1" src_uri="$2" src_path="$3" + src_revision="$4" if [ -z "${src_path}" ] && [ ! -d "${dst_path}" ] ; then git clone "${src_uri}" "${dst_path}" + git -C "${dst_path}" checkout "${src_revision}" elif [ ! -d "${dst_path}" ] ; then mkdir -p "$(dirname ${dst_path})" cp -a "${src_path}" "${dst_path}" + if [ -n "${src_revision}" ] ; then + git -C "${dst_path}" checkout "${src_revision}" + fi elif [ -z "${src_path}" ] ; then + 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}" pull --rebase else rm -rf "${dst_path}" cp -a "${src_path}" "${dst_path}" + if [ -n "${src_revision}" ] ; then + git -C "${dst_path}" checkout "${src_revision}" + fi fi }