Commit 6bac612d authored by Stan Hu's avatar Stan Hu

Clean up Shell.fork_repository

Use project models instead of a list of parameters.
parent 82b6e537
......@@ -25,9 +25,7 @@ class RepositoryForkWorker
Gitlab::Metrics.add_event(:fork_repository)
result = gitlab_shell.fork_repository(
source_project.repository_storage, source_project.disk_path, source_project.full_path,
target_project.repository_storage, target_project.disk_path, target_project.full_path)
result = gitlab_shell.fork_repository(source_project, target_project)
raise "Unable to fork project #{target_project.id} for repository #{source_project.disk_path} -> #{target_project.disk_path}" unless result
......
......@@ -126,20 +126,13 @@ module Gitlab
end
# Fork repository to new path
# forked_from_storage - forked-from project's storage name
# forked_from_disk_path - project disk relative path
# forked_to_storage - forked-to project's storage name
# forked_to_disk_path - forked project disk relative path
#
# Ex.
# fork_repository("nfs-file06", "gitlab/gitlab-ci", "nfs-file07", "new-namespace/gitlab-ci")
def fork_repository(
forked_from_storage, forked_from_disk_path, forked_from_project_name,
forked_to_storage, forked_to_disk_path, forked_to_project_name)
forked_from_relative_path = "#{forked_from_disk_path}.git"
fork_args = [forked_to_storage, "#{forked_to_disk_path}.git", forked_to_project_name]
GitalyGitlabProjects.new(forked_from_storage, forked_from_relative_path, forked_from_project_name).fork_repository(*fork_args)
# source_project - forked-from Project
# target_project - forked-to Project
def fork_repository(source_project, target_project)
forked_from_relative_path = "#{source_project.disk_path}.git"
fork_args = [target_project.repository_storage, "#{target_project.disk_path}.git", target_project.full_path]
GitalyGitlabProjects.new(source_project.repository_storage, forked_from_relative_path, source_project.full_path).fork_repository(*fork_args)
end
# Removes a repository from file system, using rm_diretory which is an alias
......
......@@ -474,15 +474,10 @@ describe Gitlab::Shell do
end
describe '#fork_repository' do
let(:target_project) { create(:project) }
subject do
gitlab_shell.fork_repository(
project.repository_storage,
project.disk_path,
project.full_path,
'nfs-file05',
'fork/path',
'fork/path'
)
gitlab_shell.fork_repository(project, target_project)
end
it 'returns true when the command succeeds' do
......
......@@ -24,14 +24,7 @@ describe RepositoryForkWorker do
end
def expect_fork_repository
expect(shell).to receive(:fork_repository).with(
'default',
project.disk_path,
project.full_path,
forked_project.repository_storage,
forked_project.disk_path,
forked_project.full_path
)
expect(shell).to receive(:fork_repository).with(project, forked_project)
end
describe 'when a worker was reset without cleanup' do
......
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