Fix ref selector to refetch data and properly encode special characters in URL
Summary
The refactored commit list has two issues when changing the branch/tag in the ref selector:
- Data is not refetched when the ref selector value changes
- URL updates with incorrect value for refs containing special characters (not properly encoded)
Current Behavior
When a user selects a different branch or tag in the ref selector:
- The URL updates but with improperly encoded values for refs with special characters
- The commit list data does not refresh to show commits from the newly selected ref
Expected Behavior
When a user selects a different branch or tag:
- The URL should update with properly encoded ref values
- The commit list should refetch and display commits from the newly selected ref
Root Cause Analysis
Issue 1: Data not refetching
The escapedRef is injected via provide/inject from init_commit_list_app.js at initialization time. This value is static and never updates when the route changes.
Issue 2: URL encoding
The onRefChange method uses generateRouterParams which may not properly handle all special characters in ref names.
Proposed Solution
For Issue 1
Make the ref reactive by using route params or watch route changes and refetch.
For Issue 2
Review and fix the encoding in generateRouterParams to properly handle special characters.
Relevant Files
app/assets/javascripts/projects/commits/components/commit_list_app.vueapp/assets/javascripts/projects/commits/components/commit_list_header.vueapp/assets/javascripts/projects/commits/init_commit_list_app.jsapp/assets/javascripts/repository/utils/ref_switcher_utils.js
Related
Part of epic &17482
Edited by 🤖 GitLab Bot 🤖