Commit 91a44699 authored by Kirill Smelkov's avatar Kirill Smelkov

Add support for XZ archive format

( will send upstream if it works )
parent 1aafce0d
......@@ -23,6 +23,10 @@
= link_to archive_namespace_project_repository_path(@project.namespace, @project, ref: ref, format: 'tar.bz2'), rel: 'nofollow' do
%i.fa.fa-download
%span Download tar.bz2
%li
= link_to archive_namespace_project_repository_path(@project.namespace, @project, ref: ref, format: 'tar.xz'), rel: 'nofollow' do
%i.fa.fa-download
%span Download tar.xz
%li
= link_to archive_namespace_project_repository_path(@project.namespace, @project, ref: ref, format: 'tar'), rel: 'nofollow' do
%i.fa.fa-download
......
......@@ -70,8 +70,8 @@ module Gitlab
def archive_formats_regex
# |zip|tar| tar.gz | tar.bz2 |
@archive_formats_regex ||= /(zip|tar|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)/.freeze
# |zip|tar| tar.gz | tar.bz2 | tar.xz |
@archive_formats_regex ||= /(zip|tar|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2|tar\.xz|txz|xz)/.freeze
end
def git_reference_regex
......
......@@ -115,6 +115,15 @@ describe API::API, api: true do
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.bz2/)
end
it "should get the archive.tar.xz" do
get api("/projects/#{project.id}/repository/archive.tar.xz", user)
repo_name = project.repository.name.gsub("\.git", "")
expect(response.status).to eq(200)
type, params = workhorse_send_data
expect(type).to eq('git-archive')
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.xz/)
end
it "should return 404 for invalid sha" do
get api("/projects/#{project.id}/repository/archive/?sha=xxx", user)
expect(response.status).to eq(404)
......
......@@ -136,6 +136,10 @@ describe Projects::RepositoriesController, 'routing' do
expect(get('/gitlab/gitlabhq/repository/archive.tar.bz2')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.bz2')
end
it 'to #archive format:tar.xz' do
expect(get('/gitlab/gitlabhq/repository/archive.tar.xz')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.xz')
end
it 'to #show' do
expect(get('/gitlab/gitlabhq/repository')).to route_to('projects/repositories#show', namespace_id: 'gitlab', project_id: 'gitlabhq')
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment