Skip to content

Fix branch with # in name fails to fetch commit data

What does this MR do and why?

Recently we opted to use encodeURI when composing a https://gitlab.com/gitlab-org/gitlab/-/merge_requests/136323 for fetching commit data. This helped to solve our problem with / being encoded for multi-level subdirectories.

However, as a result it isn't possible to correctly fetch data, when a branch name includes #. More on this in this comment: #441582 (comment 1904839407)

I decided to keep encodeURI method for the path, but go back to encodeURIComponent for the ref.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screenshot_2024-05-16_at_15.17.54 Screenshot_2024-05-16_at_15.16.33
Screenshot_2024-05-16_at_15.18.08 Screenshot_2024-05-16_at_15.16.22

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Create a branch that has # sign in its name
  2. On that branch, create a subdirectory that will have a couple of levels of subdirectories. This could be empty folders.
  3. Go to Repository page and see if the commit data loads correctly.
  4. Go into the subdirectories you created. Their commit data should also load correctly.

Related to #441582 (closed)

Edited by Paulina Sedlak-Jakubowska

Merge request reports