Merge branch 'pmq20/gitlab-ce-psvr/change-head' into 'master'

Use rugged to change HEAD

_Originally opened at !2850 by @pmq20._

Needless to invoke gitlab_shell here, which is slow.

See merge request !3705
This commit is contained in:
Robert Speicher 2016-04-15 16:44:21 +00:00
commit 34b0561560
3 changed files with 4 additions and 14 deletions

View file

@ -42,6 +42,7 @@ v 8.7.0 (unreleased)
- Add default scope to projects to exclude projects pending deletion
- Allow to close merge requests which source projects(forks) are deleted.
- Ensure empty recipients are rejected in BuildsEmailService
- Use rugged to change HEAD in Project#change_head (P.S.V.R)
- API: Ability to filter milestones by state `active` and `closed` (Robert Schilling)
- API: Fix milestone filtering by `iid` (Robert Schilling)
- API: Delete notes of issues, snippets, and merge requests (Robert Schilling)

View file

@ -865,7 +865,9 @@ class Project < ActiveRecord::Base
def change_head(branch)
repository.before_change_head
gitlab_shell.update_repository_head(self.path_with_namespace, branch)
repository.rugged.references.create('HEAD',
"refs/heads/#{branch}",
force: true)
reload_default_branch
end

View file

@ -54,19 +54,6 @@ module Gitlab
"#{path}.git", "#{new_path}.git"])
end
# Update HEAD for repository
#
# path - project path with namespace
# branch - repository branch name
#
# Ex.
# update_repository_head("gitlab/gitlab-ci", "3-1-stable")
#
def update_repository_head(path, branch)
Gitlab::Utils.system_silent([gitlab_shell_projects_path, 'update-head',
"#{path}.git", branch])
end
# Fork repository to new namespace
#
# path - project path with namespace