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
8cc82033
Commit
8cc82033
authored
Mar 05, 2020
by
James Fargher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ReplicateRepository Gitaly RPC
Minimum required to support a new RPC in gitaly client
parent
cc9eb19a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
5 deletions
+88
-5
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+6
-0
lib/gitlab/gitaly_client/repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+16
-0
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+48
-0
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
+18
-5
No files found.
lib/gitlab/git/repository.rb
View file @
8cc82033
...
@@ -152,6 +152,12 @@ module Gitlab
...
@@ -152,6 +152,12 @@ module Gitlab
end
end
end
end
def
replicate
(
source_repository
)
wrapped_gitaly_errors
do
gitaly_repository_client
.
replicate
(
source_repository
)
end
end
def
expire_has_local_branches_cache
def
expire_has_local_branches_cache
clear_memoization
(
:has_local_branches
)
clear_memoization
(
:has_local_branches
)
end
end
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
8cc82033
...
@@ -359,6 +359,22 @@ module Gitlab
...
@@ -359,6 +359,22 @@ module Gitlab
GitalyClient
.
call
(
@storage
,
:repository_service
,
:remove_repository
,
request
,
timeout:
GitalyClient
.
long_timeout
)
GitalyClient
.
call
(
@storage
,
:repository_service
,
:remove_repository
,
request
,
timeout:
GitalyClient
.
long_timeout
)
end
end
def
replicate
(
source_repository
)
request
=
Gitaly
::
ReplicateRepositoryRequest
.
new
(
repository:
@gitaly_repo
,
source:
source_repository
.
gitaly_repository
)
GitalyClient
.
call
(
@storage
,
:repository_service
,
:replicate_repository
,
request
,
remote_storage:
source_repository
.
storage
,
timeout:
GitalyClient
.
long_timeout
)
end
private
private
def
search_results_from_response
(
gitaly_response
,
options
=
{})
def
search_results_from_response
(
gitaly_response
,
options
=
{})
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
8cc82033
...
@@ -2181,4 +2181,52 @@ describe Gitlab::Git::Repository, :seed_helper do
...
@@ -2181,4 +2181,52 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
end
end
end
end
describe
'#replicate'
do
let
(
:second_storage_path
)
{
'tmp/tests/second_storage'
}
let
(
:new_repository
)
do
Gitlab
::
Git
::
Repository
.
new
(
'test_second_storage'
,
TEST_REPO_PATH
,
''
,
'group/project'
)
end
let
(
:new_repository_path
)
{
File
.
join
(
second_storage_path
,
new_repository
.
relative_path
)
}
subject
{
new_repository
.
replicate
(
repository
)
}
before
do
stub_storage_settings
(
'test_second_storage'
=>
{
'gitaly_address'
=>
Gitlab
.
config
.
repositories
.
storages
.
default
.
gitaly_address
,
'path'
=>
second_storage_path
})
# TODO: SetupHelper should be creating this
FileUtils
.
mkdir_p
(
"tmp/tests/second_storage"
)
unless
File
.
exist?
(
"tmp/tests/second_storage"
)
Gitlab
::
Shell
.
new
.
create_repository
(
'test_second_storage'
,
TEST_REPO_PATH
,
'group/project'
)
end
after
do
Gitlab
::
Shell
.
new
.
remove_repository
(
'test_second_storage'
,
TEST_REPO_PATH
)
end
it
'mirrors the source repository'
do
subject
expect
(
refs
(
new_repository_path
)).
to
eq
(
refs
(
repository_path
))
end
context
'with keep-around refs'
do
let
(
:sha
)
{
SeedRepo
::
Commit
::
ID
}
let
(
:keep_around_ref
)
{
"refs/keep-around/
#{
sha
}
"
}
let
(
:tmp_ref
)
{
"refs/tmp/
#{
SecureRandom
.
hex
}
"
}
before
do
repository
.
write_ref
(
keep_around_ref
,
sha
)
repository
.
write_ref
(
tmp_ref
,
sha
)
end
it
'includes the temporary and keep-around refs'
do
subject
expect
(
refs
(
new_repository_path
)).
to
include
(
keep_around_ref
)
expect
(
refs
(
new_repository_path
)).
to
include
(
tmp_ref
)
end
end
end
end
end
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
View file @
8cc82033
...
@@ -275,7 +275,18 @@ describe Gitlab::GitalyClient::RepositoryService do
...
@@ -275,7 +275,18 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
end
end
describe
'remove'
do
describe
'#rename'
do
it
'sends a rename_repository message'
do
expect_any_instance_of
(
Gitaly
::
RepositoryService
::
Stub
)
.
to
receive
(
:rename_repository
)
.
with
(
gitaly_request_with_path
(
storage_name
,
relative_path
),
kind_of
(
Hash
))
.
and_return
(
double
(
value:
true
))
client
.
rename
(
'some/new/path'
)
end
end
describe
'#remove'
do
it
'sends a remove_repository message'
do
it
'sends a remove_repository message'
do
expect_any_instance_of
(
Gitaly
::
RepositoryService
::
Stub
)
expect_any_instance_of
(
Gitaly
::
RepositoryService
::
Stub
)
.
to
receive
(
:remove_repository
)
.
to
receive
(
:remove_repository
)
...
@@ -286,14 +297,16 @@ describe Gitlab::GitalyClient::RepositoryService do
...
@@ -286,14 +297,16 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
end
end
describe
'rename'
do
describe
'#replicate'
do
it
'sends a rename_repository message'
do
let
(
:source_repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_MUTABLE_REPO_PATH
,
''
,
'group/project'
)
}
it
'sends a replicate_repository message'
do
expect_any_instance_of
(
Gitaly
::
RepositoryService
::
Stub
)
expect_any_instance_of
(
Gitaly
::
RepositoryService
::
Stub
)
.
to
receive
(
:re
nam
e_repository
)
.
to
receive
(
:re
plicat
e_repository
)
.
with
(
gitaly_request_with_path
(
storage_name
,
relative_path
),
kind_of
(
Hash
))
.
with
(
gitaly_request_with_path
(
storage_name
,
relative_path
),
kind_of
(
Hash
))
.
and_return
(
double
(
value:
true
))
.
and_return
(
double
(
value:
true
))
client
.
re
name
(
'some/new/path'
)
client
.
re
plicate
(
source_repository
)
end
end
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