Skip to content

Add MR mergeability check for locked paths

Joe Woodward requested to merge feat/428247-path_lock-mergeability-check into master

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

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

image

Passing

image

Inactive

image

How to set up and validate locally

  1. 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
  2. In the rails console ensure the project has no Path Locks Project.find_by_full_path('my/path').path_locks.destroy_all
  3. Enable the FF Feature.enable(:locked_paths_mergeability_check)
  4. 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)
  5. 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>
  6. 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
  7. 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
  8. Create the MR. The widget should pass
  9. Change the target brach to the test-feature branch, this should hide the check as we aren't targeting the default branch
  10. Now unlock the file then lock it with another user
  11. Now go back to the MR and reload the page. The MR should still be ok as we aren't targeting the default branch.
  12. Change the target branch to the default branch and reload the page, the widget should show the failed check
Edited by Ash McKenzie

Merge request reports

Loading