Fix accidental commits collection mutation
What does this MR do and why?
Contributes to #356094 (closed)
Introduced in !123950 (merged)
Sentry error: https://new-sentry.gitlab.net/organizations/gitlab/issues/268934
Problem
#prepend
method executes in-place update for commits collection. That
breaks code executed after it.
Solution
Use a copy of commit collection to avoid an accidental mutation.
How to set up and validate locally
- Enable feature flag
Feature.enable(:verify_push_rules_for_first_commit)
- Create an empty repository
- Go to Settings -> Repository -> Push Rules
- Enable "Prevent pushing secret files" and save
- Clone the empty repository
- Create 2 commits locally
- Push to the repository
- It should work
Before the fix:
remote: GitLab: 500 Internal Server Error
To ssh://gdk.test:2222/root/empty-repo.git
! [remote rejected] HEAD -> main (pre-receive hook declined)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Vasilii Iakliushin