Fix -skip-invalid-merge-requests flag to handle missing commits #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The flag previously only handled the case where a start commit had no parents (orphaned commits), but did not handle cases where commits referenced in merge request metadata no longer exist in the repository (typically due to force-pushes after the merge request was closed).
Changes:
Add skip-logic for missing start commits (project.go:436-443) When a start commit cannot be loaded from the repository, check the skipInvalidMergeRequests flag and log as INFO instead of ERROR
Add validation and skip-logic for missing end commits (project.go:486-492) Validate that the end commit exists before attempting to checkout the temporary source branch. Apply same skip-logic as start commits.
Improve error messages to include the commit hash for better debugging
This ensures that when -skip-invalid-merge-requests is specified, ALL merge requests with missing commits are gracefully skipped with INFO logging instead of failing with ERROR, resulting in a clean exit code.
Fixes issue where migrations would report errors even with the skip flag enabled, when merge requests referenced commits that were removed from Git history via force-push operations.