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:
- The cache key now contains an entry
{"vcs-history":"drop"} - Where possible flags for clone/branch are adjusted to reduce the amount
of data moved into that directory before removal. E.g. adding
-sto thegit clone. - Once the source is staged, the
.gitor.bzrdirectory 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
- It's possible that the variables (
vcs-historyetc) may need to be namespaced further in abst"domain"? - This requires a number of global variables to be defined and validated
- This requires changes to the
bzrand thegitSource 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-bzrvariables to projectconfig.yaml -
Set default of vcs-history-gitandvcs-history-bzrtovcs-history -
If bst_format_versionis before defined point (Current + 1): set default ofvcs-historytoKeep -
If bst_format_versionis after defined point: set default ofvcs-historytoDrop -
Add functionality to remove the VCS history based on flags` -
If flag is notset tokeep: add{"vcs-history":"drop"}to the cache key
Related Issues
This task acts as a blocker for: #311 #21 (closed) #376 (closed) #413