Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
52bfd064
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,发现更多精彩内容 >>
提交
52bfd064
编写于
11月 14, 2017
作者:
A
Ahmad Sherif
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use relative git object paths to construct absolute ones before setting Env
上级
3730d89f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
11 deletion
+51
-11
lib/api/helpers/internal_helpers.rb
lib/api/helpers/internal_helpers.rb
+12
-0
lib/api/internal.rb
lib/api/internal.rb
+3
-1
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+36
-10
未找到文件。
lib/api/helpers/internal_helpers.rb
浏览文件 @
52bfd064
...
@@ -36,6 +36,18 @@ module API
...
@@ -36,6 +36,18 @@ module API
{}
{}
end
end
def
fix_git_env_repository_paths
(
env
,
repository_path
)
if
obj_dir_relative
=
env
[
'GIT_OBJECT_DIRECTORY_RELATIVE'
].
presence
env
[
'GIT_OBJECT_DIRECTORY'
]
=
File
.
join
(
repository_path
,
obj_dir_relative
)
end
if
alt_obj_dirs_relative
=
env
[
'GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE'
].
presence
env
[
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
]
=
alt_obj_dirs_relative
.
map
{
|
dir
|
File
.
join
(
repository_path
,
dir
)
}
end
env
end
def
log_user_activity
(
actor
)
def
log_user_activity
(
actor
)
commands
=
Gitlab
::
GitAccess
::
DOWNLOAD_COMMANDS
commands
=
Gitlab
::
GitAccess
::
DOWNLOAD_COMMANDS
...
...
lib/api/internal.rb
浏览文件 @
52bfd064
...
@@ -19,7 +19,9 @@ module API
...
@@ -19,7 +19,9 @@ module API
status
200
status
200
# Stores some Git-specific env thread-safely
# Stores some Git-specific env thread-safely
Gitlab
::
Git
::
Env
.
set
(
parse_env
)
env
=
parse_env
env
=
fix_git_env_repository_paths
(
env
,
repository_path
)
if
project
Gitlab
::
Git
::
Env
.
set
(
env
)
actor
=
actor
=
if
params
[
:key_id
]
if
params
[
:key_id
]
...
...
spec/requests/api/internal_spec.rb
浏览文件 @
52bfd064
...
@@ -203,18 +203,44 @@ describe API::Internal do
...
@@ -203,18 +203,44 @@ describe API::Internal do
end
end
context
'with env passed as a JSON'
do
context
'with env passed as a JSON'
do
it
'sets env in RequestStore'
do
context
'when relative path envs are not set'
do
expect
(
Gitlab
::
Git
::
Env
).
to
receive
(
:set
).
with
({
it
'sets env in RequestStore'
do
'GIT_OBJECT_DIRECTORY'
=>
'foo'
,
expect
(
Gitlab
::
Git
::
Env
).
to
receive
(
:set
).
with
({
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
=>
'bar'
'GIT_OBJECT_DIRECTORY'
=>
'foo'
,
})
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
=>
'bar'
})
push
(
key
,
project
.
wiki
,
env:
{
GIT_OBJECT_DIRECTORY
:
'foo'
,
GIT_ALTERNATE_OBJECT_DIRECTORIES
:
'bar'
}.
to_json
)
push
(
key
,
project
.
wiki
,
env:
{
expect
(
response
).
to
have_gitlab_http_status
(
200
)
GIT_OBJECT_DIRECTORY
:
'foo'
,
end
GIT_ALTERNATE_OBJECT_DIRECTORIES
:
'bar'
end
}.
to_json
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
context
'when relative path envs are set'
do
it
'sets env in RequestStore'
do
obj_dir_relative
=
'./objects'
alt_obj_dirs_relative
=
[
'./alt-objects-1'
,
'./alt-objects-2'
]
repo_path
=
project
.
wiki
.
repository
.
path_to_repo
expect
(
Gitlab
::
Git
::
Env
).
to
receive
(
:set
).
with
({
'GIT_OBJECT_DIRECTORY'
=>
File
.
join
(
repo_path
,
obj_dir_relative
),
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
=>
alt_obj_dirs_relative
.
map
{
|
d
|
File
.
join
(
repo_path
,
d
)
},
'GIT_OBJECT_DIRECTORY_RELATIVE'
=>
obj_dir_relative
,
'GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE'
=>
alt_obj_dirs_relative
})
push
(
key
,
project
.
wiki
,
env:
{
GIT_OBJECT_DIRECTORY
:
'foo'
,
GIT_ALTERNATE_OBJECT_DIRECTORIES
:
'bar'
,
GIT_OBJECT_DIRECTORY_RELATIVE
:
obj_dir_relative
,
GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE
:
alt_obj_dirs_relative
}.
to_json
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录