From 65628a15346996b32c689d0275bfd4a5c4bec0a2 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 11 May 2020 12:47:18 +0200 Subject: Update fetch action to support commit hashes This sadly goes at the cost of a lot of the optimization that went into the original solution. This makes it slower and more bandwidth heavy, but at least it seems to work in more cases. --- lib/actions/fetch.bash | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'lib/actions') diff --git a/lib/actions/fetch.bash b/lib/actions/fetch.bash index 8af563f..ec65aaa 100644 --- a/lib/actions/fetch.bash +++ b/lib/actions/fetch.bash @@ -70,10 +70,23 @@ download_module_git() { fi notice "Cloning $url@$ref to $destination" - git clone -b "$ref" "$url" --depth=1 --single-branch "$destination" \ - > /dev/null 2>&1 - rm -fr -- "$destination/.git" + mkdir -p -- "$destination" + pushd -- "$destination" > /dev/null + + git init > /dev/null + git remote add origin "$url" 2> /dev/null + git fetch origin -a 2> /dev/null + + # Try to use the ref (branch or tag) + if ! git reset --hard "origin/$ref" 2>&1 > /dev/null + then + # Or the commit hash + git reset --hard "$(git log -1 --format=format:"%H" "$ref")" + fi + + rm -fr -- .git + popd -- "$destination" > /dev/null } download_module_http() { -- cgit v1.1