Speed up cloning by using a depth of 1 if there is no refspec#420
Speed up cloning by using a depth of 1 if there is no refspec#420betatim merged 2 commits intojupyterhub:masterfrom
Conversation
To speed up cloning a repository, a shallow clone containing just the last commit can be made, but *only* if no refspec is provided.
|
I'm aware of #120 and #131 , but as far as I can tell, the issue there was that the shallow clone was performed for cases where the refspec was either empty or given. Here, the shallow clone is only made when there is no refspec. Potentially, the same shallow cloning can be used for a branch of tag (but not for a specific commit), but this can't work with the current implementation: the refspec is parsed once the repository is cloned, and could be a branch, tag or commit. It would require a separate option to specify a branch or tag to allow shallow clones for those cases, but this would complicate the user interface. |
|
It would be great to add this feature back in! I think as is this PR won't speed up BinderHubs as they always specify a One question for my git education: if there are two branches in a remote git repository: Could you add some tests of the shallow/not shallow cloning based around a repo like https://github.com/betatim/repo2docker-ci-clone-depth so that this behaviour keeps working also in the future? Once we are actively using https://github.com/betatim/repo2docker-ci-clone-depth we should move it to https://github.com/binderhub-ci-repos (or similar org). |
|
Git will use
If I try for a test repository, I indeed get It's probably for the better that an explicit refspec is used (I assume the default is I'll try and add some tests in one of the next days. |
|
This is the code that we use to look up explicit SHAs. This is the code used to run Looking forward to some tests and thanks for explaining something new about git to me! |
|
LGTM. I moved the "clone depth test repo" to https://github.com/binderhub-ci-repos/repo2docker-ci-clone-depth. I think we should merge this after updating that link in the test. What do you think? |
Adds test for the use of a clone depth of 1 for cases where no refspec is used. This relies on an external source (an existing test repository), so may break easier.
b82b268 to
67cf0e6
Compare
|
Thanks! |
Speed up cloning by using a depth of 1 if there is no refspec
To speed up cloning a repository, a shallow clone containing just the
last commit can be made, but only if no refspec is provided.