Skip to content

Update redirects and commit lookup code for controllers

What does this MR do and why?

Update redirect and commit lookup code for controllers

A ref is ambiguous if a ref_type is not specified and it could be interpreted as a tag or a branch. When the ref_type parameter is missing and the ref is ambiguous we should redirect with a ref_type parameter. git uses the tag when it exists so we redirect to the tag when tag and branch both exist.

This change includes a new class RequestedRef which is meant to encapsulate the logic for determining when a ref is ambiguous.

How to set up and validate locally

  1. Create a project that has a branch and a tag with the same name
  2. Browse the repository and switch to the branch via the dropdown and see that the existing behaviour is preserved (get redirected to the same view except for the commit id)
  3. Enable the redirect_with_ref_type feature flag
  4. Try selecting the branch again and see that there is a redirect to the same view with the ref_type in the query parameters of the url (the contents will be incorrect. displaying the correct contents will be handled in !122145 (merged))
  5. Try the same url without the ref_type and see that there is redirect to the same view with the ref_type but for tags

MR acceptance checklist

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

Related to #20526 (closed)

Edited by Jerry Seto

Merge request reports