[go: up one dir, main page]

Skip to content

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

  1. Create a new project initialized with a README
  2. Bookmark the direkt URL to the README file (https://gitlab.com/jojoob1/default-branch-redirect-test/-/blob/main/README.md)
  3. Navigate into the repository view and click on + > New Branch
  4. Create foo/bar branch based on the default branch
  5. Navigate to the project settings Repository > Default Branch and change to foo/bar
  6. Navigate to Repository > Branches and delete main, confirm the protected branch deletion popup
  7. Test the redirect from the direct file target. It works!
  8. Create baz branch based on the default branch
  9. Navigate to the project settings Repository > Default Branch and change to baz
  10. Navigate to Repository > Branches and delete foo/bar, confirm the protected branch deletion popup
  11. 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.

Edited by 🤖 GitLab Bot 🤖