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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
9ff44c29
Commit
9ff44c29
authored
Dec 26, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate RemoteService.FetchInternalRemote Gitaly RPC
parent
fb583c4b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
30 deletions
+66
-30
GITALY_SERVER_VERSION
GITALY_SERVER_VERSION
+1
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+13
-13
lib/gitlab/gitaly_client/remote_service.rb
lib/gitlab/gitaly_client/remote_service.rb
+13
-0
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+26
-16
spec/lib/gitlab/gitaly_client/remote_service_spec.rb
spec/lib/gitlab/gitaly_client/remote_service_spec.rb
+13
-0
No files found.
GITALY_SERVER_VERSION
View file @
9ff44c29
0.6
5
.0
0.6
6
.0
lib/gitlab/git/repository.rb
View file @
9ff44c29
...
@@ -1154,23 +1154,13 @@ module Gitlab
...
@@ -1154,23 +1154,13 @@ module Gitlab
end
end
def
fetch_repository_as_mirror
(
repository
)
def
fetch_repository_as_mirror
(
repository
)
remote_name
=
"tmp-
#{
SecureRandom
.
hex
}
"
gitaly_migrate
(
:remote_fetch_internal_remote
)
do
|
is_enabled
|
# Notice that this feature flag is not for `fetch_repository_as_mirror`
# as a whole but for the fetching mechanism (file path or gitaly-ssh).
url
,
env
=
gitaly_migrate
(
:fetch_internal
)
do
|
is_enabled
|
if
is_enabled
if
is_enabled
repository
=
RemoteRepository
.
new
(
repository
)
unless
repository
.
is_a?
(
RemoteRepository
)
gitaly_remote_client
.
fetch_internal_remote
(
repository
)
[
GITALY_INTERNAL_URL
,
repository
.
fetch_env
]
else
else
[
repository
.
path
,
nil
]
rugged_fetch_repository_as_mirror
(
repository
)
end
end
end
end
add_remote
(
remote_name
,
url
,
mirror_refmap: :all_refs
)
fetch_remote
(
remote_name
,
env:
env
)
ensure
remove_remote
(
remote_name
)
end
end
def
blob_at
(
sha
,
path
)
def
blob_at
(
sha
,
path
)
...
@@ -1940,6 +1930,16 @@ module Gitlab
...
@@ -1940,6 +1930,16 @@ module Gitlab
false
false
end
end
def
rugged_fetch_repository_as_mirror
(
repository
)
remote_name
=
"tmp-
#{
SecureRandom
.
hex
}
"
repository
=
RemoteRepository
.
new
(
repository
)
unless
repository
.
is_a?
(
RemoteRepository
)
add_remote
(
remote_name
,
GITALY_INTERNAL_URL
,
mirror_refmap: :all_refs
)
fetch_remote
(
remote_name
,
env:
repository
.
fetch_env
)
ensure
remove_remote
(
remote_name
)
end
def
fetch_remote
(
remote_name
=
'origin'
,
env:
nil
)
def
fetch_remote
(
remote_name
=
'origin'
,
env:
nil
)
run_git
([
'fetch'
,
remote_name
],
env:
env
).
last
.
zero?
run_git
([
'fetch'
,
remote_name
],
env:
env
).
last
.
zero?
end
end
...
...
lib/gitlab/gitaly_client/remote_service.rb
View file @
9ff44c29
...
@@ -23,6 +23,19 @@ module Gitlab
...
@@ -23,6 +23,19 @@ module Gitlab
response
.
result
response
.
result
end
end
def
fetch_internal_remote
(
repository
)
request
=
Gitaly
::
FetchInternalRemoteRequest
.
new
(
repository:
@gitaly_repo
,
remote_repository:
repository
.
gitaly_repository
)
response
=
GitalyClient
.
call
(
@storage
,
:remote_service
,
:fetch_internal_remote
,
request
,
remote_storage:
repository
.
storage
)
response
.
result
end
end
end
end
end
end
end
spec/lib/gitlab/git/repository_spec.rb
View file @
9ff44c29
...
@@ -648,6 +648,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -648,6 +648,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
Gitlab
::
Shell
.
new
.
remove_repository
(
TestEnv
.
repos_path
,
'my_project'
)
Gitlab
::
Shell
.
new
.
remove_repository
(
TestEnv
.
repos_path
,
'my_project'
)
end
end
shared_examples
'repository mirror fecthing'
do
it
'fetches a repository as a mirror remote'
do
it
'fetches a repository as a mirror remote'
do
subject
subject
...
@@ -673,6 +674,15 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -673,6 +674,15 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
end
end
context
'with gitaly enabled'
do
it_behaves_like
'repository mirror fecthing'
end
context
'with gitaly enabled'
,
:skip_gitaly_mock
do
it_behaves_like
'repository mirror fecthing'
end
end
describe
'#remote_tags'
do
describe
'#remote_tags'
do
let
(
:remote_name
)
{
'upstream'
}
let
(
:remote_name
)
{
'upstream'
}
let
(
:target_commit_id
)
{
SeedRepo
::
Commit
::
ID
}
let
(
:target_commit_id
)
{
SeedRepo
::
Commit
::
ID
}
...
...
spec/lib/gitlab/gitaly_client/remote_service_spec.rb
View file @
9ff44c29
...
@@ -31,4 +31,17 @@ describe Gitlab::GitalyClient::RemoteService do
...
@@ -31,4 +31,17 @@ describe Gitlab::GitalyClient::RemoteService do
expect
(
client
.
remove_remote
(
remote_name
)).
to
be
(
true
)
expect
(
client
.
remove_remote
(
remote_name
)).
to
be
(
true
)
end
end
end
end
describe
'#fetch_internal_remote'
do
let
(
:remote_repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_MUTABLE_REPO_PATH
,
''
)
}
it
'sends an fetch_internal_remote message and returns the result value'
do
expect_any_instance_of
(
Gitaly
::
RemoteService
::
Stub
)
.
to
receive
(
:fetch_internal_remote
)
.
with
(
gitaly_request_with_path
(
storage_name
,
relative_path
),
kind_of
(
Hash
))
.
and_return
(
double
(
result:
true
))
expect
(
client
.
fetch_internal_remote
(
remote_repository
)).
to
be
(
true
)
end
end
end
end
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