add project name and namespace to filename on project export
added changelog
This commit is contained in:
parent
86f83db2b0
commit
65549a5866
5 changed files with 33 additions and 3 deletions
|
@ -93,6 +93,7 @@ v 8.10.0 (unreleased)
|
|||
- Redesign Builds and Pipelines pages
|
||||
- Change status color and icon for running builds
|
||||
- Fix markdown rendering for: consecutive labels references, label references that begin with a digit or contains `.`
|
||||
- Project export filename now includes the project and namespace path
|
||||
|
||||
v 8.9.6
|
||||
- Fix importing of events under notes for GitLab projects. !5154
|
||||
|
|
|
@ -10,7 +10,7 @@ module Projects
|
|||
|
||||
def save_all
|
||||
if [version_saver, project_tree_saver, uploads_saver, repo_saver, wiki_repo_saver].all?(&:save)
|
||||
Gitlab::ImportExport::Saver.save(shared: @shared)
|
||||
Gitlab::ImportExport::Saver.save(project: project, shared: @shared)
|
||||
notify_success
|
||||
else
|
||||
cleanup_and_notify
|
||||
|
|
|
@ -3,6 +3,7 @@ module Gitlab
|
|||
extend self
|
||||
|
||||
VERSION = '0.1.1'
|
||||
FILENAME_LIMIT = 50
|
||||
|
||||
def export_path(relative_path:)
|
||||
File.join(storage_path, relative_path)
|
||||
|
@ -28,6 +29,12 @@ module Gitlab
|
|||
'VERSION'
|
||||
end
|
||||
|
||||
def export_filename(project:)
|
||||
basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{project.namespace.path}_#{project.path}"
|
||||
|
||||
"#{basename[0..FILENAME_LIMIT]}_export.tar.gz"
|
||||
end
|
||||
|
||||
def version
|
||||
VERSION
|
||||
end
|
||||
|
|
|
@ -7,7 +7,8 @@ module Gitlab
|
|||
new(*args).save
|
||||
end
|
||||
|
||||
def initialize(shared:)
|
||||
def initialize(project:, shared:)
|
||||
@project = project
|
||||
@shared = shared
|
||||
end
|
||||
|
||||
|
@ -36,7 +37,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def archive_file
|
||||
@archive_file ||= File.join(@shared.export_path, '..', "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_project_export.tar.gz")
|
||||
@archive_file ||= File.join(@shared.export_path, '..', Gitlab::ImportExport.export_filename(project: @project))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
21
spec/lib/gitlab/import_export/import_export_spec.rb
Normal file
21
spec/lib/gitlab/import_export/import_export_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::ImportExport, services: true do
|
||||
describe 'export filename' do
|
||||
let(:project) { create(:project, :public, path: 'project-path') }
|
||||
|
||||
it 'contains the project path' do
|
||||
expect(described_class.export_filename(project: project)).to include(project.path)
|
||||
end
|
||||
|
||||
it 'contains the namespace path' do
|
||||
expect(described_class.export_filename(project: project)).to include(project.namespace.path)
|
||||
end
|
||||
|
||||
it 'does not go over a certain length' do
|
||||
project.path = 'a' * 100
|
||||
|
||||
expect(described_class.export_filename(project: project).length).to be < 70
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue