Closed scothis closed 1 year ago
I believe this to be an optimization that is compatible with existing usage patterns, but I'm not an expert in all the ways git repos are consumed with vendir.
Using vendir 0.33.1 fetching a branch took 93 seconds. With this change, syncing the same content took 17 seconds.
LGTM! Makes a lot of sense. I can't see a reason this would be a breaking change.... By specifying a branch / tag, you are effectively only ever going to checkout that code anyways. I guess it's possible someone is relying on the fact we are pulling down all the branches locally. But it's not really the intended outcome from specifying a tag. At least I as a user wouldn't expect to rely on this behaviour...
@neil-hickey what are the next steps?
@scothis did you tested your changes with ref:
@kumaritanushree ~good catch, it works with branches but not tags. I'll keep digging to find a way the makes both happy.~
edit: I had misconfigured my vendir.yml for a tag, I tried again and the same vendir.yml works with git branches, tags, and commits with both vendir 0.32.2 and this PR. All of the tags and branches are still fetched for tags and commits. It doesn't take advantage of the optimized flow that exists for branches, but it still works.
@scothis I verified your changes as well and my doubt was do we want same functionality for tag and commit or not?
@kumaritanushree sorry for the confusion. It's possible to efficiently clone tags and branches using git clone -b <branchname | tagname> --depth 1 <repository>
, but this will fail when the ref is a commit digest. We could try to sniff a commit based on the length of the ref, but it won't be perfect.
Just want to say I really want this changes so bad. Thx @scothis for improving this. When can this be merged? Cheers.
When a git ref is specified, it's not necessary to pull refs for every tag and branch in the repo. For large repos with lots of branch and tags this change can result in a multiple orders of magnitude speed up.