Commit 562e2aaf authored by Eric Frias's avatar Eric Frias Committed by Dan Notestein
Browse files

Add pre_get_sources_script hook to fix fetch strategy corruption

When pipelines are cancelled mid-fetch, git submodules can be left in
a corrupt state (incomplete pack files, empty refs). GitLab Runner's
retry doesn't clean this up, causing "Unable to find current revision"
errors.

This hook runs BEFORE git operations and:
- Removes stale .lock files from interrupted operations
- Detects corrupt main repo (git rev-parse HEAD fails) and removes .git
- Detects corrupt submodules by checking both the working directory AND
  .git/modules/ directly (the latter can be corrupt even when the
  working directory doesn't exist)

Based on workarounds from GitLab issues #296638 and #4600.
parent 82864c53
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment