Skip to content

Improve support for `git clean`

Kamil Trzciński requested to merge do-clean-after-checkout into master

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 disable git 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:

  1. We do not use git reset --hard as this is not needed, because we already do git checkout -f,
  2. Moves git clean after git checkout -f as this is desired behavior,
  3. We remove one I/O intensive operation (git reset --hard), reducing I/O by 33%: git checkout -f and git 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

Merge request reports