Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
571f1dda
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 搜索 >>
提交
571f1dda
编写于
11月 22, 2017
作者:
J
Jacob Vosmaer (GitLab)
提交者:
Sean McGivern
11月 22, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add FetchSourceBranch Gitaly call
上级
6369db01
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
49 addition
and
11 deletion
+49
-11
GITALY_SERVER_VERSION
GITALY_SERVER_VERSION
+1
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+15
-5
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+9
-3
lib/gitlab/gitaly_client/repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+19
-0
lib/tasks/gitlab/gitaly.rake
lib/tasks/gitlab/gitaly.rake
+2
-0
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+1
-1
spec/requests/api/v3/merge_requests_spec.rb
spec/requests/api/v3/merge_requests_spec.rb
+1
-1
spec/tasks/gitlab/gitaly_rake_spec.rb
spec/tasks/gitlab/gitaly_rake_spec.rb
+1
-0
未找到文件。
GITALY_SERVER_VERSION
浏览文件 @
571f1dda
0.5
4
.0
0.5
5
.0
lib/gitlab/git/repository.rb
浏览文件 @
571f1dda
...
...
@@ -1058,12 +1058,11 @@ module Gitlab
end
def
fetch_source_branch!
(
source_repository
,
source_branch
,
local_ref
)
with_repo_branch_commit
(
source_repository
,
source_branch
)
do
|
commit
|
if
commit
write_ref
(
local_ref
,
commit
.
sha
)
true
Gitlab
::
GitalyClient
.
migrate
(
:fetch_source_branch
)
do
|
is_enabled
|
if
is_enabled
gitaly_repository_client
.
fetch_source_branch
(
source_repository
,
source_branch
,
local_ref
)
else
false
rugged_fetch_source_branch
(
source_repository
,
source_branch
,
local_ref
)
end
end
end
...
...
@@ -1216,6 +1215,17 @@ module Gitlab
private
def
rugged_fetch_source_branch
(
source_repository
,
source_branch
,
local_ref
)
with_repo_branch_commit
(
source_repository
,
source_branch
)
do
|
commit
|
if
commit
write_ref
(
local_ref
,
commit
.
sha
)
true
else
false
end
end
end
# Gitaly note: JV: Trying to get rid of the 'filter' option so we can implement this with 'git'.
def
branches_filter
(
filter:
nil
,
sort_by:
nil
)
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37464
...
...
lib/gitlab/gitaly_client.rb
浏览文件 @
571f1dda
...
...
@@ -75,6 +75,10 @@ module Gitlab
address
end
def
self
.
address_metadata
(
storage
)
Base64
.
strict_encode64
(
JSON
.
dump
({
storage
=>
{
'address'
=>
address
(
storage
),
'token'
=>
token
(
storage
)
}
}))
end
# All Gitaly RPC call sites should use GitalyClient.call. This method
# makes sure that per-request authentication headers are set.
#
...
...
@@ -89,18 +93,19 @@ module Gitlab
# kwargs.merge(deadline: Time.now + 10)
# end
#
def
self
.
call
(
storage
,
service
,
rpc
,
request
)
def
self
.
call
(
storage
,
service
,
rpc
,
request
,
remote_storage:
nil
)
start
=
Process
.
clock_gettime
(
Process
::
CLOCK_MONOTONIC
)
enforce_gitaly_request_limits
(
:call
)
kwargs
=
request_kwargs
(
storage
)
kwargs
=
request_kwargs
(
storage
,
remote_storage:
remote_storage
)
kwargs
=
yield
(
kwargs
)
if
block_given?
stub
(
service
,
storage
).
__send__
(
rpc
,
request
,
kwargs
)
# rubocop:disable GitlabSecurity/PublicSend
ensure
self
.
query_time
+=
Process
.
clock_gettime
(
Process
::
CLOCK_MONOTONIC
)
-
start
end
def
self
.
request_kwargs
(
storage
)
def
self
.
request_kwargs
(
storage
,
remote_storage:
nil
)
encoded_token
=
Base64
.
strict_encode64
(
token
(
storage
).
to_s
)
metadata
=
{
'authorization'
=>
"Bearer
#{
encoded_token
}
"
,
...
...
@@ -110,6 +115,7 @@ module Gitlab
feature_stack
=
Thread
.
current
[
:gitaly_feature_stack
]
feature
=
feature_stack
&&
feature_stack
[
0
]
metadata
[
'call_site'
]
=
feature
.
to_s
if
feature
metadata
[
'gitaly-servers'
]
=
address_metadata
(
remote_storage
)
if
remote_storage
{
metadata:
metadata
}
end
...
...
lib/gitlab/gitaly_client/repository_service.rb
浏览文件 @
571f1dda
...
...
@@ -65,6 +65,25 @@ module Gitlab
response
.
value
end
def
fetch_source_branch
(
source_repository
,
source_branch
,
local_ref
)
request
=
Gitaly
::
FetchSourceBranchRequest
.
new
(
repository:
@gitaly_repo
,
source_repository:
source_repository
.
gitaly_repository
,
source_branch:
source_branch
.
b
,
target_ref:
local_ref
.
b
)
response
=
GitalyClient
.
call
(
@storage
,
:repository_service
,
:fetch_source_branch
,
request
,
remote_storage:
source_repository
.
storage
)
response
.
result
end
end
end
end
lib/tasks/gitlab/gitaly.rake
浏览文件 @
571f1dda
...
...
@@ -78,6 +78,8 @@ namespace :gitlab do
config
[
:auth
]
=
{
token:
'secret'
}
if
Rails
.
env
.
test?
config
[
:'gitaly-ruby'
]
=
{
dir:
File
.
join
(
Dir
.
pwd
,
'ruby'
)
}
if
gitaly_ruby
config
[
:'gitlab-shell'
]
=
{
dir:
Gitlab
.
config
.
gitlab_shell
.
path
}
config
[
:bin_dir
]
=
Gitlab
.
config
.
gitaly
.
client_path
TOML
.
dump
(
config
)
end
...
...
spec/requests/api/merge_requests_spec.rb
浏览文件 @
571f1dda
...
...
@@ -628,7 +628,7 @@ describe API::MergeRequests do
context
'forked projects'
do
let!
(
:user2
)
{
create
(
:user
)
}
let!
(
:forked_project
)
{
fork_project
(
project
,
user2
)
}
let!
(
:forked_project
)
{
fork_project
(
project
,
user2
,
repository:
true
)
}
let!
(
:unrelated_project
)
{
create
(
:project
,
namespace:
create
(
:user
).
namespace
,
creator_id:
user2
.
id
)
}
before
do
...
...
spec/requests/api/v3/merge_requests_spec.rb
浏览文件 @
571f1dda
...
...
@@ -314,7 +314,7 @@ describe API::MergeRequests do
context
'forked projects'
do
let!
(
:user2
)
{
create
(
:user
)
}
let!
(
:forked_project
)
{
fork_project
(
project
,
user2
)
}
let!
(
:forked_project
)
{
fork_project
(
project
,
user2
,
repository:
true
)
}
let!
(
:unrelated_project
)
{
create
(
:project
,
namespace:
create
(
:user
).
namespace
,
creator_id:
user2
.
id
)
}
before
do
...
...
spec/tasks/gitlab/gitaly_rake_spec.rb
浏览文件 @
571f1dda
...
...
@@ -112,6 +112,7 @@ describe 'gitlab:gitaly namespace rake task' do
expected_output
=
<<~
TOML
# Gitaly storage configuration generated from
#{
Gitlab
.
config
.
source
}
on
#{
Time
.
current
.
to_s
(
:long
)
}
# This is in TOML format suitable for use in Gitaly's config.toml file.
bin_dir = "tmp/tests/gitaly"
socket_path = "/path/to/my.socket"
[gitlab-shell]
dir = "
#{
Gitlab
.
config
.
gitlab_shell
.
path
}
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录