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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
276d4eb8
Commit
276d4eb8
authored
Apr 18, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specifying a non-default ref when requesting an archive using the legacy URL
parent
05aa4976
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
5 deletions
+36
-5
app/controllers/projects/repositories_controller.rb
app/controllers/projects/repositories_controller.rb
+6
-5
changelogs/unreleased/45507-fix-repository-archive-url.yml
changelogs/unreleased/45507-fix-repository-archive-url.yml
+6
-0
spec/controllers/projects/repositories_controller_spec.rb
spec/controllers/projects/repositories_controller_spec.rb
+24
-0
No files found.
app/controllers/projects/repositories_controller.rb
View file @
276d4eb8
...
@@ -28,11 +28,12 @@ class Projects::RepositoriesController < Projects::ApplicationController
...
@@ -28,11 +28,12 @@ class Projects::RepositoriesController < Projects::ApplicationController
end
end
def
assign_archive_vars
def
assign_archive_vars
@id
=
params
[
:id
]
if
params
[
:id
]
@ref
,
@filename
=
extract_ref
(
params
[
:id
])
return
unless
@id
else
@ref
=
params
[
:ref
]
@ref
,
@filename
=
extract_ref
(
@id
)
@filename
=
nil
end
rescue
InvalidPathError
rescue
InvalidPathError
render_404
render_404
end
end
...
...
changelogs/unreleased/45507-fix-repository-archive-url.yml
0 → 100644
View file @
276d4eb8
---
title
:
Fix specifying a non-default ref when requesting an archive using the legacy
URL
merge_request
:
18468
author
:
type
:
fixed
spec/controllers/projects/repositories_controller_spec.rb
View file @
276d4eb8
...
@@ -40,6 +40,30 @@ describe Projects::RepositoriesController do
...
@@ -40,6 +40,30 @@ describe Projects::RepositoriesController do
expect
(
response
.
header
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]).
to
start_with
(
"git-archive:"
)
expect
(
response
.
header
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]).
to
start_with
(
"git-archive:"
)
end
end
it
'handles legacy queries with the ref specified as ref in params'
do
get
:archive
,
namespace_id:
project
.
namespace
,
project_id:
project
,
ref:
'feature'
,
format:
'zip'
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
assigns
(
:ref
)).
to
eq
(
'feature'
)
expect
(
response
.
header
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]).
to
start_with
(
"git-archive:"
)
end
it
'handles legacy queries with the ref specified as id in params'
do
get
:archive
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
'feature'
,
format:
'zip'
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
assigns
(
:ref
)).
to
eq
(
'feature'
)
expect
(
response
.
header
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]).
to
start_with
(
"git-archive:"
)
end
it
'prioritizes the id param over the ref param when both are specified'
do
get
:archive
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
'feature'
,
ref:
'feature_conflict'
,
format:
'zip'
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
assigns
(
:ref
)).
to
eq
(
'feature'
)
expect
(
response
.
header
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]).
to
start_with
(
"git-archive:"
)
end
context
"when the service raises an error"
do
context
"when the service raises an error"
do
before
do
before
do
allow
(
Gitlab
::
Workhorse
).
to
receive
(
:send_git_archive
).
and_raise
(
"Archive failed"
)
allow
(
Gitlab
::
Workhorse
).
to
receive
(
:send_git_archive
).
and_raise
(
"Archive failed"
)
...
...
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