Refactor the UpdateMirrorService
What does this MR do and why?
Related to: #561037
This is a follow up to LFS mirroring timeout issue (!198736 - merged)
This MR extracts branch filtering and change calculation logic into separate service classes for better maintainability and performance.
- Add BranchFilter service to handle protected branch and regex filtering.
- Add BranchChangesCalculator service to determine which revisions changed
References
How to set up and validate locally
- Create a remote project (or you can use the exiting one https://gitlab.com/emmaspark/mirroring-lfs)
- Create an empty local project WITHOUT a README file
- Go to Settings → Repository → Mirroring
- Add the remote project repository URL (e.g., https://gitlab.com/emmaspark/mirroring-lfs.git)
- Confirm it's pull mirroring
- Click "Mirror repository"
- Check if the initial mirroring is successful
- A new branch + the existing branches test:
- In the remote repo: add a new branch with a new LFS file(file_name.txt). Also edit one of the existing branches.
- In the local repo: go to Settings → Repository → Mirroring. Click the run icon next to a bin icon. Check your local repo and see if both branches are mirrored.
- The protected branch test:
- In the local repo: repeat the step 2-5 and check "Mirror only protected branches" -> the step 7 and 8 -> set the protected branch in Settings -> Protected branches
- In the remote repo: edit one of the existing branches(an unprotected branch) and the protected branch as well. Start mirroring. See if the only protected branch is mirrored.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #561037
Edited by Emma Park