Skip to content
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

Let shallow clone work with any ref #266

Merged
merged 4 commits into from
Oct 4, 2021

Conversation

zachwhaley
Copy link
Contributor

@zachwhaley zachwhaley commented Aug 28, 2020

Currently the shallow clone only works if ref is either not set, or set
to the default branch. This is becuase go-getter does not set the ref
to checkout during a shallow clone so Git assumes the default branch,
and then when go-getter tries to checkout a ref other than the default
branch it fails because the shallow clone did not fetch that ref.

To fix this, I have used --branch to explicitly set the ref to fetch
during a clone so that when a shallow clone is done go-getter will clone
the ref given and not the default branch. This will also make clones of
non-default branches just a tad bit more optimized since the clone will
not waste time checking out a branch it ultimately will not use.

Fixes hashicorp/terraform#10703

Currently the shallow clone only works if ref is either not set, or set
to the default branch.  This is becuase go-getter does not set the ref
to checkout during a shallow clone so Git assumes the default branch,
and then when go-getter tries to checkout a ref other than the default
branch it fails because the shallow clone did not fetch that ref.

To fix this, I have used `--branch` to explicitly set the ref to fetch
during a clone so that when a shallow clone is done go-getter will clone
the ref given and not the default branch.  This will also make clones of
non-default branches just a tad bit more optimized since the clone will
not waste time checking out a branch it ultimately will not use.
@zachwhaley
Copy link
Contributor Author

I was not able to get the tests to run locally and I couldn't seem to find any documentation to explain this. Also, I'm not sure if I was supposed to open a PR here or in terraform.

Please advise :)

@zachwhaley
Copy link
Contributor Author

Hello?

@zachwhaley
Copy link
Contributor Author

I see that a similar PR was opened 9 months ago to address the same thing #251

Is this repo abandoned?

@zachwhaley
Copy link
Contributor Author

Hello?

@sebglon
Copy link

sebglon commented Mar 15, 2021

@schmichael or @apparentlymart can we have your helm on this PR?
This is a big locket on many project

@simoncaron
Copy link

@azr Any chance you could take a few minutes to look at this? It would be really great if we could close this issue which has been ongoing for more than a year. Thanks!

@schmichael schmichael merged commit 0821303 into hashicorp:main Oct 4, 2021
@zachwhaley zachwhaley deleted the shallow-tag-clone branch October 4, 2021 23:08
@schmichael
Copy link
Member

Sorry for the delay everyone and thanks for the contribution. Unfortunately you'll still have to wait for dependent projects (Nomad, Terraform, etc) to update their go-getter dependency.

@tomqwpl
Copy link

tomqwpl commented Nov 24, 2021

On the face of it, the fix for this has changed the behaviour with regard to the "ref" parameter when getting from git. Previously it allowed any ref, so commit hash etc. Now it only allows branch names or tag names. My guess is that this is an unintended side effect of the change?
Doing "git clone; git checkout " (which is what happened before) isn't the same as doing "git clone --branch ; git checkout " (which is what happens now), since the "git clone --branch " bit only works for branch names or tag names.

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.

Sourcing module with git by cloning in shallow mode
5 participants