Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9ff44c29
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9ff44c29
编写于
12月 26, 2017
作者:
A
Alejandro Rodríguez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Incorporate RemoteService.FetchInternalRemote Gitaly RPC
上级
fb583c4b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
30 deletion
+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
未找到文件。
GITALY_SERVER_VERSION
浏览文件 @
9ff44c29
0.6
5
.0
0.6
6
.0
lib/gitlab/git/repository.rb
浏览文件 @
9ff44c29
...
...
@@ -1154,23 +1154,13 @@ module Gitlab
end
def
fetch_repository_as_mirror
(
repository
)
remote_name
=
"tmp-
#{
SecureRandom
.
hex
}
"
# 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
|
gitaly_migrate
(
:remote_fetch_internal_remote
)
do
|
is_enabled
|
if
is_enabled
repository
=
RemoteRepository
.
new
(
repository
)
unless
repository
.
is_a?
(
RemoteRepository
)
[
GITALY_INTERNAL_URL
,
repository
.
fetch_env
]
gitaly_remote_client
.
fetch_internal_remote
(
repository
)
else
[
repository
.
path
,
nil
]
rugged_fetch_repository_as_mirror
(
repository
)
end
end
add_remote
(
remote_name
,
url
,
mirror_refmap: :all_refs
)
fetch_remote
(
remote_name
,
env:
env
)
ensure
remove_remote
(
remote_name
)
end
def
blob_at
(
sha
,
path
)
...
...
@@ -1940,6 +1930,16 @@ module Gitlab
false
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
)
run_git
([
'fetch'
,
remote_name
],
env:
env
).
last
.
zero?
end
...
...
lib/gitlab/gitaly_client/remote_service.rb
浏览文件 @
9ff44c29
...
...
@@ -23,6 +23,19 @@ module Gitlab
response
.
result
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
spec/lib/gitlab/git/repository_spec.rb
浏览文件 @
9ff44c29
...
...
@@ -648,29 +648,39 @@ describe Gitlab::Git::Repository, seed_helper: true do
Gitlab
::
Shell
.
new
.
remove_repository
(
TestEnv
.
repos_path
,
'my_project'
)
end
it
'fetches a repository as a mirror remote'
do
subject
shared_examples
'repository mirror fecthing'
do
it
'fetches a repository as a mirror remote'
do
subject
expect
(
refs
(
new_repository
.
path
)).
to
eq
(
refs
(
repository
.
path
))
end
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
}
"
}
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
.
rugged
.
references
.
create
(
keep_around_ref
,
sha
,
force:
true
)
repository
.
rugged
.
references
.
create
(
tmp_ref
,
sha
,
force:
true
)
end
before
do
repository
.
rugged
.
references
.
create
(
keep_around_ref
,
sha
,
force:
true
)
repository
.
rugged
.
references
.
create
(
tmp_ref
,
sha
,
force:
true
)
end
it
'includes the temporary and keep-around refs'
do
subject
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
)
expect
(
refs
(
new_repository
.
path
)).
to
include
(
keep_around_ref
)
expect
(
refs
(
new_repository
.
path
)).
to
include
(
tmp_ref
)
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
...
...
spec/lib/gitlab/gitaly_client/remote_service_spec.rb
浏览文件 @
9ff44c29
...
...
@@ -31,4 +31,17 @@ describe Gitlab::GitalyClient::RemoteService do
expect
(
client
.
remove_remote
(
remote_name
)).
to
be
(
true
)
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录