Ensure project discover default branch on Project#show
This commit is contained in:
parent
20c65f3bcb
commit
d0a95c30b9
|
@ -57,6 +57,10 @@ class ProjectsController < Projects::ApplicationController
|
||||||
limit = (params[:limit] || 20).to_i
|
limit = (params[:limit] || 20).to_i
|
||||||
@events = @project.events.recent.limit(limit).offset(params[:offset] || 0)
|
@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|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
if @project.empty_repo?
|
if @project.empty_repo?
|
||||||
|
|
|
@ -312,7 +312,7 @@ class Project < ActiveRecord::Base
|
||||||
def discover_default_branch
|
def discover_default_branch
|
||||||
# Discover the default branch, but only if it hasn't already been set to
|
# Discover the default branch, but only if it hasn't already been set to
|
||||||
# something else
|
# something else
|
||||||
if repository && default_branch.nil?
|
if repository.exists? && default_branch.nil?
|
||||||
update_attributes(default_branch: self.repository.discover_default_branch)
|
update_attributes(default_branch: self.repository.discover_default_branch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue