gitlab-org--gitlab-foss/lib/gitlab/import_export.rb
Z.J. van de Weg 1d3815f89b
Allow projects to be started from a template
Started implementation for the first iteration of
gitlab-org/gitlab-ce#32420. This will allow users to select a template
to start with, instead of an empty repository in the project just
created.

Internally this is basically a small extension of the ImportExport
GitLab projects we already support. We just import a certain import
tar archive. This commits includes the first one: Ruby on Rails. In the
future more will be added.
2017-07-28 11:32:46 +02:00

53 lines
1.1 KiB
Ruby

module Gitlab
module ImportExport
extend self
# For every version update, the version history in import_export.md has to be kept up to date.
VERSION = '0.1.8'.freeze
FILENAME_LIMIT = 50
def export_path(relative_path:)
File.join(storage_path, relative_path)
end
def storage_path
File.join(Settings.shared['path'], 'tmp/project_exports')
end
def import_upload_path(filename:)
milliseconds = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
File.join(storage_path, 'uploads', "#{millisecond}-#{filename}")
end
def project_filename
"project.json"
end
def project_bundle_filename
"project.bundle"
end
def config_file
Rails.root.join('lib/gitlab/import_export/import_export.yml')
end
def version_filename
'VERSION'
end
def export_filename(project:)
basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{project.full_path.tr('/', '_')}"
"#{basename[0..FILENAME_LIMIT]}_export.tar.gz"
end
def version
VERSION
end
def reset_tokens?
true
end
end
end