Skip to content

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 We don't need to move this from controller to frontend, because the message is shown on entering the edit, not submitting it.
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:

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

  1. In rails console enable the feature flag

    Feature.enable(:blob_edit_refactor)
  2. Go to Project / Repository

  3. Choose a file to edit in single file editor.

  4. Change the name of the file and commit changes.

  5. Make sure you're redirected to the newly renamed file.

  6. 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

Edited by Paulina Sedlak-Jakubowska

Merge request reports

Loading