Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
d86751d8
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,发现更多精彩内容 >>
提交
d86751d8
编写于
1月 17, 2018
作者:
A
Alejandro Rodríguez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Incorporate Gitaly's RemoteService.UpdateRemoteMirror RPC
上级
7fa0a3e7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
61 addition
and
6 deletion
+61
-6
GITALY_SERVER_VERSION
GITALY_SERVER_VERSION
+1
-1
lib/gitlab/git/remote_mirror.rb
lib/gitlab/git/remote_mirror.rb
+19
-5
lib/gitlab/gitaly_client/remote_service.rb
lib/gitlab/gitaly_client/remote_service.rb
+27
-0
spec/lib/gitlab/gitaly_client/remote_service_spec.rb
spec/lib/gitlab/gitaly_client/remote_service_spec.rb
+14
-0
未找到文件。
GITALY_SERVER_VERSION
浏览文件 @
d86751d8
0.7
0
.0
0.7
2
.0
lib/gitlab/git/remote_mirror.rb
浏览文件 @
d86751d8
...
...
@@ -6,7 +6,23 @@ module Gitlab
@ref_name
=
ref_name
end
def
update
(
only_branches_matching:
[],
only_tags_matching:
[])
def
update
(
only_branches_matching:
[])
@repository
.
gitaly_migrate
(
:remote_update_remote_mirror
)
do
|
is_enabled
|
if
is_enabled
gitaly_update
(
only_branches_matching
)
else
rugged_update
(
only_branches_matching
)
end
end
end
private
def
gitaly_update
(
only_branches_matching
)
@repository
.
gitaly_remote_client
.
update_remote_mirror
(
@ref_name
,
only_branches_matching
)
end
def
rugged_update
(
only_branches_matching
)
local_branches
=
refs_obj
(
@repository
.
local_branches
,
only_refs_matching:
only_branches_matching
)
remote_branches
=
refs_obj
(
@repository
.
remote_branches
(
@ref_name
),
only_refs_matching:
only_branches_matching
)
...
...
@@ -15,8 +31,8 @@ module Gitlab
delete_refs
(
local_branches
,
remote_branches
)
local_tags
=
refs_obj
(
@repository
.
tags
,
only_refs_matching:
only_tags_matching
)
remote_tags
=
refs_obj
(
@repository
.
remote_tags
(
@ref_name
)
,
only_refs_matching:
only_tags_matching
)
local_tags
=
refs_obj
(
@repository
.
tags
)
remote_tags
=
refs_obj
(
@repository
.
remote_tags
(
@ref_name
))
updated_tags
=
changed_refs
(
local_tags
,
remote_tags
)
@repository
.
push_remote_branches
(
@ref_name
,
updated_tags
.
keys
)
if
updated_tags
.
present?
...
...
@@ -24,8 +40,6 @@ module Gitlab
delete_refs
(
local_tags
,
remote_tags
)
end
private
def
refs_obj
(
refs
,
only_refs_matching:
[])
refs
.
each_with_object
({})
do
|
ref
,
refs
|
next
if
only_refs_matching
.
present?
&&
!
only_refs_matching
.
include?
(
ref
.
name
)
...
...
lib/gitlab/gitaly_client/remote_service.rb
浏览文件 @
d86751d8
module
Gitlab
module
GitalyClient
class
RemoteService
MAX_MSG_SIZE
=
128
.
kilobytes
.
freeze
def
initialize
(
repository
)
@repository
=
repository
@gitaly_repo
=
repository
.
gitaly_repository
...
...
@@ -38,6 +40,31 @@ module Gitlab
response
.
result
end
def
update_remote_mirror
(
ref_name
,
only_branches_matching
)
req_enum
=
Enumerator
.
new
do
|
y
|
y
.
yield
Gitaly
::
UpdateRemoteMirrorRequest
.
new
(
repository:
@gitaly_repo
,
ref_name:
ref_name
)
current_size
=
0
slices
=
only_branches_matching
.
slice_before
do
|
branch_name
|
current_size
+=
branch_name
.
bytesize
next
false
if
current_size
<
MAX_MSG_SIZE
current_size
=
0
end
slices
.
each
do
|
slice
|
y
.
yield
Gitaly
::
UpdateRemoteMirrorRequest
.
new
(
only_branches_matching:
slice
)
end
end
GitalyClient
.
call
(
@storage
,
:remote_service
,
:update_remote_mirror
,
req_enum
)
end
end
end
end
spec/lib/gitlab/gitaly_client/remote_service_spec.rb
浏览文件 @
d86751d8
...
...
@@ -44,4 +44,18 @@ describe Gitlab::GitalyClient::RemoteService do
expect
(
client
.
fetch_internal_remote
(
remote_repository
)).
to
be
(
true
)
end
end
describe
'#update_remote_mirror'
do
let
(
:ref_name
)
{
'remote_mirror_1'
}
let
(
:only_branches_matching
)
{
[
'my-branch'
,
'master'
]
}
it
'sends an update_remote_mirror message'
do
expect_any_instance_of
(
Gitaly
::
RemoteService
::
Stub
)
.
to
receive
(
:update_remote_mirror
)
.
with
(
kind_of
(
Enumerator
),
kind_of
(
Hash
))
.
and_return
(
double
(
:update_remote_mirror_response
))
client
.
update_remote_mirror
(
ref_name
,
only_branches_matching
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录