Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e65bc0f1
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,发现更多精彩内容 >>
提交
e65bc0f1
编写于
8月 24, 2016
作者:
L
Lin Jen-Shin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Path could also have slashes! Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5142#note_14347729
上级
bc3493f9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
10 deletion
+36
-10
app/controllers/projects/artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+11
-3
app/helpers/gitlab_routing_helper.rb
app/helpers/gitlab_routing_helper.rb
+3
-2
config/routes.rb
config/routes.rb
+2
-3
spec/requests/projects/artifacts_controller_spec.rb
spec/requests/projects/artifacts_controller_spec.rb
+20
-2
未找到文件。
app/controllers/projects/artifacts_controller.rb
浏览文件 @
e65bc0f1
class
Projects::ArtifactsController
<
Projects
::
ApplicationController
include
ExtractsPath
layout
'project'
before_action
:authorize_read_build!
before_action
:authorize_update_build!
,
only:
[
:keep
]
...
...
@@ -35,7 +37,8 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
def
latest_succeeded
target_path
=
artifacts_action_path
(
params
[
:path
],
project
,
build
)
path
=
ref_name_and_path
.
last
target_path
=
artifacts_action_path
(
path
,
project
,
build
)
if
target_path
redirect_to
(
target_path
)
...
...
@@ -59,13 +62,18 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
def
build_from_ref
if
params
[
:ref_name
]
builds
=
project
.
latest_successful_builds_for
(
params
[
:ref_name
])
if
params
[
:ref_name_and_path
]
ref_name
=
ref_name_and_path
.
first
builds
=
project
.
latest_successful_builds_for
(
ref_name
)
builds
.
find_by
(
name:
params
[
:job
])
end
end
def
ref_name_and_path
@ref_name_and_path
||=
extract_ref
(
params
[
:ref_name_and_path
])
end
def
artifacts_file
@artifacts_file
||=
build
.
artifacts_file
end
...
...
app/helpers/gitlab_routing_helper.rb
浏览文件 @
e65bc0f1
...
...
@@ -153,9 +153,10 @@ module GitlabRoutingHelper
# Artifacts
def
artifacts_action_path
(
path
,
project
,
build
)
args
=
[
project
.
namespace
,
project
,
build
]
action
,
path_params
=
path
.
split
(
'/'
,
2
)
args
=
[
project
.
namespace
,
project
,
build
,
path_params
]
case
path
case
action
when
'download'
download_namespace_project_build_artifacts_path
(
*
args
)
when
'browse'
...
...
config/routes.rb
浏览文件 @
e65bc0f1
...
...
@@ -787,9 +787,8 @@ Rails.application.routes.draw do
resources
:artifacts
,
only:
[]
do
collection
do
get
:latest_succeeded
,
path:
':ref_name/*path'
,
format:
false
,
constraints:
{
ref_name:
/.+/
}
# could have /
path:
'*ref_name_and_path'
,
format:
false
end
end
end
...
...
spec/requests/projects/artifacts_controller_spec.rb
浏览文件 @
e65bc0f1
...
...
@@ -26,8 +26,7 @@ describe Projects::ArtifactsController do
latest_succeeded_namespace_project_artifacts_path
(
project
.
namespace
,
project
,
ref
,
path
,
[
ref
,
path
].
join
(
'/'
),
job:
job
)
end
...
...
@@ -94,6 +93,25 @@ describe Projects::ArtifactsController do
it_behaves_like
'redirect to the build'
end
context
'with branch name and path containing slashes'
do
before
do
pipeline
.
update
(
ref:
'improve/awesome'
,
sha:
project
.
commit
(
'improve/awesome'
).
sha
)
get
path_from_ref
(
'improve/awesome'
,
build
.
name
,
'file/README.md'
)
end
it
'redirects'
do
path
=
file_namespace_project_build_artifacts_path
(
project
.
namespace
,
project
,
build
,
'README.md'
)
expect
(
response
).
to
redirect_to
(
path
)
end
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录