From f3abbfec5ab7bbb984bd74c734a8cf470dd63f05 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 13 Jan 2013 03:52:34 +0100 Subject: [PATCH] Projects/Gitolite: Make the default branch the real default. Gitlab will now tell gitolite to update the HEAD pointer over ssh using the symbolic-ref command - this ensures that when performing a git clone, the branch you receive if none is specified will actually be the one you configured as default. This also resolves breakage when your repo lacks any branch named "master. For this to function, you MUST also apply Git commit 048a1918ff to your gitolite installation and enable the command in your .gitolite.rc --- app/contexts/project_update_context.rb | 7 ++++++- lib/gitlab/backend/gitolite_config.rb | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/contexts/project_update_context.rb b/app/contexts/project_update_context.rb index 5b77d0a7964..96a5ebfab8e 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 a2bc4ca8d74..1ec43e94f10 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 -- GitLab