Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f07e1876
Commit
f07e1876
authored
May 23, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use controllers to redirect
parent
41490904
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
44 deletions
+100
-44
app/controllers/projects/build_artifacts_controller.rb
app/controllers/projects/build_artifacts_controller.rb
+49
-0
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+27
-0
lib/gitlab/routes/legacy_builds.rb
lib/gitlab/routes/legacy_builds.rb
+24
-44
No files found.
app/controllers/projects/build_artifacts_controller.rb
0 → 100644
View file @
f07e1876
class
Projects::BuildArtifactsController
<
Projects
::
ApplicationController
include
ExtractsPath
include
RendersBlob
before_action
:extract_ref_name_and_path
def
download
redirect_to
download_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
job
)
end
def
browse
redirect_to
browse_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
job
,
path:
params
[
:path
])
end
def
file
redirect_to
file_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
job
,
path:
params
[
:path
])
end
def
raw
redirect_to
raw_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
job
,
path:
params
[
:path
])
end
def
latest_succeeded
redirect_to
latest_succeeded_namespace_project_artifacts_path
(
project
.
namespace
,
project
,
job
,
ref_name_and_path:
params
[
:ref_name_and_path
],
job:
params
[
:job
])
end
private
def
extract_ref_name_and_path
return
unless
params
[
:ref_name_and_path
]
@ref_name
,
@path
=
extract_ref
(
params
[
:ref_name_and_path
])
end
def
job
@job
||=
job_from_id
||
job_from_ref
end
def
job_from_id
project
.
builds
.
find_by
(
id:
params
[
:build_id
])
if
params
[
:build_id
]
end
def
job_from_ref
return
unless
@ref_name
jobs
=
project
.
latest_successful_builds_for
(
@ref_name
)
jobs
.
find_by
(
name:
params
[
:job
])
end
end
app/controllers/projects/builds_controller.rb
0 → 100644
View file @
f07e1876
class
Projects::BuildsController
<
Projects
::
ApplicationController
def
index
redirect_to
namespace_project_jobs_path
(
project
.
namespace
,
project
)
end
def
show
redirect_to
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
def
trace
redirect_to
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
job
,
format:
params
[
:format
])
end
def
status
redirect_to
status_namespace_project_job_path
(
project
.
namespace
,
project
,
job
,
format:
params
[
:format
])
end
def
raw
redirect_to
raw_namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
private
def
job
@job
||=
project
.
builds
.
find
(
params
[
:id
])
end
end
lib/gitlab/routes/legacy_builds.rb
View file @
f07e1876
module
Gitlab
module
Gitlab
module
Routes
module
Routes
class
LegacyBuilds
class
LegacyBuilds
...
@@ -10,52 +9,33 @@ module Gitlab
...
@@ -10,52 +9,33 @@ module Gitlab
end
end
def
draw
def
draw
redirect_artifacts
=
@map
.
redirect
(
&
method
(
:redirect_artifacts
))
@map
.
instance_eval
do
redirect_builds
=
@map
.
redirect
(
&
method
(
:redirect_builds
))
resources
:builds
,
only:
[
:index
,
:show
],
constraints:
{
id:
/\d+/
}
do
collection
do
@map
.
get
'/builds(/:id)/artifacts/*action'
,
to:
redirect_artifacts
,
resources
:artifacts
,
only:
[],
controller:
'build_artifacts'
do
as:
'legacy_artifacts'
,
collection
do
format:
false
get
:latest_succeeded
,
path:
'*ref_name_and_path'
,
@map
.
get
'/builds(/:id(/*action))'
,
to:
redirect_builds
,
format:
false
as:
'legacy_builds'
,
end
format:
false
end
end
end
private
member
do
get
:status
def
redirect_artifacts
(
params
,
req
)
get
:trace
,
defaults:
{
format:
'json'
}
if
params
[
:id
]
get
:raw
project
=
fake_project
(
*
params
.
values_at
(
:namespace_id
,
:project_id
))
end
artifacts_action_path
(
params
[
:action
],
project
,
params
[
:id
])
resource
:artifacts
,
only:
[],
controller:
'build_artifacts'
do
else
get
:download
latest_succeeded_namespace_project_artifacts_path
(
params
[
:namespace_id
],
params
[
:project_id
],
params
[
:action
],
job:
req
.
GET
[
:job
])
get
:browse
,
path:
'browse(/*path)'
,
format:
false
end
get
:file
,
path:
'file/*path'
,
format:
false
end
get
:raw
,
path:
'raw/*path'
,
format:
false
end
def
redirect_builds
(
params
,
req
)
args
=
params
.
values_at
(
:namespace_id
,
:project_id
,
:id
).
compact
if
params
[
:id
]
case
params
[
:action
]
when
'status'
status_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
when
'trace'
trace_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
when
'raw'
raw_namespace_project_job_path
(
*
args
)
else
# show
namespace_project_job_path
(
*
args
)
end
end
else
# index
namespace_project_jobs_path
(
*
args
)
end
end
end
end
def
fake_project
(
namespace_id
,
project_id
)
Struct
.
new
(
:namespace
,
:to_param
).
new
(
namespace_id
,
project_id
)
end
end
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