Skip to content

Expose additional args when calling Git.clone() - #11921

Merged
jcar87 merged 2 commits into
conan-io:developfrom
jcar87:feature/git-clone-with-args
Aug 22, 2022
Merged

jcar87 merged 2 commits into
conan-io:developfrom
jcar87:feature/git-clone-with-args

Conversation

@jcar87

@jcar87 jcar87 commented Aug 19, 2022

Copy link
Copy Markdown
Contributor

Changelog: Feature: Add ability to pass additional arguments to conan.tools.scm.Git.clone().
Docs: conan-io/docs#2721

As a way of addressing: #11797

This PR exposes an args parameter when calling Git.clone(), so that we can forward additional parameters to the git command - thus enabling more advanced behaviours than cloning the default branch.

This can satisfy the issue in #11797 (by passing e.g. by passing ['--depth', '1']). I believe the most common case when building recipes that clone from a git repository is to want to have it set to a specific commit (branch or tag). Some repositories take considerable time to clone, so the ability to tweak the git clone wall to make it as quick as possible seems like a good feature to have.

I'm unsure as to whether to expose a specific parameter for a shallow clone, what should it be called? tools.Git() had a shallow=True/False, but other git wrappers for Python have a specific depth argument, which may match more closely. And if we were to do that, why not others that also control likely toggles, like the submodule recursive (or not) clone behaviour. Exposing an args argument could be a good compromise to cover these cases.

@jcar87
jcar87 requested review from lasote and memsharded August 19, 2022 14:37

@memsharded memsharded left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree a generic args is fine, no need to do specific python interface for shallow or others.
I think this can go to 1.52, very low risk, and useful to have.

Comment thread conan/tools/scm/git.py Outdated
@memsharded memsharded added this to the 1.52 milestone Aug 20, 2022
Co-authored-by: James <james@conan.io>
@memsharded
memsharded requested a review from czoido August 22, 2022 08:21
@jcar87
jcar87 marked this pull request as ready for review August 22, 2022 10:04
@jcar87
jcar87 merged commit 84cadfc into conan-io:develop Aug 22, 2022
@jcar87
jcar87 deleted the feature/git-clone-with-args branch August 22, 2022 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants