-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gitPullOrClone - shallow cloning only for GitHub repos #2678
Comments
To obtain all unique remote http(s) repos used by
To obtain non-http(s) repos such as variables usage:
All the results use GitHub repositories, so there is no problem. Testing shallow-cloning support of the results:
Conclusion: only |
I think I'd still prefer a whitelist. Means we don't have to worry if we add another repo that doesn't support shallow clones. Or - can we just default to shallow and catch the return code if it fails? |
Yeah I think we should actually try depth 1 then if it errors do a full clone. What do you think? |
Return code is 128 which isn't too helpful as it returns this for other issues afair. String matching is ok so long as this error message isn't localised. We could just try again without depth on first error I guess. |
Sorry for spam. I did some code for this but it feels messy with the additional logic. So my vote is for a whitelist again :-) |
This was my quick test diff --git a/scriptmodules/helpers.sh b/scriptmodules/helpers.sh
index 38e5c840..15cdd150 100644
--- a/scriptmodules/helpers.sh
+++ b/scriptmodules/helpers.sh
@@ -355,6 +355,8 @@ function gitPullOrClone() {
local branch="$3"
[[ -z "$branch" ]] && branch="master"
local commit="$4"
+ local depth="$5"
+ [[ -z "$depth" && "$__persistent_repos" -ne 1 && -z "$commit" ]] && depth=1
if [[ -d "$dir/.git" ]]; then
pushd "$dir" > /dev/null
@@ -364,12 +366,17 @@ function gitPullOrClone() {
popd > /dev/null
else
local git="git clone --recursive"
- if [[ "$__persistent_repos" -ne 1 && "$repo" == *github* && -z "$commit" ]]; then
- git+=" --depth 1"
+ if [[ "$depth" -ne -1 ]]; then
+ git+==" --depth $depth"
fi
git+=" --branch $branch"
printMsgs "console" "$git \"$repo\" \"$dir\""
- runCmd $git "$repo" "$dir"
+ if ! runCmd $git $depth_param "$repo" "$dir"; then
+ if [[ "$depth" -ne -1 ]]; then
+ unset md_ret_errors[${#md_ret_errors[@]}-1]
+ gitPullOrClone "$1" "$2" "$3" "$4" -1
+ fi
+ fi
fi
if [[ -n "$commit" ]]; then |
Simplified code by making it recursive. Doesn't seem too bad but I don't like the idea of calling git twice for other errors. |
Yes I also thought at some point to make logic to auto-detect if shallow-cloning didn't work, but like you I also concluded that it gets more messy for no real reason. However after looking at your quick test code, I got thinking that is not a bad idea to actually have an optional parameter to Then, for these hostings that we know don't support shallow-cloning, we explicitly pass
In the future, when developing scriptmodules, if anyone gets an error because of shallow-cloning we just need to disable it via this extra optional argument. What do you think? Otherwise, yes we can just go with the current whitelist. In this case I think github and gitlab are by far the most used hosts so I would just add gitlab to the whitelist. |
…ow cloning - RetroPie#2678 * use a depth of 0 for xroar to do a full depth clone as the repository doesn't support shallow cloning
helpers / gitPullOrClone - add a depth parameter and default to shallow cloning - #2678
Closing after fix from #2840 . Thanks! |
Hi @joolswills ,
I noticed that
gitPullOrClone
limits the usage of shallow-cloning, e.g. passing--depth 1
, to GitHub repositories only. I went to collect all the calls to this function to find out what other repository services are being used by the scriptmodules and I found (via testing) that in addition to GitHub, also GitLab and BitBucket repos support shallow cloning correctly.Maybe these could be added too to the whitelist for passing
--depth 1
here?RetroPie-Setup/scriptmodules/helpers.sh
Lines 363 to 365 in 307db2d
It should be a simple change, therefore I'm just filing an issue here. If you don't have time but agree on adding these, I can make a PR too. Just let me know. Thanks!
The text was updated successfully, but these errors were encountered: