Add MR mergeability check for locked paths
What does this MR do and why?
Add MR mergeability check for locked paths
This change introduces a new check. This check will prevent merging MRs which include locked paths.
We also have a check which runs when a user pushes code that prevents pushing paths that are locked by other users.
This change will allow us to enable the fix for #23625 (closed)
Related
- Spike: Introduce new mergeability check to ensu... (#428247 - closed)
- [Feature flag] Rollout of `locked_paths_mergeab... (#474705 - closed)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Failing
Passing
Inactive
How to set up and validate locally
- Go to a project in GDK and ensure File Locking is available https://docs.gitlab.com/ee/user/project/file_lock.html#default-branch-file-and-directory-locks
- In the rails console ensure the project has no Path Locks
Project.find_by_full_path('my/path').path_locks.destroy_all
- Enable the FF
Feature.enable(:locked_paths_mergeability_check)
- In the project you are working on, lock one of the existing files (if you just came from !158773 (merged) we can use the test.txt file)
- In the console verify that there is a new
PathLock
PathLock.last
should be similar to=> #<PathLock:0x000000016d16b728 id: 33, path: "test.txt", project_id: 21, user_id: 1, created_at: Mon, 29 Jul 2024 13:20:58.836181000 UTC +00:00, updated_at: Mon, 29 Jul 2024 13:20:58.836181000 UTC +00:00>
- In a new branch well update and push the file
git checkout -b test-path-locks && echo 'test' > test.txt && git add . && git commit -m 'test path lock feature' && git push origin test-path-locks
- In the response, click the link to create the merge request e.g.
remote: http://gdk.test:3000/playground/lockissue/-/merge_requests/new?merge_request%5Bsource_branch%5D=test-path-locks
- Create the MR. The widget should pass
- Change the target brach to the
test-feature
branch, this should hide the check as we aren't targeting the default branch - Now unlock the file then lock it with another user
- Now go back to the MR and reload the page. The MR should still be ok as we aren't targeting the default branch.
- Change the target branch to the default branch and reload the page, the widget should show the failed check
Edited by Ash McKenzie