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

A pub git references that specifies a specific ref does an entire git clone #2686

Closed
dnfield opened this issue Oct 15, 2020 · 5 comments
Closed
Labels
type-enhancement A request for a change that isn't a bug

Comments

@dnfield
Copy link
Contributor

dnfield commented Oct 15, 2020

e.g. the following:

dependencies:
  vm_service:
    git:
      url: https://dart.googlesource.com/sdk
      ref: refs/changes/80/156980/3
      path: pkg/vm_service

ends up doing:

[  +34 ms] IO  : Spawning "git --version" in /Users/dnfield/src/flutter/plugins/packages/integration_test/.
[  +17 ms] IO  : Finished git. Exit code 0.
[        ]     | stdout:
[        ]     | | git version 2.18.0
[        ]     | Nothing output on stderr.
[        ] FINE: Determined git command git.
[   +1 ms] IO  : Spawning "git rev-parse --is-inside-git-dir" in /Users/dnfield/.pub-cache/git/cache/sdk-40ed25bf474d78ecf3880eb744f1165252eb170d
[  +34 ms] IO  : Finished git. Exit code 128.
[        ]     | Nothing output on stdout.
[        ]     | stderr:
[        ]     | | fatal: not a git repository (or any of the parent directories): .git
[   +4 ms] IO  : Deleting directory /Users/dnfield/.pub-cache/git/cache/sdk-40ed25bf474d78ecf3880eb744f1165252eb170d.
[   +4 ms] IO  : Spawning "git clone --mirror https://dart.googlesource.com/sdk /Users/dnfield/.pub-cache/git/cache/sdk-40ed25bf474d78ecf3880eb744f1165252eb170d" in /Users/dnfield/src/flutter/plugins/packages/integration_test/.

Which goes on to fetch the entire history of a very large repository when all I'll really need is a specific ref. As of this writing, it results in cloning multiple gigabytes of data into my .pub-cache which I will have to manually clean up, and takes over a minute to complete.

This would be multitudes more efficient if it did something like:

final sdkDir = createSdkCacheDir();
runProcess('git init .', workingDirectory: sdkDir);
runProcess('git remote add upstream https://dart.gogolesource.com/sdk', workingDirectory: sdkDir);
runProcess('git fetch upstream $ref', workingDirectory: sdkDir);
runProcess('git checkout FETCH_HEAD', workingDirectory: sdkDir); // or git checkout $ref is fine too

It should be faster.

@sigurdm
Copy link
Contributor

sigurdm commented Oct 19, 2020

Checking out a single ref would also get the entire history leading to that ref (as I understand it).

I think what we should be using is a shallow clone: https://linuxhint.com/git-shallow-clone-and-clone-depth/ .

I wonder if it has any downsides (will it be more expensive to change the ref?) @jonasfj WDYT?

@sigurdm sigurdm added the type-enhancement A request for a change that isn't a bug label Oct 22, 2020
@jonasfj
Copy link
Member

jonasfj commented Oct 27, 2020

I think this is nice to have.. we already do some caching, so the second time you use the same repo, it's not cloned again.

@mralbertchen
Copy link

I think shallow clone is the way to go for this. At my company we are currently combining unity with flutter through https://pub.dev/packages/flutter_unity_widget and we host the unity widget dependency on a git repo. It gets big really quickly and we have to keep deleting tags. Can someone point out where this logic is currently done? Happy to take a stab at it and submit a PR.

@2shrestha22
Copy link

Any update on this?

@sigurdm
Copy link
Contributor

sigurdm commented Jun 9, 2023

closing this in favor of #3556

@sigurdm sigurdm closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants