Commit d0a95c30 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Ensure project discover default branch on Project#show

parent 20c65f3b
......@@ -57,6 +57,10 @@ class ProjectsController < Projects::ApplicationController
limit = (params[:limit] || 20).to_i
@events = @project.events.recent.limit(limit).offset(params[:offset] || 0)
# Ensure project default branch is set if it possible
# Normally it defined on push or during creation
@project.discover_default_branch
respond_to do |format|
format.html do
if @project.empty_repo?
......
......@@ -312,7 +312,7 @@ class Project < ActiveRecord::Base
def discover_default_branch
# Discover the default branch, but only if it hasn't already been set to
# something else
if repository && default_branch.nil?
if repository.exists? && default_branch.nil?
update_attributes(default_branch: self.repository.discover_default_branch)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment