snippits cannot be edited if created when semantic branch names are used as global default

Summary

After setting default branch name to a semantic version name 0.0.x snippits can no longer be edited.

Steps to reproduce

  1. visit /admin/application_settings/repository
  2. change the default branch name to 0.0.x
  3. create a snippit with a file
  4. edit the newly created snippit
    • Notice the error message saying "Can't fetch content for the blob: Error: Request failed with status code 404"

      This can also be verified by the network tab on the browser. For example if the name of the file in the snippit is test and the snippit number is 71 then the GET request for the snippit returns a 404 status for the url /-/snippets/71/raw/0.0.x/test

      This happens if the snippit is set to any visibility.

Example Project

Not applicable.

What is the current bug behavior?

The snippit edit page shows a message saying "Can't fetch content for the blob: Error: Request failed with status code 404"

What is the expected correct behavior?

The snippit edit page shows the snippit ready for editing.

Relevant logs and/or screenshots

broken snippit edit page

Results of GitLab environment info

Your GitLab Version 🚀 15.3 Up to date


(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Possible fixes

Edited by 🤖 GitLab Bot 🤖