diff --git a/app/contexts/project_update_context.rb b/app/contexts/project_update_context.rb index 5b77d0a79648f7bed60cb06507bee51935af797e..96a5ebfab8ee806e1b65b14d5da6fa758e5e2ae2 100644 --- a/app/contexts/project_update_context.rb +++ b/app/contexts/project_update_context.rb @@ -17,7 +17,12 @@ class ProjectUpdateContext < BaseContext end end - project.update_attributes(params[:project], as: role) + if params[:project]["default_branch"] != project.default_branch + project.update_attributes(params[:project], as: role) + project.update_repository + else + project.update_attributes(params[:project], as: role) + end end end diff --git a/lib/gitlab/backend/gitolite_config.rb b/lib/gitlab/backend/gitolite_config.rb index a2bc4ca8d74f662ebf56acf87b7b1c77077c9c24..1ec43e94f10ad352e49c6e97d06d24ac4018a0b4 100644 --- a/lib/gitlab/backend/gitolite_config.rb +++ b/lib/gitlab/backend/gitolite_config.rb @@ -161,6 +161,9 @@ module Gitlab # Add sharedRepository config repo.set_git_config("core.sharedRepository", "0660") + # Update the repository HEAD to point to the default branch + system("ssh git@#{Gitlab.config.gitolite.ssh_host} 'symbolic-ref #{project.path_with_namespace} HEAD refs/heads/#{project.default_branch}'") + repo end