Fixing VCS reduction
Background
Currently we have a version of VCS reduction that unconditionally removes the VCS history. Unfortunately this results in certain projects breaking and it also blocks some future projects, for example dogfooding, which would require git history in order for it to be usable for development.
To fix this, i suggest the following:
The variable vcs-history
be added with a default value of drop
This would allow for the default functionality to be that all VCS history is removed
The variable would also have the option of keep
This would allow for projects or elements to retain all of their VCS history as this can be changed at both a project and element level.
In addition, the variables vcs-history-git
and vcs-history-bzr
would be added with the default value
%{vcs-history}
With the option to be independently assigned values.
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 changed so that no VCS history is removed
In this case, no entry to the cache key is made
If the resolved value is drop
then behaviour is changed to that:
- 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
-s
to thegit clone
. - Once the source is staged, the
.git
or.bzr
directory is removed.
This approach means that we can have the removal of VCS history, without breaking projects which rely on having VCS history available.
This can also be expanded on in the future to add a reduce
or limit
option, to allow for the reduction of VCS history instead of the complete removal of it.
This could 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.
Affected areas / concerns
- It's possible that the variables (
vcs-history
etc) 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
bzr
and thegit
Source handlers.
Task description
-
Add
vcs-history
,vcs-history-git
,vcs-history-bzr
variables to projectconfig.yaml -
Set default of
vcs-history-git
andvcs-history-bzr
tovcs-history
-
Set default of
vcs-history
todrop
- Add functionality to remove the VCS history based on flags`
-
If flag is
not
set tokeep
: add{"vcs-history":"drop"}
to the cache key