Empty default branches with other populated branches cause exceptions
When there is an empty default branch and code has been pushed to other branches a bunch of errors started happening in 6.6.
- rake gitlab:check throws this trace
Group / repo ... rake aborted! Reference 'refs/heads/master' not found /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/gitlab_git-5.4.0/lib/gitlab_git/repository.rb:110:in `head' /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/gitlab_git-5.4.0/lib/gitlab_git/repository.rb:110:in `discover_default_branch' /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/gitlab_git-5.4.0/lib/gitlab_git/repository.rb:29:in `initialize' /home/git/gitlab/app/models/repository.rb:8:in `new' /home/git/gitlab/app/models/repository.rb:8:in `initialize' /home/git/gitlab/app/models/project.rb:177:in `new' /home/git/gitlab/app/models/project.rb:177:in `repository' /home/git/gitlab/app/models/project.rb:366:in `empty_repo?' /home/git/gitlab/lib/tasks/gitlab/check.rake:481:in `block in check_repos_update_hooks_is_link' /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.3/lib/active_record/relation/batches.rb:26:in `block (2 levels) in find_each' /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.3/lib/active_record/relation/batches.rb:26:in `each' /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.3/lib/active_record/relation/batches.rb:26:in `block in find_each' /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.3/lib/active_record/relation/batches.rb:75:in `find_in_batches' /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-deprecated_finders-1.0.3/lib/active_record/deprecated_finders/relation.rb:70:in `find_in_batches' /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.3/lib/active_record/relation/batches.rb:25:in `find_each' /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.3/lib/active_record/querying.rb:8:in `find_each' /home/git/gitlab/lib/tasks/gitlab/check.rake:478:in `check_repos_update_hooks_is_link' /home/git/gitlab/lib/tasks/gitlab/check.rake:331:in `block (3 levels) in <top (required)>' Tasks: TOP => gitlab:check => gitlab:gitlab_shell:check (See full trace by running task with --trace)
- the Project page shows a 500
This wouldn't be a big deal as this is sort of a broken situation but the 500 on the Project page means there's no obvious was to resolve the error without creating the branch, changing the settings, then deleting the branch back out. With no feedback on what the branch is you'll have to guess at what the branch its expecting is.
How I think I got into this situation.
- Created a project where it assumed the master branch to be the default.
- Pushed up code from another repository that had no master branch.
I had 2 projects that had been around for quite a while in this state and as I said earlier this was a regression that happened in 6.6 that had not thrown a error previously.