Commit 20e20b33 authored by Eric Frias's avatar Eric Frias
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 794873f0
Loading
Loading
Loading
Loading