Skip to content

Add pinned file to merge requests

Stanislav Lashmanov requested to merge slashmanov/add-pinned-file into master

What does this MR do and why?

Implements Pin file when linking to a file line in an MR (#387246 - closed).

This MR does the following:

  1. Uses diff_by_file_hash endpoint from Add diff_by_file_hash merge request action (!138712 - merged) to fetch pinned file.
  2. Pins a file if we're on a merge request Changes page and there's a ?pin=FILE_HASH present in the URL
    1. Backend provides an URL to fetch the pinned file by hash using diff_by_file_hash endpoint
    2. Frontend fetches that file if the URL is present and pins the file, changing its' order to always be the first in the list of files
  3. Adds a button to unpin the file

Screenshots or screen recordings

Screen_Recording_2023-11-21_at_18.07.48

How to set up and validate locally

  1. Enable pinned_file feature flag
  2. Open any MR with at least two files
  3. Open a link to a second file a new tab
  4. File should become pinned
  5. Unpin the file
  6. File should appear where it was before pinning
Edited by Stanislav Lashmanov

Merge request reports