sifive / wit

Workspace Integration Tool
Apache License 2.0
23 stars 13 forks source link

Add environment variable for git clone --reference #218

Closed mmjconolly closed 4 years ago

mmjconolly commented 4 years ago

Point at another workspace as a seed, to speed up wit init, especially on slower networks. Not all the required repositories have to be in the seed workspace.

Example usage

$ export WIT_WORKSPACE_REFERENCE=$HOME/other-workspace
$ wit init new-workspace -a git@github.com:acme/foo

I'm not sure that an environment variable is the best way to go here, but it looked like there were a lot of paths to follow if we were to thread the variable through from main. Let me know if you think I should do it a different way.

The commit message:

git clone's --reference[-if-able] option uses a local checkout of a
repository to seed the objects that would be fetched during a clone.
On the same filesystem this will result in hardlinks, and across
filesystems it uses symlinks. Using symlinks is an issue if the original
repository is removed, it will break the second repository.
To ensure the operation is safe, '--dissociate' is added to git clone
to instead copy the objects. This is likely still faster than network.

The environment varible is WIT_WORKSPACE_REFERENCE which should be a
directory containing repositories you would like to use as a seed,
such as another wit workspace.
Any repositories that are missing are cloned from the network as before.
mmjconolly commented 4 years ago

On a large workspace on my home network, it's cuts the time in half

mmjconolly commented 4 years ago

Added emulation of the if-able portion of --reference-if-able

jackkoenig commented 4 years ago

Also nice documentation, thanks :)

One thought is maybe this variable should be mentioned in --help somehow; perhaps a longer description like the one you did for the foreach command (https://github.com/sifive/wit/blob/master/lib/wit/parser.py#L104) but for the top-level parser?