Make sure we have the branch on the other project
This commit is contained in:
parent
5de74551ac
commit
d8fe2fac7e
|
@ -988,6 +988,17 @@ class Project < ActiveRecord::Base
|
|||
Gitlab::UploadsTransfer.new.rename_project(path_was, path, namespace.path)
|
||||
end
|
||||
|
||||
def fetch_ref(source_project, branch_name, ref)
|
||||
repository.fetch_ref(
|
||||
source_project.repository.path_to_repo,
|
||||
"refs/heads/#{ref}",
|
||||
"refs/heads/#{branch_name}"
|
||||
)
|
||||
|
||||
repository.after_create_branch
|
||||
repository.find_branch(branch_name)
|
||||
end
|
||||
|
||||
# Expires various caches before a project is renamed.
|
||||
def expire_caches_before_rename(old_path)
|
||||
repo = Repository.new(old_path, self)
|
||||
|
|
|
@ -7,15 +7,7 @@ class CreateBranchService < BaseService
|
|||
return failure if failure
|
||||
|
||||
new_branch = if source_project != @project
|
||||
repository.fetch_ref(
|
||||
source_project.repository.path_to_repo,
|
||||
"refs/heads/#{ref}",
|
||||
"refs/heads/#{branch_name}"
|
||||
)
|
||||
|
||||
repository.after_create_branch
|
||||
|
||||
repository.find_branch(branch_name)
|
||||
@project.fetch_ref(source_project, branch_name, ref)
|
||||
else
|
||||
repository.add_branch(current_user, branch_name, ref)
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ module Files
|
|||
validate
|
||||
|
||||
# Create new branch if it different from source_branch
|
||||
validate_target_branch if different_branch?
|
||||
ensure_target_branch if different_branch?
|
||||
|
||||
result = commit
|
||||
if result
|
||||
|
@ -71,6 +71,14 @@ module Files
|
|||
end
|
||||
end
|
||||
|
||||
def ensure_target_branch
|
||||
validate_target_branch
|
||||
|
||||
if @source_project != project
|
||||
@project.fetch_ref(@source_project, @target_branch, @source_branch)
|
||||
end
|
||||
end
|
||||
|
||||
def validate_target_branch
|
||||
result = ValidateNewBranchService.new(project, current_user).
|
||||
execute(@target_branch)
|
||||
|
|
Loading…
Reference in New Issue