BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e65bc0f1
Commit
e65bc0f1
authored
Aug 24, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Path could also have slashes! Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5142#note_14347729
parent
bc3493f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
10 deletions
+36
-10
artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+11
-3
gitlab_routing_helper.rb
app/helpers/gitlab_routing_helper.rb
+3
-2
routes.rb
config/routes.rb
+2
-3
artifacts_controller_spec.rb
spec/requests/projects/artifacts_controller_spec.rb
+20
-2
No files found.
app/controllers/projects/artifacts_controller.rb
View file @
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
View file @
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
View file @
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
View file @
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment