Default branch rename redirect broken for specific branch names
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
The default branch rename redirect introduced with by #329100 (closed) does not work when the former default branch name contained a slash (/
).
Steps to reproduce
- Create a new project initialized with a README
- Bookmark the direkt URL to the README file (https://gitlab.com/jojoob1/default-branch-redirect-test/-/blob/main/README.md)
- Navigate into the repository view and click on
+ > New Branch
- Create
foo/bar
branch based on the default branch - Navigate to the project settings
Repository > Default Branch
and change tofoo/bar
- Navigate to
Repository > Branches
and deletemain
, confirm the protected branch deletion popup - Test the redirect from the direct file target. It works!
- Create
baz
branch based on the default branch - Navigate to the project settings
Repository > Default Branch
and change tobaz
- Navigate to
Repository > Branches
and deletefoo/bar
, confirm the protected branch deletion popup - Test the redirect from the direct file target. 404 page is shown instead of redirect (https://gitlab.com/jojoob1/default-branch-redirect-test/-/blob/foo/bar/README.md)
Example Project
https://gitlab.com/jojoob1/default-branch-redirect-test/
What is the current bug behavior?
The default branch rename redirect does not work when the former default branch name contained a slash (/
).
What is the expected correct behavior?
I expect the redirect to work regardless of the branch name.
Suggestion
Beside fixing the bug (maybe there are other branch names that brake the redirect, too?) I suggest introducing a "default branch URL": a URL that always points or redirects to the default branch. Something like https://gitlab.com/jojoob1/default-branch-redirect-test/-/blob/_default_branch/README.md
where _default_branch
is not a branch name but an alias.