Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
6bac612d
Commit
6bac612d
authored
Jan 16, 2019
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up Shell.fork_repository
Use project models instead of a list of parameters.
parent
82b6e537
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
33 deletions
+12
-33
app/workers/repository_fork_worker.rb
app/workers/repository_fork_worker.rb
+1
-3
lib/gitlab/shell.rb
lib/gitlab/shell.rb
+7
-14
spec/lib/gitlab/shell_spec.rb
spec/lib/gitlab/shell_spec.rb
+3
-8
spec/workers/repository_fork_worker_spec.rb
spec/workers/repository_fork_worker_spec.rb
+1
-8
No files found.
app/workers/repository_fork_worker.rb
View file @
6bac612d
...
...
@@ -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
...
...
lib/gitlab/shell.rb
View file @
6bac612d
...
...
@@ -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
...
...
spec/lib/gitlab/shell_spec.rb
View file @
6bac612d
...
...
@@ -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
...
...
spec/workers/repository_fork_worker_spec.rb
View file @
6bac612d
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment