Files
gitlabhq/lib/gitlab/import_export/project_tree_saver.rb
T
Douwe MaanandRobert Speicher bf0294378e Merge branch 'feature/project-export' into 'master'
Export project functionality

This is a MR for the export functionality of https://gitlab.com/gitlab-org/gitlab-ce/issues/3050, which adds the ability to export single projects.

- [x] members
- DB data
  - [x] issues
  - [x] issue comments
  - [x] merge requests
  - [x] merge request diff
  - [x] merge request comments
  - [x] labels
  - [x] milestones
  - [x] snippets
  - [x] releases
  - [x] events
  - [x] commit statuses
  - [x] CI builds
- File system data
  - [x] Git repository
  - [x] wiki
  - [x] uploads
  - [ ] ~~CI build traces~~
  - [ ] ~~CI build artifacts~~
  - [ ] ~~LFS objects~~
- DB configuration
  - [x] services
  - [x] web hooks
  - [x] protected branches
  - [x] deploy keys
  - [x] CI variables
  - [x] CI triggers

See merge request !3114
2016-06-17 14:18:15 -04:00

30 lines
632 B
Ruby

module Gitlab
module ImportExport
class ProjectTreeSaver
attr_reader :full_path
def initialize(project:, shared:)
@project = project
@shared = shared
@full_path = File.join(@shared.export_path, ImportExport.project_filename)
end
def save
FileUtils.mkdir_p(@shared.export_path)
File.write(full_path, project_json_tree)
true
rescue => e
@shared.error(e)
false
end
private
def project_json_tree
@project.to_json(Gitlab::ImportExport::Reader.new(shared: @shared).project_tree)
end
end
end
end