Commit d0a95c30b9246bd5914f47f2d644c7c16c43fe7d
1 parent
20c65f3b
Exists in
master
and in
4 other branches
Ensure project discover default branch on Project#show
Showing
2 changed files
with
5 additions
and
1 deletions
Show diff stats
app/controllers/projects_controller.rb
| ... | ... | @@ -57,6 +57,10 @@ class ProjectsController < Projects::ApplicationController |
| 57 | 57 | limit = (params[:limit] || 20).to_i |
| 58 | 58 | @events = @project.events.recent.limit(limit).offset(params[:offset] || 0) |
| 59 | 59 | |
| 60 | + # Ensure project default branch is set if it possible | |
| 61 | + # Normally it defined on push or during creation | |
| 62 | + @project.discover_default_branch | |
| 63 | + | |
| 60 | 64 | respond_to do |format| |
| 61 | 65 | format.html do |
| 62 | 66 | if @project.empty_repo? | ... | ... |
app/models/project.rb
| ... | ... | @@ -312,7 +312,7 @@ class Project < ActiveRecord::Base |
| 312 | 312 | def discover_default_branch |
| 313 | 313 | # Discover the default branch, but only if it hasn't already been set to |
| 314 | 314 | # something else |
| 315 | - if repository && default_branch.nil? | |
| 315 | + if repository.exists? && default_branch.nil? | |
| 316 | 316 | update_attributes(default_branch: self.repository.discover_default_branch) |
| 317 | 317 | end |
| 318 | 318 | end | ... | ... |