Fix default branch being cached and show old one after change
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
44c55307a0
commit
e2e1167022
2 changed files with 9 additions and 2 deletions
|
@ -5,12 +5,14 @@ module Projects
|
||||||
params[:project].delete(:public) unless can?(current_user, :change_public_mode, project)
|
params[:project].delete(:public) unless can?(current_user, :change_public_mode, project)
|
||||||
new_branch = params[:project].delete(:default_branch)
|
new_branch = params[:project].delete(:default_branch)
|
||||||
|
|
||||||
if project.repository.exists? && new_branch != project.repository.root_ref
|
if project.repository.exists? && new_branch != project.default_branch
|
||||||
GitlabShellWorker.perform_async(
|
GitlabShellWorker.perform_async(
|
||||||
:update_repository_head,
|
:update_repository_head,
|
||||||
project.path_with_namespace,
|
project.path_with_namespace,
|
||||||
new_branch
|
new_branch
|
||||||
)
|
)
|
||||||
|
|
||||||
|
project.reload_default_branch
|
||||||
end
|
end
|
||||||
|
|
||||||
project.update_attributes(params[:project], as: role)
|
project.update_attributes(params[:project], as: role)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
class Project < ActiveRecord::Base
|
class Project < ActiveRecord::Base
|
||||||
include Gitlab::ShellAdapter
|
include Gitlab::ShellAdapter
|
||||||
extend Enumerize
|
extend Enumerize
|
||||||
|
|
||||||
ActsAsTaggableOn.strict_case_match = true
|
ActsAsTaggableOn.strict_case_match = true
|
||||||
|
|
||||||
attr_accessible :name, :path, :description, :issues_tracker, :label_list,
|
attr_accessible :name, :path, :description, :issues_tracker, :label_list,
|
||||||
|
@ -451,4 +451,9 @@ class Project < ActiveRecord::Base
|
||||||
def default_branch
|
def default_branch
|
||||||
@default_branch ||= repository.root_ref if repository.exists?
|
@default_branch ||= repository.root_ref if repository.exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reload_default_branch
|
||||||
|
@default_branch = nil
|
||||||
|
default_branch
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue