Improve support for `git clean`
What does this MR do?
Adds support for GIT_CLEAN_FLAGS
to allow customize the behavior of git clean
.
This makes GIT_CLEAN_FLAGS
:
- when not defined to use
-ffdx
, - when
none
to disablegit clean
.
This is configurable via following statements in .gitlab-ci.yml
:
variables:
missing GIT_CLEAN_FLAGS # use default, the `-ffdx`
GIT_CLEAN_FLAGS: "" # use default, the `-ffdx`
GIT_CLEAN_FLAGS: -ffdx -e cache/
GIT_CLEAN_FLAGS: none # disable git clean
This MR also improves performance of checkout in very big (a lot of files) repositories:
- We do not use
git reset --hard
as this is not needed, because we already dogit checkout -f
, - Moves
git clean
aftergit checkout -f
as this is desired behavior, - We remove one I/O intensive operation (
git reset --hard
), reducing I/O by 33%:git checkout -f
andgit clean
only which has the same I/O footprint.
Closes #4109 (closed)
Why was this MR needed?
Make git clean
behavior flexible and performant.
Does this MR meet the acceptance criteria?
-
Documentation created/updated -
Added tests for this feature/bug -
In case of conflicts with master
- branch was rebased
What are the relevant issue numbers?
Related to https://forum.gitlab.com/t/disable-git-clean-between-jobs/7494
Edited by Kamil Trzciński (Back 2025-01-01)