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
a7954564
Commit
a7954564
authored
Oct 30, 2019
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created a constant for archive formats
Closes
https://gitlab.com/gitlab-org/gitlab/issues/35231
parent
14227cac
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
11 additions
and
17 deletions
+11
-17
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+1
-3
app/models/releases/source.rb
app/models/releases/source.rb
+1
-3
app/views/projects/buttons/_download_links.html.haml
app/views/projects/buttons/_download_links.html.haml
+2
-4
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+1
-0
spec/models/release_spec.rb
spec/models/release_spec.rb
+2
-2
spec/models/releases/source_spec.rb
spec/models/releases/source_spec.rb
+1
-1
spec/support/shared_examples/features/archive_download_buttons_shared_examples.rb
...ples/features/archive_download_buttons_shared_examples.rb
+3
-4
No files found.
app/helpers/tree_helper.rb
View file @
a7954564
...
@@ -197,9 +197,7 @@ module TreeHelper
...
@@ -197,9 +197,7 @@ module TreeHelper
end
end
def
directory_download_links
(
project
,
ref
,
archive_prefix
)
def
directory_download_links
(
project
,
ref
,
archive_prefix
)
formats
=
[
'zip'
,
'tar.gz'
,
'tar.bz2'
,
'tar'
]
Gitlab
::
Workhorse
::
ARCHIVE_FORMATS
.
map
do
|
fmt
|
formats
.
map
do
|
fmt
|
{
{
text:
fmt
,
text:
fmt
,
path:
project_archive_path
(
project
,
id:
tree_join
(
ref
,
archive_prefix
),
format:
fmt
)
path:
project_archive_path
(
project
,
id:
tree_join
(
ref
,
archive_prefix
),
format:
fmt
)
...
...
app/models/releases/source.rb
View file @
a7954564
...
@@ -6,11 +6,9 @@ module Releases
...
@@ -6,11 +6,9 @@ module Releases
attr_accessor
:project
,
:tag_name
,
:format
attr_accessor
:project
,
:tag_name
,
:format
FORMATS
=
%w(zip tar.gz tar.bz2 tar)
.
freeze
class
<<
self
class
<<
self
def
all
(
project
,
tag_name
)
def
all
(
project
,
tag_name
)
Releases
::
Source
::
FORMATS
.
map
do
|
format
|
Gitlab
::
Workhorse
::
ARCHIVE_
FORMATS
.
map
do
|
format
|
Releases
::
Source
.
new
(
project:
project
,
Releases
::
Source
.
new
(
project:
project
,
tag_name:
tag_name
,
tag_name:
tag_name
,
format:
format
)
format:
format
)
...
...
app/views/projects/buttons/_download_links.html.haml
View file @
a7954564
-
formats
=
[[
'zip'
,
'btn-primary'
],
[
'tar.gz'
],
[
'tar.bz2'
],
[
'tar'
]]
.btn-group.ml-0.w-100
.btn-group.ml-0.w-100
-
formats
.
each
do
|
(
fmt
,
extra_class
)
|
-
Gitlab
::
Workhorse
::
ARCHIVE_FORMATS
.
each_with_index
do
|
fmt
,
index
|
-
archive_path
=
project_archive_path
(
project
,
id:
tree_join
(
ref
,
archive_prefix
),
path:
path
,
format:
fmt
)
-
archive_path
=
project_archive_path
(
project
,
id:
tree_join
(
ref
,
archive_prefix
),
path:
path
,
format:
fmt
)
=
link_to
fmt
,
external_storage_url_or_path
(
archive_path
),
rel:
'nofollow'
,
download:
''
,
class:
"btn btn-xs
#{
extra_class
}
"
=
link_to
fmt
,
external_storage_url_or_path
(
archive_path
),
rel:
'nofollow'
,
download:
''
,
class:
"btn btn-xs
#{
"btn-primary"
if
index
==
0
}
"
lib/gitlab/workhorse.rb
View file @
a7954564
...
@@ -14,6 +14,7 @@ module Gitlab
...
@@ -14,6 +14,7 @@ module Gitlab
NOTIFICATION_CHANNEL
=
'workhorse:notifications'
NOTIFICATION_CHANNEL
=
'workhorse:notifications'
ALLOWED_GIT_HTTP_ACTIONS
=
%w[git_receive_pack git_upload_pack info_refs]
.
freeze
ALLOWED_GIT_HTTP_ACTIONS
=
%w[git_receive_pack git_upload_pack info_refs]
.
freeze
DETECT_HEADER
=
'Gitlab-Workhorse-Detect-Content-Type'
DETECT_HEADER
=
'Gitlab-Workhorse-Detect-Content-Type'
ARCHIVE_FORMATS
=
%w(zip tar.gz tar.bz2 tar)
.
freeze
include
JwtAuthenticatable
include
JwtAuthenticatable
...
...
spec/models/release_spec.rb
View file @
a7954564
...
@@ -57,14 +57,14 @@ RSpec.describe Release do
...
@@ -57,14 +57,14 @@ RSpec.describe Release do
subject
{
release
.
assets_count
}
subject
{
release
.
assets_count
}
it
'returns the number of sources'
do
it
'returns the number of sources'
do
is_expected
.
to
eq
(
Releases
::
Source
::
FORMATS
.
count
)
is_expected
.
to
eq
(
Gitlab
::
Workhorse
::
ARCHIVE_
FORMATS
.
count
)
end
end
context
'when a links exists'
do
context
'when a links exists'
do
let!
(
:link
)
{
create
(
:release_link
,
release:
release
)
}
let!
(
:link
)
{
create
(
:release_link
,
release:
release
)
}
it
'counts the link as an asset'
do
it
'counts the link as an asset'
do
is_expected
.
to
eq
(
1
+
Releases
::
Source
::
FORMATS
.
count
)
is_expected
.
to
eq
(
1
+
Gitlab
::
Workhorse
::
ARCHIVE_
FORMATS
.
count
)
end
end
it
"excludes sources count when asked"
do
it
"excludes sources count when asked"
do
...
...
spec/models/releases/source_spec.rb
View file @
a7954564
...
@@ -11,7 +11,7 @@ describe Releases::Source do
...
@@ -11,7 +11,7 @@ describe Releases::Source do
it
'returns all formats of sources'
do
it
'returns all formats of sources'
do
expect
(
subject
.
map
(
&
:format
))
expect
(
subject
.
map
(
&
:format
))
.
to
match_array
(
described_class
::
FORMATS
)
.
to
match_array
(
Gitlab
::
Workhorse
::
ARCHIVE_
FORMATS
)
end
end
end
end
...
...
spec/support/shared_examples/features/archive_download_buttons_shared_examples.rb
View file @
a7954564
# frozen_string_literal: true
# frozen_string_literal: true
shared_examples
'archive download buttons'
do
shared_examples
'archive download buttons'
do
let
(
:formats
)
{
%w(zip tar.gz tar.bz2 tar)
}
let
(
:path_to_visit
)
{
project_path
(
project
)
}
let
(
:path_to_visit
)
{
project_path
(
project
)
}
let
(
:ref
)
{
project
.
default_branch
}
let
(
:ref
)
{
project
.
default_branch
}
...
@@ -13,7 +12,7 @@ shared_examples 'archive download buttons' do
...
@@ -13,7 +12,7 @@ shared_examples 'archive download buttons' do
context
'private project'
do
context
'private project'
do
it
'shows archive download buttons with external storage URL prepended and user token appended to their href'
do
it
'shows archive download buttons with external storage URL prepended and user token appended to their href'
do
formats
.
each
do
|
format
|
Gitlab
::
Workhorse
::
ARCHIVE_FORMATS
.
each
do
|
format
|
path
=
archive_path
(
project
,
ref
,
format
)
path
=
archive_path
(
project
,
ref
,
format
)
uri
=
URI
(
'https://cdn.gitlab.com'
)
uri
=
URI
(
'https://cdn.gitlab.com'
)
uri
.
path
=
path
uri
.
path
=
path
...
@@ -28,7 +27,7 @@ shared_examples 'archive download buttons' do
...
@@ -28,7 +27,7 @@ shared_examples 'archive download buttons' do
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
it
'shows archive download buttons with external storage URL prepended to their href'
do
it
'shows archive download buttons with external storage URL prepended to their href'
do
formats
.
each
do
|
format
|
Gitlab
::
Workhorse
::
ARCHIVE_FORMATS
.
each
do
|
format
|
path
=
archive_path
(
project
,
ref
,
format
)
path
=
archive_path
(
project
,
ref
,
format
)
uri
=
URI
(
'https://cdn.gitlab.com'
)
uri
=
URI
(
'https://cdn.gitlab.com'
)
uri
.
path
=
path
uri
.
path
=
path
...
@@ -45,7 +44,7 @@ shared_examples 'archive download buttons' do
...
@@ -45,7 +44,7 @@ shared_examples 'archive download buttons' do
end
end
it
'shows default archive download buttons'
do
it
'shows default archive download buttons'
do
formats
.
each
do
|
format
|
Gitlab
::
Workhorse
::
ARCHIVE_FORMATS
.
each
do
|
format
|
path
=
archive_path
(
project
,
ref
,
format
)
path
=
archive_path
(
project
,
ref
,
format
)
expect
(
page
).
to
have_link
format
,
href:
path
expect
(
page
).
to
have_link
format
,
href:
path
...
...
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