Skip to content
Snippets Groups Projects

Improve support for `git clean`

Merged Kamil Trzciński requested to merge do-clean-after-checkout into master
1 unresolved thread

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Brendan O'Leary mentioned in issue #2900

    mentioned in issue #2900

  • Brendan O'Leary changed the description

    changed the description

  • added 1 commit

    • a28d1017 - Improve support for git clean

    Compare with previous version

  • added 1 commit

    • b50b00a7 - Improve support for git clean

    Compare with previous version

  • Kamil Trzciński changed the description

    changed the description

  • Kamil Trzciński resolved all discussions

    resolved all discussions

  • added 1 commit

    • 4b0e151d - Improve support for git clean

    Compare with previous version

    • Resolved by Steve Xuereb

      @ayufan would it make sense to move git reset --hard inside of a different MR? This would make it easier to revert is something goes wrong. It is a small change but I think it's better track different behaviors changes in different MRs.

  • Steve Xuereb
  • Steve Xuereb
  • Steve Xuereb
  • Steve Xuereb
  • Few suggestions/question back to you @ayufan

  • assigned to @ayufan

  • Kamil Trzciński assigned to @steveazz

    assigned to @steveazz

  • added 1 commit

    • d9c1ddff - Improve support for git clean

    Compare with previous version

  • Kamil Trzciński added 12 commits

    added 12 commits

    Compare with previous version

  • Steve Xuereb
  • Steve Xuereb
  • assigned to @ayufan

  • added 1 commit

    • ef64b964 - Improve support for git clean

    Compare with previous version

  • Kamil Trzciński assigned to @steveazz

    assigned to @steveazz

  • Steve Xuereb approved this merge request

    approved this merge request

  • Nice work @ayufan I'll hand this over to @nolith as he left some comments and want to make sure he thinks that those were addressed, but let's go ahead and crate the documentation.

  • assigned to @nolith

  • @ayufan a couple of minor nitpicks.

  • assigned to @ayufan

  • added 1 commit

    • f4c1feb2 - Improve support for git clean

    Compare with previous version

  • assigned to @nolith

  • Alessio Caiazza approved this merge request

    approved this merge request

  • Alessio Caiazza enabled an automatic merge when the pipeline for f4c1feb2 succeeds

    enabled an automatic merge when the pipeline for f4c1feb2 succeeds

  • Alessio Caiazza mentioned in commit ef40d5f9

    mentioned in commit ef40d5f9

  • @ayufan @brendan I think that with this MR being merged we can also close this issue: #1453 (closed)

  • mentioned in issue #1453 (closed)

  • maybe !772 (closed) could be closed as well

  • Steve Xuereb mentioned in merge request !772 (closed)

    mentioned in merge request !772 (closed)

  • @ayufan Is it possible to extend this feature to the submodule strategy? I've just tried in 11.10rc2 and it only works for the main branch. The fetch strategy of submodules keeps doing a forced git clean (even ignoring .gitignore).

    Thank you.

  • @yperchy It's being handled in !1297 (closed) :)

  • @tmaczukin Thanks for answering :)

  • mentioned in issue #3473 (closed)

  • mentioned in issue #4175 (closed)

  • mentioned in epic &1238 (closed)

  • Anton Maklakov mentioned in merge request !925 (closed)

    mentioned in merge request !925 (closed)

  • Please register or sign in to reply
    Loading