Fix specifying a non-default ref when requesting an archive using the legacy URL
This commit is contained in:
parent
05aa49765f
commit
276d4eb80c
|
@ -28,11 +28,12 @@ class Projects::RepositoriesController < Projects::ApplicationController
|
|||
end
|
||||
|
||||
def assign_archive_vars
|
||||
@id = params[:id]
|
||||
|
||||
return unless @id
|
||||
|
||||
@ref, @filename = extract_ref(@id)
|
||||
if params[:id]
|
||||
@ref, @filename = extract_ref(params[:id])
|
||||
else
|
||||
@ref = params[:ref]
|
||||
@filename = nil
|
||||
end
|
||||
rescue InvalidPathError
|
||||
render_404
|
||||
end
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
title: Fix specifying a non-default ref when requesting an archive using the legacy
|
||||
URL
|
||||
merge_request: 18468
|
||||
author:
|
||||
type: fixed
|
|
@ -40,6 +40,30 @@ describe Projects::RepositoriesController do
|
|||
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
|
||||
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
|
||||
before do
|
||||
allow(Gitlab::Workhorse).to receive(:send_git_archive).and_raise("Archive failed")
|
||||
|
|
Loading…
Reference in New Issue