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
be764a3a
Commit
be764a3a
authored
Jan 14, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor improvements in build arfifacts browser
Added also a `Gitlab::Ci::Build::Artifacts::Metadata::ParserError` exception class.
parent
76e578fd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
10 deletions
+17
-10
_tree_file.html.haml
app/views/projects/artifacts/_tree_file.html.haml
+1
-1
routes.rb
config/routes.rb
+2
-2
metadata.rb
lib/gitlab/ci/build/artifacts/metadata.rb
+12
-5
entry.rb
lib/gitlab/ci/build/artifacts/metadata/entry.rb
+2
-2
No files found.
app/views/projects/artifacts/_tree_file.html.haml
View file @
be764a3a
...
...
@@ -6,6 +6,6 @@
%td
=
number_to_human_size
(
file
.
metadata
[
:size
],
precision:
2
)
%td
=
link_to
file_namespace_project_build_artifacts_path
(
path:
file
.
path
),
=
link_to
file_namespace_project_build_artifacts_path
(
@project
.
namespace
,
@project
,
@build
,
path:
file
.
path
),
class:
'btn btn-xs btn-default artifact-download'
do
=
icon
(
'download'
)
config/routes.rb
View file @
be764a3a
...
...
@@ -609,8 +609,8 @@ Rails.application.routes.draw do
resource
:artifacts
,
only:
[]
do
get
:download
get
:browse
,
path:
'browse(/*path)'
,
action: :browse
,
format:
false
get
:file
,
path:
'file/*path'
,
action: :file
,
format:
false
get
:browse
,
path:
'browse(/*path)'
,
format:
false
get
:file
,
path:
'file/*path'
,
format:
false
end
end
...
...
lib/gitlab/ci/build/artifacts/metadata.rb
View file @
be764a3a
...
...
@@ -6,6 +6,8 @@ module Gitlab
module
Build
module
Artifacts
class
Metadata
class
ParserError
<
StandardError
;
end
VERSION_PATTERN
=
/^[\w\s]+(\d+\.\d+\.\d+)/
INVALID_PATH_PATTERN
=
%r{(^
\.
?
\.
?/)|(/
\.
?
\.
?/)}
...
...
@@ -24,8 +26,13 @@ module Gitlab
gzip
do
|
gz
|
read_string
(
gz
)
# version
errors
=
read_string
(
gz
)
raise
StandardError
,
'Errors field not found!'
unless
errors
JSON
.
parse
(
errors
)
raise
ParserError
,
'Errors field not found!'
unless
errors
begin
JSON
.
parse
(
errors
)
rescue
JSON
::
ParserError
raise
ParserError
,
'Invalid errors field!'
end
end
end
...
...
@@ -56,7 +63,7 @@ module Gitlab
next
unless
path
=~
match_pattern
next
if
path
=~
INVALID_PATH_PATTERN
entries
.
store
(
path
,
JSON
.
parse
(
meta
,
symbolize_names:
true
)
)
entries
[
path
]
=
JSON
.
parse
(
meta
,
symbolize_names:
true
)
rescue
JSON
::
ParserError
,
Encoding
::
CompatibilityError
next
end
...
...
@@ -70,11 +77,11 @@ module Gitlab
version_string
=
read_string
(
gz
)
unless
version_string
raise
Standard
Error
,
'Artifacts metadata file empty!'
raise
Parser
Error
,
'Artifacts metadata file empty!'
end
unless
version_string
=~
VERSION_PATTERN
raise
Standard
Error
,
'Invalid version!'
raise
Parser
Error
,
'Invalid version!'
end
version_string
.
chomp
...
...
lib/gitlab/ci/build/artifacts/metadata/entry.rb
View file @
be764a3a
...
...
@@ -57,7 +57,7 @@ module Gitlab
return
@children
if
@children
child_pattern
=
%r{^
#{
Regexp
.
escape
(
@path
)
}
[^/]+/?$}
@children
=
select_entries
{
|
entry
|
entry
=~
child_pattern
}
@children
=
select_entries
{
|
path
|
path
=~
child_pattern
}
end
def
directories
(
opts
=
{})
...
...
@@ -110,7 +110,7 @@ module Gitlab
private
def
select_entries
selected
=
@entries
.
select
{
|
entry
,
_metadata
|
yield
entry
}
selected
=
@entries
.
select
{
|
path
,
_metadata
|
yield
path
}
selected
.
map
{
|
path
,
_metadata
|
self
.
class
.
new
(
path
,
@entries
)
}
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