Selecting a ref on the commits page does not set ref_type unless ref_type is already present
Related to https://gitlab.com/gitlab-org/gitlab/-/merge_requests/209645+ Thread https://gitlab.com/gitlab-org/gitlab/-/merge_requests/209645#note_2843725471 https://gitlab.com/gitlab-org/gitlab/-/blob/3f03acfda406b9983fc26d37ce1c2c120f1510da/app/assets/javascripts/repository/utils/ref_switcher_utils.js#L57-89 https://gitlab.com/gitlab-org/gitlab/-/blob/3f03acfda406b9983fc26d37ce1c2c120f1510da/app/assets/javascripts/repository/components/header_area.vue#L18 https://gitlab.com/gitlab-org/gitlab/-/blob/3f03acfda406b9983fc26d37ce1c2c120f1510da/app/assets/javascripts/projects/commits/index.js#L50 We have logic in the ref selector dropdown which should set the `ref_type` value in the URL query string to the type of ref that was selected. ![image](/uploads/3c9b02511928ce0071f6218ab9f6bb91/image.png){width=363 height=275} This only works if you have manually entered the ref_type in the URL previously. e.g. if you visit https://gitlab.com/gitlab-org/gitlab/-/commits/master and select a new ref `cqs-linter` from the dropdown, the resulting URL is `https://gitlab.com/gitlab-org/gitlab/-/commits/cqs-linter` however, if you visit https://gitlab.com/gitlab-org/gitlab/-/commits/master?ref_type=heads and select the ref you end up at `https://gitlab.com/gitlab-org/gitlab/-/commits/cqs-linter?ref_type=heads` which is correct. We need to update the logic so it alwasy sets the ref_type regardless of the ref_type existing currently or not. If possible we should also unify the logic between the commits, branches, and tags pages as these could all use the same ref selector logic. ## Additional note If we could also add a 3rd ref_type value for `commit` that would be useful. We currently only have `heads` and `tags`. This may need additional work in the branches and tags pages but this needs investigation. If it's not possible in this change we should create a follow-up to implement the backend changes to make it possible and then implement the frontend changes.
issue