[go: up one dir, main page]

Skip to content

Fetch correct pipeline when viewing commits in detacted state

What does this MR do and why?

Fetch correct pipeline when viewing commits in detacted state

If you are viewing the commits and have a branch or tag selected in the ref selector we can correctly fetch the pipeline using the ref.name. However, you can also view commits when you've checked out a commit i.e. instead of viewing master you're viewing commit1 and viewing all of the commits in the history of commit1.

When we are in this detatched state we need to remove the ref and rely on the SHA instead. We don't know which branch or tag we're on so we just find the most recent pipeline within any ref and show that one.

Unfortunately we don't have ref_type available in the commits page so here we are checking if the ref looks like a SHA. This does have a caveat that any branches that look like SHAs will show the latest pipelines for the commit, not the commit within the current branch.

This trade-off is much better than the current situation. It's highly unlikely for users to be naming branches with SHA values. It is much more likely for users to view the commits page while viewing a commit.

References

Tag list page links to latest pipeline of the c... (#347526)

Screenshots or screen recordings

Pipeline correctly displays on master branch

image

Navigating to the first commit it shows nothing because there's no ref

image

After the change we now show the pipelines

image

How to set up and validate locally

Visit a project and go to the commits page. Copy the SHA of the first commit on the page. Open the ref selector above the list, enter the SHA value and select the commit that is returned. The page should now show the commit's history and display the pipeline statuses.

Merge request reports

Loading