Update redirects and commit lookup code for controllers
requested to merge 20526-impossible-to-browse-a-branch-if-a-tag-exists-with-the-same-name-be-2 into master
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
- Create a project that has a branch and a tag with the same name
- 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)
- Enable the
redirect_with_ref_type
feature flag - 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))
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #20526 (closed)
Edited by Jerry Seto