Fix commits list ref selector

What does this MR do and why?

Fixes two bugs in the commits page ref selector:

  1. Ref changes didn't refetch commits - Switching branches/tags via the ref selector only updated the URL but didn't trigger a new GraphQL query, so stale commits remained on screen. This was because the Apollo query used the injected escapedRef (a constant) instead of a reactive data property. Now, commit_list_header emits a ref-change event, and commit_list_app updates a reactive currentRef and resets pagination accordingly.
  2. Refs with # were incorrectly encoded - generateRouterParams used an inline encodeURI().replace(/#/g, '%23') instead of the existing encodeRepositoryPath() utility. This is now consolidated to use the shared helper, reducing duplication.

References

Closes #589360 (closed)

Screenshots or screen recordings

before after

How to set up and validate locally

  1. Enable project_commits_refactor
  2. Navigate to any project's commits page (e.g., /-/commits/main)
  3. Use the ref selector dropdown to switch to a different branch
  4. Before: The URL updates but the commit list stays the same
  5. After: The commit list refetches and displays commits for the selected branch, pagination resets
  6. Test with a branch name containing # (e.g., fix/#123) to verify correct URL encoding
Edited by Jacques Erasmus

Merge request reports

Loading