Welcome to mirror list, hosted at ThFree Co, Russian Federation.

import_export.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 231f2a977c0f172569b2f9a582408564fc05a856 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# frozen_string_literal: true

module Gitlab
  module ImportExport
    extend self

    # For every version update the version history in these docs must be kept up to date:
    # - development/import_export.md
    # - user/project/settings/import_export.md
    VERSION = '0.2.4'
    FILENAME_LIMIT = 50

    def export_path(relative_path:)
      File.join(storage_path, relative_path)
    end

    def storage_path
      File.join(Settings.shared['path'], 'tmp/gitlab_exports')
    end

    def import_upload_path(filename:)
      File.join(storage_path, 'uploads', filename)
    end

    def project_filename
      "project.json"
    end

    def project_bundle_filename
      "project.bundle"
    end

    def lfs_objects_filename
      "lfs-objects.json"
    end

    def lfs_objects_storage
      "lfs-objects"
    end

    def wiki_repo_bundle_filename
      "project.wiki.bundle"
    end

    def design_repo_bundle_filename
      'project.design.bundle'
    end

    def snippet_repo_bundle_dir
      'snippets'
    end

    def snippets_repo_bundle_path(absolute_path)
      File.join(absolute_path, ::Gitlab::ImportExport.snippet_repo_bundle_dir)
    end

    def snippet_repo_bundle_filename_for(snippet)
      "#{snippet.hexdigest}.bundle"
    end

    def config_file
      Rails.root.join('lib/gitlab/import_export/project/import_export.yml')
    end

    def version_filename
      'VERSION'
    end

    def gitlab_version_filename
      'GITLAB_VERSION'
    end

    def gitlab_revision_filename
      'GITLAB_REVISION'
    end

    def export_filename(exportable:)
      basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{exportable.full_path.tr('/', '_')}"

      "#{basename[0..FILENAME_LIMIT]}_export.tar.gz"
    end

    def version
      VERSION
    end

    def reset_tokens?
      true
    end

    def group_filename
      'group.json'
    end

    def legacy_group_config_file
      Rails.root.join('lib/gitlab/import_export/group/legacy_import_export.yml')
    end

    def group_config_file
      Rails.root.join('lib/gitlab/import_export/group/import_export.yml')
    end

    def group_wiki_repo_bundle_filename(group_id)
      "#{group_id}.wiki.bundle"
    end

    def group_wiki_repo_bundle_path(shared, filename)
      File.join(shared.export_path, 'repositories', filename)
    end

    def group_wiki_repo_bundle_full_path(shared, group_id)
      group_wiki_repo_bundle_path(shared, group_wiki_repo_bundle_filename(group_id))
    end
  end
end

Gitlab::ImportExport.prepend_mod