Skip to content

Link to previous path when viewing blame on renamed files

What does this MR do and why?

Link to previous path when viewing blame on renamed files

On blame page, the View blame prior to this change button fail if the file has been renamed.

To resolve that, when reading the raw blame from git, the lines beginning with "previous" are read to retrieve the previous path.

Also, the button has been removed for the initial commit on the file.

Fixes Blaming the previous version has errors before ... (#196632 - closed)

Screenshots or screen recordings

Capture_d_écran_du_2022-02-08_22-34-34

This branch is available here https://gitlab.com/gitlab-org/gitlab-test/-/blob/32c33da59f8a1a9f90bdeda570337888b00b244d/files/plain_text/renamed (MR Blame on renamed (gitlab-test!55 - merged))

This file has been renamed three times. Now, the button to the previous blame links to the correct path.

Also notice the button is missing for the initial commit. It was already the case for the repository initial commit, but now it's also for the file initial commit.

How to set up and validate locally

  1. Edit a file, rename it, and commit
  2. Go to blame
  3. Click on one of the button View blame prior to this change. It will show blame on the previous path.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Thomas Chandelle

Merge request reports

Loading