Skip to content

Preserve selected tree path when switching revisions in Commits view

What does this MR do and why?

Makes the Commits view preserve the selected tree path when switching refs using the picker.

It also changes that view's handling of non-existent paths to be consistent with blob view: When the selected path does not exist on the selected ref, show a "$file did not exist on $ref" message and go to the root.

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

Before After Note

Before-1

After-1

Load the Commits view of a file.

Before-2

After-2

Select revision v1.1.1 using picker.

Before: showed commit history at the root of the tree.

After: shows commit history of the file selected on the previous page.

Before-3

After-3

Before: showed commit history in tag v1.0.0 at the root of the tree.

After: Catches that the file does not exist in v1.0.0 and report it. Goes to the project root like the blob view does.

How to set up and validate locally

  1. Set up the GitLab Development Kit (GDK) locally (instructions here).
  2. Check out the changes from this branch into the GDK tree.
  3. Go to a file's Commits view: http://gdk.local:3000/gitlab-org/gitlab-test/-/commits/lock-detection/with%20space/README.md?ref_type=heads
  4. Switch to different revisions, including v1.0.0 where the file does not exist.

Closes #444282.

Merge request reports