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
8cbfe3ae
Unverified
Commit
8cbfe3ae
authored
Oct 03, 2017
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redirect to pages daemon
parent
ca0e3904
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
102 additions
and
55 deletions
+102
-55
artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+11
-7
artifact_helper.rb
app/helpers/artifact_helper.rb
+0
-31
artifact_blob.rb
app/models/ci/artifact_blob.rb
+24
-1
routable.rb
app/models/concerns/routable.rb
+4
-0
_tree_file.html.haml
app/views/projects/artifacts/_tree_file.html.haml
+2
-2
1_settings.rb
config/initializers/1_settings.rb
+10
-9
artifacts_controller_spec.rb
spec/controllers/projects/artifacts_controller_spec.rb
+9
-4
ci_build_artifacts.zip
spec/fixtures/ci_build_artifacts.zip
+0
-0
artifact_blob_spec.rb
spec/models/ci/artifact_blob_spec.rb
+42
-1
No files found.
app/controllers/projects/artifacts_controller.rb
View file @
8cbfe3ae
...
@@ -29,13 +29,17 @@ class Projects::ArtifactsController < Projects::ApplicationController
...
@@ -29,13 +29,17 @@ class Projects::ArtifactsController < Projects::ApplicationController
blob
=
@entry
.
blob
blob
=
@entry
.
blob
conditionally_expand_blob
(
blob
)
conditionally_expand_blob
(
blob
)
respond_to
do
|
format
|
if
blob
.
external_link?
format
.
html
do
redirect_to
blob
.
external_url
(
@project
,
build
)
render
'file'
else
end
respond_to
do
|
format
|
format
.
html
do
format
.
json
do
render
'file'
render_blob_json
(
blob
)
end
format
.
json
do
render_blob_json
(
blob
)
end
end
end
end
end
end
end
...
...
app/helpers/artifact_helper.rb
deleted
100644 → 0
View file @
ca0e3904
module
ArtifactHelper
include
GitlabRoutingHelper
def
link_to_artifact
(
project
,
job
,
file
)
if
external_url?
(
file
.
blob
)
html_artifact_url
(
project
,
job
,
file
.
blob
)
else
file_project_job_artifacts_path
(
project
,
job
,
path:
file
.
path
)
end
end
def
external_url?
(
blob
)
blob
.
name
.
end_with?
(
".html"
)
&&
pages_config
.
enabled
&&
pages_config
.
artifacts_server
end
private
def
html_artifact_url
(
project
,
job
,
blob
)
http
=
pages_config
.
https
?
"https://"
:
"http://"
domain
=
"
#{
project
.
namespace
.
to_param
}
.
#{
pages_config
.
host
}
/"
path
=
"-/jobs/
#{
job
.
id
}
/artifacts/
#{
blob
.
path
}
"
http
+
domain
+
path
end
def
pages_config
Gitlab
.
config
.
pages
end
end
app/models/ci/artifact_blob.rb
View file @
8cbfe3ae
...
@@ -2,6 +2,8 @@ module Ci
...
@@ -2,6 +2,8 @@ module Ci
class
ArtifactBlob
class
ArtifactBlob
include
BlobLike
include
BlobLike
EXTENTIONS_SERVED_BY_PAGES
=
%w[.html .htm .txt]
.
freeze
attr_reader
:entry
attr_reader
:entry
def
initialize
(
entry
)
def
initialize
(
entry
)
...
@@ -17,6 +19,7 @@ module Ci
...
@@ -17,6 +19,7 @@ module Ci
def
size
def
size
entry
.
metadata
[
:size
]
entry
.
metadata
[
:size
]
end
end
alias_method
:external_size
,
:size
def
data
def
data
"Build artifact
#{
path
}
"
"Build artifact
#{
path
}
"
...
@@ -30,6 +33,26 @@ module Ci
...
@@ -30,6 +33,26 @@ module Ci
:build_artifact
:build_artifact
end
end
alias_method
:external_size
,
:size
def
external_url
(
project
,
job
)
return
unless
external_link?
components
=
project
.
full_path_components
components
<<
"-/jobs/
#{
job
.
id
}
/artifacts/file/
#{
path
}
"
artifact_path
=
components
[
1
..-
1
].
join
(
'/'
)
"
#{
pages_config
.
protocol
}
://
#{
components
[
0
]
}
.
#{
pages_config
.
host
}
/
#{
artifact_path
}
"
end
def
external_link?
pages_config
.
enabled
&&
pages_config
.
artifacts_server
&&
EXTENTIONS_SERVED_BY_PAGES
.
include?
(
File
.
extname
(
name
))
end
private
def
pages_config
Gitlab
.
config
.
pages
end
end
end
end
end
app/models/concerns/routable.rb
View file @
8cbfe3ae
...
@@ -106,6 +106,10 @@ module Routable
...
@@ -106,6 +106,10 @@ module Routable
RequestStore
[
full_path_key
]
||=
uncached_full_path
RequestStore
[
full_path_key
]
||=
uncached_full_path
end
end
def
full_path_components
full_path
.
split
(
'/'
)
end
def
expires_full_path_cache
def
expires_full_path_cache
RequestStore
.
delete
(
full_path_key
)
if
RequestStore
.
active?
RequestStore
.
delete
(
full_path_key
)
if
RequestStore
.
active?
@full_path
=
nil
@full_path
=
nil
...
...
app/views/projects/artifacts/_tree_file.html.haml
View file @
8cbfe3ae
-
blob
=
file
.
blob
-
blob
=
file
.
blob
-
is_external_link
=
external_link?
(
blob
)
-
is_external_link
=
blob
.
external_link?
-
path_to_file
=
link_to_artifact
(
@project
,
@build
,
file
)
-
path_to_file
=
file_project_job_artifacts_path
(
@project
,
@build
,
path:
file
.
path
)
%tr
.tree-item.js-artifact-tree-row
{
data:
{
link:
path_to_file
,
external_link:
"#{is_external_link}"
}
}
%tr
.tree-item.js-artifact-tree-row
{
data:
{
link:
path_to_file
,
external_link:
"#{is_external_link}"
}
}
%td
.tree-item-file-name
%td
.tree-item-file-name
...
...
config/initializers/1_settings.rb
View file @
8cbfe3ae
...
@@ -316,15 +316,16 @@ Settings.registry['path'] = Settings.absolute(Settings.registry['path
...
@@ -316,15 +316,16 @@ Settings.registry['path'] = Settings.absolute(Settings.registry['path
# Pages
# Pages
#
#
Settings
[
'pages'
]
||=
Settingslogic
.
new
({})
Settings
[
'pages'
]
||=
Settingslogic
.
new
({})
Settings
.
pages
[
'enabled'
]
=
false
if
Settings
.
pages
[
'enabled'
].
nil?
Settings
.
pages
[
'enabled'
]
=
false
if
Settings
.
pages
[
'enabled'
].
nil?
Settings
.
pages
[
'path'
]
=
Settings
.
absolute
(
Settings
.
pages
[
'path'
]
||
File
.
join
(
Settings
.
shared
[
'path'
],
"pages"
))
Settings
.
pages
[
'path'
]
=
Settings
.
absolute
(
Settings
.
pages
[
'path'
]
||
File
.
join
(
Settings
.
shared
[
'path'
],
"pages"
))
Settings
.
pages
[
'https'
]
=
false
if
Settings
.
pages
[
'https'
].
nil?
Settings
.
pages
[
'https'
]
=
false
if
Settings
.
pages
[
'https'
].
nil?
Settings
.
pages
[
'host'
]
||=
"example.com"
Settings
.
pages
[
'host'
]
||=
"example.com"
Settings
.
pages
[
'port'
]
||=
Settings
.
pages
.
https
?
443
:
80
Settings
.
pages
[
'port'
]
||=
Settings
.
pages
.
https
?
443
:
80
Settings
.
pages
[
'protocol'
]
||=
Settings
.
pages
.
https
?
"https"
:
"http"
Settings
.
pages
[
'protocol'
]
||=
Settings
.
pages
.
https
?
"https"
:
"http"
Settings
.
pages
[
'url'
]
||=
Settings
.
__send__
(
:build_pages_url
)
Settings
.
pages
[
'url'
]
||=
Settings
.
__send__
(
:build_pages_url
)
Settings
.
pages
[
'external_http'
]
||=
false
unless
Settings
.
pages
[
'external_http'
].
present?
Settings
.
pages
[
'external_http'
]
||=
false
unless
Settings
.
pages
[
'external_http'
].
present?
Settings
.
pages
[
'external_https'
]
||=
false
unless
Settings
.
pages
[
'external_https'
].
present?
Settings
.
pages
[
'external_https'
]
||=
false
unless
Settings
.
pages
[
'external_https'
].
present?
Settings
.
pages
[
'artifacts_server'
]
||=
Settings
.
pages
[
'enabled'
]
#
#
# Git LFS
# Git LFS
...
...
spec/controllers/projects/artifacts_controller_spec.rb
View file @
8cbfe3ae
require
'spec_helper'
require
'spec_helper'
describe
Projects
::
ArtifactsController
do
describe
Projects
::
ArtifactsController
do
l
et
(
:user
)
{
create
(
:user
)
}
s
et
(
:user
)
{
create
(
:user
)
}
l
et
(
:project
)
{
create
(
:project
,
:repository
)
}
s
et
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:pipeline
)
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
create
(
:ci_pipeline
,
...
@@ -15,7 +15,7 @@ describe Projects::ArtifactsController do
...
@@ -15,7 +15,7 @@ describe Projects::ArtifactsController do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
before
do
before
do
project
.
team
<<
[
user
,
:developer
]
project
.
add_developer
(
user
)
sign_in
(
user
)
sign_in
(
user
)
end
end
...
@@ -47,11 +47,16 @@ describe Projects::ArtifactsController do
...
@@ -47,11 +47,16 @@ describe Projects::ArtifactsController do
end
end
describe
'GET file'
do
describe
'GET file'
do
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:artifacts_server
).
and_return
(
true
)
end
context
'when the file exists'
do
context
'when the file exists'
do
it
'renders the file view'
do
it
'renders the file view'
do
get
:file
,
namespace_id:
project
.
namespace
,
project_id:
project
,
job_id:
job
,
path:
'ci_artifacts.txt'
get
:file
,
namespace_id:
project
.
namespace
,
project_id:
project
,
job_id:
job
,
path:
'ci_artifacts.txt'
expect
(
response
).
to
render_template
(
'projects/artifacts/file'
)
expect
(
response
).
to
have_http_status
(
302
)
end
end
end
end
...
...
spec/fixtures/ci_build_artifacts.zip
View file @
8cbfe3ae
No preview for this file type
spec/models/ci/artifact_blob_spec.rb
View file @
8cbfe3ae
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
ArtifactBlob
do
describe
Ci
::
ArtifactBlob
do
l
et
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
s
et
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
let
(
:entry
)
{
build
.
artifacts_metadata_entry
(
'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
)
}
let
(
:entry
)
{
build
.
artifacts_metadata_entry
(
'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
)
}
subject
{
described_class
.
new
(
entry
)
}
subject
{
described_class
.
new
(
entry
)
}
...
@@ -41,4 +41,45 @@ describe Ci::ArtifactBlob do
...
@@ -41,4 +41,45 @@ describe Ci::ArtifactBlob do
expect
(
subject
.
external_storage
).
to
eq
(
:build_artifact
)
expect
(
subject
.
external_storage
).
to
eq
(
:build_artifact
)
end
end
end
end
describe
'#url'
do
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:artifacts_server
).
and_return
(
true
)
end
context
'.gif extension'
do
it
'returns nil'
do
expect
(
subject
.
external_url
(
build
.
project
,
build
)).
to
be_nil
end
end
context
'txt extensions'
do
let
(
:entry
)
{
build
.
artifacts_metadata_entry
(
'other_artifacts_0.1.2/doc_sample.txt'
)
}
it
'returns a URL'
do
url
=
subject
.
external_url
(
build
.
project
,
build
)
expect
(
url
).
not_to
be_nil
expect
(
url
).
to
start_with
(
"http"
)
expect
(
url
).
to
match
Gitlab
.
config
.
pages
.
host
expect
(
url
).
to
end_with
(
entry
.
path
)
end
end
end
describe
'#external_link?'
do
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:artifacts_server
).
and_return
(
true
)
end
it
{
is_expected
.
not_to
be_external_link
}
context
'txt extensions'
do
let
(
:entry
)
{
build
.
artifacts_metadata_entry
(
'other_artifacts_0.1.2/doc_sample.txt'
)
}
it
{
is_expected
.
to
be_external_link
}
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