Handle renaming files
What does this MR do and why?
This MR is a chunk of work I started in !202756 (closed). I've realised I'll have to cover a couple of scenarios that previously the controller was taking care. Below you can find a breakdown how I plan to split the work:
MR # | Scope | Status |
---|---|---|
1 | Uses rest API to submit data | |
2 | Reintroduce notifications | |
3 | Editing file name is possible | |
4 | File size validation |
|
5 | Handle fork workflow |
It turns out that REST API PUT /projects/:id/repository/files/:file_path
does not allow for renaming the file. I had to introduce a call to /api/:version/projects/:id/repository/commits
, when the file name changes. This also handles changes to the files contents at the same time.
Important note for reviewers
I'm working on this refactor for some time now and I had to do some cleaning before adding another piece. You can review this MR in two ways:
- initial refactor: 2239625a, db71bbb2, fe9d3fa2
- new functionality: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/209168/diffs?diff_id=1531559978&start_sha=4bb77777890cfce7932316004880c67473324302
References
Screenshots or screen recordings
Before | After |
---|---|
Screen_Recording_2025-10-17_at_11.38.03 | Screen_Recording_2025-10-17_at_11.37.06 |
How to set up and validate locally
-
In rails console enable the feature flag
Feature.enable(:blob_edit_refactor)
-
Go to Project / Repository
-
Choose a file to edit in single file editor.
-
Change the name of the file and commit changes.
-
Make sure you're redirected to the newly renamed file.
-
Repeat the same scenario with the feature flag disabled.
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 #509968