aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-05-11 12:47:18 +0200
committerPatrick Spek <p.spek@tyil.nl>2020-11-20 20:42:29 +0100
commit65628a15346996b32c689d0275bfd4a5c4bec0a2 (patch)
treec3ccd745b9d12099dc637e626822eff2f7e9d5a0 /lib
parent8ed93ac07fbcd8b96090b0f3bd48122d3464cd5c (diff)
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/actions/fetch.bash19
1 files changed, 16 insertions, 3 deletions
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() {