Skip to content

Remove VCS History

Background

Connected to: #376 (closed) Sources to only stage what is required for building, omitting large parts of VCS history

The original task required the removal of some git history from the cache. This was being done to save space. See #376 (closed) for more information.

As this has become a large task, to allow the feature, and those dependent on it to go through sooner, it was decided that a partial issue be raised where the user can have either all of the VCS history or none of it.

We want to be able to control whether or not a project cache contains VCS history

Task Idea / Overview

If bst_format_version is currently X, then the gate is X+1 Before the gate, the default value for the variable vcs-history is keep. After the gate, the default value for that variable is drop.

In addition, a variable vcs-history-git has the default value %{vcs-history} And similarly for vcs-history-bzr.

In elements, any of those may be overridden.

The Source plugins for git and bzr, look for a history key in their source dictionary, if absent, the value %{vcs-history-git} or %{vcs-history-bzr} is used as appropriate.

If the resolved value is keep then behaviour is entirely as it is now.

If the resolved value is drop then behaviour is changed:

  1. The cache key now contains an entry {"vcs-history":"drop"}
  2. Where possible flags for clone/branch are adjusted to reduce the amount of data moved into that directory before removal. E.g. adding -s to the git clone.
  3. Once the source is staged, the .git or .bzr directory is removed.

This approach means that if current behaviour is preserved by means of bumping the format version and then including variables: vcs-history: keep in the project.conf, the cache key calculation will be unchanged.

Affected areas / concerns

  1. It's possible that the variables (vcs-history etc) may need to be namespaced further in a bst "domain"?
  2. This requires a number of global variables to be defined and validated
  3. This requires changes to the bzr and the git Source handlers.

Future proofing

If in the future we come up with a way to trim VCS history then we may do another format bump to change the default from drop to trim and that can be handled in a similar fashion without causing significant issue since each time it is an active opt-in to the new behaviour which can be documented in the NEWS file.

Task description

  • Add vcs-history, vcs-history-git, vcs-history-bzr variables to projectconfig.yaml
  • Set default of vcs-history-git and vcs-history-bzr to vcs-history
  • If bst_format_version is before defined point (Current + 1): set default of vcs-history to Keep
  • If bst_format_version is after defined point: set default of vcs-history to Drop
  • Add functionality to remove the VCS history based on flags`
  • If flag is not set to keep: add {"vcs-history":"drop"} to the cache key

Related Issues

This task acts as a blocker for: #311 #21 (closed) #376 (closed) #413


Edited by Phillip Smyth
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information