Commit 34b05615 authored by Robert Speicher's avatar Robert Speicher

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
parents bb59a1f9 f8e8a61c
......@@ -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)
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment