Skip to content
Snippets Groups Projects
Commit 20450649 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 3f0f13c6
No related branches found
No related tags found
No related merge requests found
Showing
with 170 additions and 92 deletions
Loading
@@ -69,7 +69,7 @@ This is the recommended minimum hardware for a handful of example GitLab user ba
Loading
@@ -69,7 +69,7 @@ This is the recommended minimum hardware for a handful of example GitLab user ba
- 4 cores supports up to 500 users - 4 cores supports up to 500 users
- 8 cores supports up to 1,000 users - 8 cores supports up to 1,000 users
- 32 cores supports up to 5,000 users - 32 cores supports up to 5,000 users
- More users? Run it high-availability on [multiple application servers](https://about.gitlab.com/high-availability/) - More users? Run it high-availability on [multiple application servers](https://about.gitlab.com/solutions/high-availability/)
   
### Memory ### Memory
   
Loading
@@ -86,7 +86,7 @@ errors during usage.
Loading
@@ -86,7 +86,7 @@ errors during usage.
- 16GB RAM supports up to 500 users - 16GB RAM supports up to 500 users
- 32GB RAM supports up to 1,000 users - 32GB RAM supports up to 1,000 users
- 128GB RAM supports up to 5,000 users - 128GB RAM supports up to 5,000 users
- More users? Run it high-availability on [multiple application servers](https://about.gitlab.com/high-availability/) - More users? Run it high-availability on [multiple application servers](https://about.gitlab.com/solutions/high-availability/)
   
We recommend having at least [2GB of swap on your server](https://askubuntu.com/a/505344/310789), even if you currently have We recommend having at least [2GB of swap on your server](https://askubuntu.com/a/505344/310789), even if you currently have
enough available RAM. Having swap will help reduce the chance of errors occurring enough available RAM. Having swap will help reduce the chance of errors occurring
Loading
@@ -139,7 +139,7 @@ If you are using [GitLab Geo](../development/geo.md):
Loading
@@ -139,7 +139,7 @@ If you are using [GitLab Geo](../development/geo.md):
- The - The
[tracking database](../development/geo.md#using-the-tracking-database) [tracking database](../development/geo.md#using-the-tracking-database)
requires the requires the
[postgres_fdw](https://www.postgresql.org/docs/9.6/static/postgres-fdw.html) [postgres_fdw](https://www.postgresql.org/docs/9.6/postgres-fdw.html)
extension. extension.
   
``` ```
Loading
Loading
Loading
@@ -55,7 +55,7 @@ The following languages and dependency managers are supported.
Loading
@@ -55,7 +55,7 @@ The following languages and dependency managers are supported.
|----------------------------- | --------- | ------------ | |----------------------------- | --------- | ------------ |
| Java ([Gradle](https://gradle.org/)) | not currently ([issue](https://gitlab.com/gitlab-org/gitlab/issues/13075 "Dependency Scanning for Gradle" )) | not available | | Java ([Gradle](https://gradle.org/)) | not currently ([issue](https://gitlab.com/gitlab-org/gitlab/issues/13075 "Dependency Scanning for Gradle" )) | not available |
| Java ([Maven](https://maven.apache.org/)) | yes | [gemnasium](https://gitlab.com/gitlab-org/security-products/gemnasium) | | Java ([Maven](https://maven.apache.org/)) | yes | [gemnasium](https://gitlab.com/gitlab-org/security-products/gemnasium) |
| JavaScript ([npm](https://www.npmjs.com/), [yarn](https://yarnpkg.com/en/)) | yes | [gemnasium](https://gitlab.com/gitlab-org/security-products/gemnasium), [Retire.js](https://retirejs.github.io/retire.js) | | JavaScript ([npm](https://www.npmjs.com/), [yarn](https://yarnpkg.com/en/)) | yes | [gemnasium](https://gitlab.com/gitlab-org/security-products/gemnasium), [Retire.js](https://retirejs.github.io/retire.js/) |
| Go ([Golang](https://golang.org/)) | not currently ([issue](https://gitlab.com/gitlab-org/gitlab/issues/7132 "Dependency Scanning for Go")) | not available | | Go ([Golang](https://golang.org/)) | not currently ([issue](https://gitlab.com/gitlab-org/gitlab/issues/7132 "Dependency Scanning for Go")) | not available |
| PHP ([Composer](https://getcomposer.org/)) | yes | [gemnasium](https://gitlab.com/gitlab-org/security-products/gemnasium) | | PHP ([Composer](https://getcomposer.org/)) | yes | [gemnasium](https://gitlab.com/gitlab-org/security-products/gemnasium) |
| Python ([pip](https://pip.pypa.io/en/stable/)) | yes | [gemnasium](https://gitlab.com/gitlab-org/security-products/gemnasium) | | Python ([pip](https://pip.pypa.io/en/stable/)) | yes | [gemnasium](https://gitlab.com/gitlab-org/security-products/gemnasium) |
Loading
Loading
Loading
@@ -57,7 +57,7 @@ This workflow comes with some drawbacks and there's a
Loading
@@ -57,7 +57,7 @@ This workflow comes with some drawbacks and there's a
   
## Interacting with the vulnerabilities ## Interacting with the vulnerabilities
   
> Introduced in [GitLab Ultimate](https://about.gitlab.com/pricing) 10.8. > Introduced in [GitLab Ultimate](https://about.gitlab.com/pricing/) 10.8.
   
CAUTION: **Warning:** CAUTION: **Warning:**
This feature is currently [Alpha](https://about.gitlab.com/handbook/product/#alpha-beta-ga) and while you can start using it, it may receive important changes in the future. This feature is currently [Alpha](https://about.gitlab.com/handbook/product/#alpha-beta-ga) and while you can start using it, it may receive important changes in the future.
Loading
@@ -84,7 +84,7 @@ If you wish to undo this dismissal, you can click the **Undo dismiss** button.
Loading
@@ -84,7 +84,7 @@ If you wish to undo this dismissal, you can click the **Undo dismiss** button.
   
#### Adding a dismissal reason #### Adding a dismissal reason
   
> Introduced in [GitLab Ultimate](https://about.gitlab.com/pricing) 12.0. > Introduced in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.0.
   
When dismissing a vulnerability, it's often helpful to provide a reason for doing so. When dismissing a vulnerability, it's often helpful to provide a reason for doing so.
If you press the comment button next to **Dismiss vulnerability** in the modal, a text box will appear, allowing you to add a comment with your dismissal. If you press the comment button next to **Dismiss vulnerability** in the modal, a text box will appear, allowing you to add a comment with your dismissal.
Loading
@@ -110,7 +110,7 @@ the vulnerability will now have an associated issue next to the name.
Loading
@@ -110,7 +110,7 @@ the vulnerability will now have an associated issue next to the name.
   
### Solutions for vulnerabilities (auto-remediation) ### Solutions for vulnerabilities (auto-remediation)
   
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/5656) in [GitLab Ultimate](https://about.gitlab.com/pricing) 11.7. > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/5656) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 11.7.
   
Some vulnerabilities can be fixed by applying the solution that GitLab Some vulnerabilities can be fixed by applying the solution that GitLab
automatically generates. The following scanners are supported: automatically generates. The following scanners are supported:
Loading
@@ -134,7 +134,7 @@ generated by GitLab. To apply the fix:
Loading
@@ -134,7 +134,7 @@ generated by GitLab. To apply the fix:
   
#### Creating a merge request from a vulnerability #### Creating a merge request from a vulnerability
   
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/9224) in [GitLab Ultimate](https://about.gitlab.com/pricing) 11.9. > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/9224) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 11.9.
   
In certain cases, GitLab will allow you to create a merge request that will In certain cases, GitLab will allow you to create a merge request that will
automatically remediate the vulnerability. Any vulnerability that has a automatically remediate the vulnerability. Any vulnerability that has a
Loading
@@ -148,7 +148,7 @@ Clicking on this button will create a merge request to apply the solution onto t
Loading
@@ -148,7 +148,7 @@ Clicking on this button will create a merge request to apply the solution onto t
   
## Security approvals in merge requests **(ULTIMATE)** ## Security approvals in merge requests **(ULTIMATE)**
   
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/9928) in [GitLab Ultimate](https://about.gitlab.com/pricing) 12.2. > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/9928) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.2.
   
Merge Request Approvals can be configured to require approval from a member Merge Request Approvals can be configured to require approval from a member
of your security team when a vulnerability, or a software license compliance violation would be introduced by a merge request. of your security team when a vulnerability, or a software license compliance violation would be introduced by a merge request.
Loading
Loading
Loading
@@ -60,7 +60,7 @@ The following languages and package managers are supported.
Loading
@@ -60,7 +60,7 @@ The following languages and package managers are supported.
| Elixir | [mix](https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types)) |[License Finder](https://github.com/pivotal/LicenseFinder)| | Elixir | [mix](https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types)) |[License Finder](https://github.com/pivotal/LicenseFinder)|
| C++/C | [conan](https://conan.io/) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types))|[License Finder](https://github.com/pivotal/LicenseFinder)| | C++/C | [conan](https://conan.io/) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types))|[License Finder](https://github.com/pivotal/LicenseFinder)|
| Scala | [sbt](https://www.scala-sbt.org/) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types))|[License Finder](https://github.com/pivotal/LicenseFinder)| | Scala | [sbt](https://www.scala-sbt.org/) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types))|[License Finder](https://github.com/pivotal/LicenseFinder)|
| Rust | [cargo](https://crates.io/) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types))|[License Finder](https://github.com/pivotal/LicenseFinder)| | Rust | [cargo](https://crates.io) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types))|[License Finder](https://github.com/pivotal/LicenseFinder)|
| PHP | [composer](https://getcomposer.org/) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types))|[License Finder](https://github.com/pivotal/LicenseFinder)| | PHP | [composer](https://getcomposer.org/) ([experimental support](https://github.com/pivotal/LicenseFinder#experimental-project-types))|[License Finder](https://github.com/pivotal/LicenseFinder)|
   
## Requirements ## Requirements
Loading
Loading
Loading
@@ -67,7 +67,7 @@ The following table shows which languages, package managers and frameworks are s
Loading
@@ -67,7 +67,7 @@ The following table shows which languages, package managers and frameworks are s
| .NET | [Security Code Scan](https://security-code-scan.github.io) | 11.0 | | .NET | [Security Code Scan](https://security-code-scan.github.io) | 11.0 |
| Any | [Gitleaks](https://github.com/zricethezav/gitleaks) and [TruffleHog](https://github.com/dxa4481/truffleHog) | 11.9 | | Any | [Gitleaks](https://github.com/zricethezav/gitleaks) and [TruffleHog](https://github.com/dxa4481/truffleHog) | 11.9 |
| Apex (Salesforce) | [pmd](https://pmd.github.io/pmd/index.html) | 12.1 | | Apex (Salesforce) | [pmd](https://pmd.github.io/pmd/index.html) | 12.1 |
| C/C++ | [Flawfinder](https://www.dwheeler.com/flawfinder/) | 10.7 | | C/C++ | [Flawfinder](https://dwheeler.com/flawfinder/) | 10.7 |
| Elixir (Phoenix) | [Sobelow](https://github.com/nccgroup/sobelow) | 11.10 | | Elixir (Phoenix) | [Sobelow](https://github.com/nccgroup/sobelow) | 11.10 |
| Go | [Gosec](https://github.com/securego/gosec) | 10.7 | | Go | [Gosec](https://github.com/securego/gosec) | 10.7 |
| Groovy ([Ant](https://ant.apache.org/), [Gradle](https://gradle.org/), [Maven](https://maven.apache.org/) and [SBT](https://www.scala-sbt.org/)) | [SpotBugs](https://spotbugs.github.io/) with the [find-sec-bugs](https://find-sec-bugs.github.io/) plugin | 11.3 (Gradle) & 11.9 (Ant, Maven, SBT) | | Groovy ([Ant](https://ant.apache.org/), [Gradle](https://gradle.org/), [Maven](https://maven.apache.org/) and [SBT](https://www.scala-sbt.org/)) | [SpotBugs](https://spotbugs.github.io/) with the [find-sec-bugs](https://find-sec-bugs.github.io/) plugin | 11.3 (Gradle) & 11.9 (Ant, Maven, SBT) |
Loading
Loading
Loading
@@ -36,7 +36,7 @@ To use the group, project or pipeline security dashboard:
Loading
@@ -36,7 +36,7 @@ To use the group, project or pipeline security dashboard:
   
## Pipeline Security Dashboard ## Pipeline Security Dashboard
   
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/13496) in [GitLab Ultimate](https://about.gitlab.com/pricing) 12.3. > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/13496) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.3.
   
At the pipeline level, the Security Dashboard displays the vulnerabilities present in the branch of the project the pipeline was run against. At the pipeline level, the Security Dashboard displays the vulnerabilities present in the branch of the project the pipeline was run against.
   
Loading
@@ -46,7 +46,7 @@ Visit the page for any pipeline which has run any of the [supported reports](#su
Loading
@@ -46,7 +46,7 @@ Visit the page for any pipeline which has run any of the [supported reports](#su
   
## Project Security Dashboard ## Project Security Dashboard
   
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/6165) in [GitLab Ultimate](https://about.gitlab.com/pricing) 11.1. > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/6165) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 11.1.
   
At the project level, the Security Dashboard displays the latest security reports At the project level, the Security Dashboard displays the latest security reports
for your project. Use it to find and fix vulnerabilities affecting the for your project. Use it to find and fix vulnerabilities affecting the
Loading
@@ -56,7 +56,7 @@ for your project. Use it to find and fix vulnerabilities affecting the
Loading
@@ -56,7 +56,7 @@ for your project. Use it to find and fix vulnerabilities affecting the
   
## Group Security Dashboard ## Group Security Dashboard
   
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/6709) in [GitLab Ultimate](https://about.gitlab.com/pricing) 11.5. > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/6709) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 11.5.
   
The group Security Dashboard gives an overview of the vulnerabilities of all the The group Security Dashboard gives an overview of the vulnerabilities of all the
projects in a group and its subgroups. projects in a group and its subgroups.
Loading
Loading
Loading
@@ -38,7 +38,6 @@ to be enabled:
Loading
@@ -38,7 +38,6 @@ to be enabled:
- Files uploaded must have a file extension of either `png`, `jpg`, `jpeg`, `gif`, `bmp`, `tiff` or `ico`. - Files uploaded must have a file extension of either `png`, `jpg`, `jpeg`, `gif`, `bmp`, `tiff` or `ico`.
The [`svg` extension is not yet supported](https://gitlab.com/gitlab-org/gitlab/issues/12771). The [`svg` extension is not yet supported](https://gitlab.com/gitlab-org/gitlab/issues/12771).
- Design uploads are limited to 10 files at a time. - Design uploads are limited to 10 files at a time.
- [Designs cannot yet be deleted](https://gitlab.com/gitlab-org/gitlab/issues/11089).
- Design Management is - Design Management is
[not yet supported in the project export](https://gitlab.com/gitlab-org/gitlab/issues/11090). [not yet supported in the project export](https://gitlab.com/gitlab-org/gitlab/issues/11090).
- Design Management data - Design Management data
Loading
@@ -64,13 +63,13 @@ of the design, and will replace the previous version.
Loading
@@ -64,13 +63,13 @@ of the design, and will replace the previous version.
   
## Viewing designs ## Viewing designs
   
Images on the Design Management page can be enlarged by clicking on them. Images on the Design Management page can be enlarged by clicking on them.
   
The number of comments on a design — if any — is listed to the right The number of comments on a design — if any — is listed to the right
of the design filename. Clicking on this number enlarges the design of the design filename. Clicking on this number enlarges the design
just like clicking anywhere else on the design. just like clicking anywhere else on the design.
When a design is added or modified, an icon is displayed on the item When a design is added or modified, an icon is displayed on the item
to help summarize changes between versions. to help summarize changes between versions.
   
| Indicator | Example | | Indicator | Example |
| --------- | ------- | | --------- | ------- |
Loading
Loading
Loading
@@ -65,6 +65,7 @@ The following items will be exported:
Loading
@@ -65,6 +65,7 @@ The following items will be exported:
- Project configuration, including services - Project configuration, including services
- Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, - Issues with comments, merge requests with diffs and comments, labels, milestones, snippets,
and other project entities and other project entities
- Design Management files and data **(PREMIUM)**
- LFS objects - LFS objects
- Issue boards - Issue boards
   
Loading
Loading
Loading
@@ -38,6 +38,10 @@ module Gitlab
Loading
@@ -38,6 +38,10 @@ module Gitlab
"lfs-objects" "lfs-objects"
end end
   
def wiki_repo_bundle_filename
"project.wiki.bundle"
end
def config_file def config_file
Rails.root.join('lib/gitlab/import_export/import_export.yml') Rails.root.join('lib/gitlab/import_export/import_export.yml')
end end
Loading
@@ -61,3 +65,5 @@ module Gitlab
Loading
@@ -61,3 +65,5 @@ module Gitlab
end end
end end
end end
Gitlab::ImportExport.prepend_if_ee('EE::Gitlab::ImportExport')
Loading
@@ -26,30 +26,60 @@ module Gitlab
Loading
@@ -26,30 +26,60 @@ module Gitlab
end end
   
def find def find
find_object || @klass.create(project_attributes) find_object || klass.create(project_attributes)
end end
   
private private
   
attr_reader :klass, :attributes, :group, :project
def find_object def find_object
@klass.where(where_clause).first klass.where(where_clause).first
end end
   
def where_clause def where_clause
@attributes.slice('title').map do |key, value| where_clauses.reduce(:and)
scope_clause = table[:project_id].eq(@project.id) end
scope_clause = scope_clause.or(table[:group_id].eq(@group.id)) if @group
def where_clauses
[
where_clause_base,
where_clause_for_title,
where_clause_for_klass
].compact
end
# Returns Arel clause `"{table_name}"."project_id" = {project.id}`
# or, if group is present:
# `"{table_name}"."project_id" = {project.id} OR "{table_name}"."group_id" = {group.id}`
def where_clause_base
clause = table[:project_id].eq(project.id)
clause = clause.or(table[:group_id].eq(group.id)) if group
clause
end
   
table[key].eq(value).and(scope_clause) # Returns Arel clause `"{table_name}"."title" = '{attributes['title']}'`
end.reduce(:or) # if attributes has 'title key, otherwise `nil`.
def where_clause_for_title
attrs_to_arel(attributes.slice('title'))
end
# Returns Arel clause:
# `"{table_name}"."{attrs.keys[0]}" = '{attrs.values[0]} AND {table_name}"."{attrs.keys[1]}" = '{attrs.values[1]}"`
# from the given Hash of attributes.
def attrs_to_arel(attrs)
attrs.map do |key, value|
table[key].eq(value)
end.reduce(:and)
end end
   
def table def table
@table ||= @klass.arel_table @table ||= klass.arel_table
end end
   
def project_attributes def project_attributes
@attributes.except('group').tap do |atts| attributes.except('group').tap do |atts|
if label? if label?
atts['type'] = 'ProjectLabel' # Always create project labels atts['type'] = 'ProjectLabel' # Always create project labels
elsif milestone? elsif milestone?
Loading
@@ -60,15 +90,17 @@ module Gitlab
Loading
@@ -60,15 +90,17 @@ module Gitlab
claim_iid claim_iid
end end
end end
atts['importing'] = true if klass.ancestors.include?(Importable)
end end
end end
   
def label? def label?
@klass == Label klass == Label
end end
   
def milestone? def milestone?
@klass == Milestone klass == Milestone
end end
   
# If an existing group milestone used the IID # If an existing group milestone used the IID
Loading
@@ -79,7 +111,7 @@ module Gitlab
Loading
@@ -79,7 +111,7 @@ module Gitlab
def claim_iid def claim_iid
# The milestone has to be a group milestone, as it's the only case where # The milestone has to be a group milestone, as it's the only case where
# we set the IID as the maximum. The rest of them are fixed. # we set the IID as the maximum. The rest of them are fixed.
milestone = @project.milestones.find_by(iid: @attributes['iid']) milestone = project.milestones.find_by(iid: attributes['iid'])
   
return unless milestone return unless milestone
   
Loading
@@ -87,6 +119,15 @@ module Gitlab
Loading
@@ -87,6 +119,15 @@ module Gitlab
milestone.ensure_project_iid! milestone.ensure_project_iid!
milestone.save! milestone.save!
end end
protected
# Returns Arel clause for a particular model or `nil`.
def where_clause_for_klass
# no-op
end
end end
end end
end end
Gitlab::ImportExport::GroupProjectObjectBuilder.prepend_if_ee('EE::Gitlab::ImportExport::GroupProjectObjectBuilder')
Loading
@@ -248,7 +248,16 @@ preloads:
Loading
@@ -248,7 +248,16 @@ preloads:
ee: ee:
tree: tree:
project: project:
protected_branches: - issues:
- designs:
- notes:
- :author
- events:
- :push_event_payload
- design_versions:
- actions:
- :design # Duplicate export of issues.designs in order to link the record to both Issue and DesignVersion
- protected_branches:
- :unprotect_access_levels - :unprotect_access_levels
protected_environments: - protected_environments:
- :deploy_access_levels - :deploy_access_levels
Loading
@@ -21,7 +21,7 @@ module Gitlab
Loading
@@ -21,7 +21,7 @@ module Gitlab
if import_file && check_version! && restorers.all?(&:restore) && overwrite_project if import_file && check_version! && restorers.all?(&:restore) && overwrite_project
project_tree.restored_project project_tree.restored_project
else else
raise Projects::ImportService::Error.new(@shared.errors.join(', ')) raise Projects::ImportService::Error.new(shared.errors.to_sentence)
end end
rescue => e rescue => e
raise Projects::ImportService::Error.new(e.message) raise Projects::ImportService::Error.new(e.message)
Loading
@@ -31,70 +31,72 @@ module Gitlab
Loading
@@ -31,70 +31,72 @@ module Gitlab
   
private private
   
attr_accessor :archive_file, :current_user, :project, :shared
def restorers def restorers
[repo_restorer, wiki_restorer, project_tree, avatar_restorer, [repo_restorer, wiki_restorer, project_tree, avatar_restorer,
uploads_restorer, lfs_restorer, statistics_restorer] uploads_restorer, lfs_restorer, statistics_restorer]
end end
   
def import_file def import_file
Gitlab::ImportExport::FileImporter.import(project: @project, Gitlab::ImportExport::FileImporter.import(project: project,
archive_file: @archive_file, archive_file: archive_file,
shared: @shared) shared: shared)
end end
   
def check_version! def check_version!
Gitlab::ImportExport::VersionChecker.check!(shared: @shared) Gitlab::ImportExport::VersionChecker.check!(shared: shared)
end end
   
def project_tree def project_tree
@project_tree ||= Gitlab::ImportExport::ProjectTreeRestorer.new(user: @current_user, @project_tree ||= Gitlab::ImportExport::ProjectTreeRestorer.new(user: current_user,
shared: @shared, shared: shared,
project: @project) project: project)
end end
   
def avatar_restorer def avatar_restorer
Gitlab::ImportExport::AvatarRestorer.new(project: project_tree.restored_project, shared: @shared) Gitlab::ImportExport::AvatarRestorer.new(project: project_tree.restored_project, shared: shared)
end end
   
def repo_restorer def repo_restorer
Gitlab::ImportExport::RepoRestorer.new(path_to_bundle: repo_path, Gitlab::ImportExport::RepoRestorer.new(path_to_bundle: repo_path,
shared: @shared, shared: shared,
project: project_tree.restored_project) project: project_tree.restored_project)
end end
   
def wiki_restorer def wiki_restorer
Gitlab::ImportExport::WikiRestorer.new(path_to_bundle: wiki_repo_path, Gitlab::ImportExport::WikiRestorer.new(path_to_bundle: wiki_repo_path,
shared: @shared, shared: shared,
project: ProjectWiki.new(project_tree.restored_project), project: ProjectWiki.new(project_tree.restored_project),
wiki_enabled: @project.wiki_enabled?) wiki_enabled: project.wiki_enabled?)
end end
   
def uploads_restorer def uploads_restorer
Gitlab::ImportExport::UploadsRestorer.new(project: project_tree.restored_project, shared: @shared) Gitlab::ImportExport::UploadsRestorer.new(project: project_tree.restored_project, shared: shared)
end end
   
def lfs_restorer def lfs_restorer
Gitlab::ImportExport::LfsRestorer.new(project: project_tree.restored_project, shared: @shared) Gitlab::ImportExport::LfsRestorer.new(project: project_tree.restored_project, shared: shared)
end end
   
def statistics_restorer def statistics_restorer
Gitlab::ImportExport::StatisticsRestorer.new(project: project_tree.restored_project, shared: @shared) Gitlab::ImportExport::StatisticsRestorer.new(project: project_tree.restored_project, shared: shared)
end end
   
def path_with_namespace def path_with_namespace
File.join(@project.namespace.full_path, @project.path) File.join(project.namespace.full_path, project.path)
end end
   
def repo_path def repo_path
File.join(@shared.export_path, 'project.bundle') File.join(shared.export_path, Gitlab::ImportExport.project_bundle_filename)
end end
   
def wiki_repo_path def wiki_repo_path
File.join(@shared.export_path, 'project.wiki.bundle') File.join(shared.export_path, Gitlab::ImportExport.wiki_repo_bundle_filename)
end end
   
def remove_import_file def remove_import_file
upload = @project.import_export_upload upload = project.import_export_upload
   
return unless upload&.import_file&.file return unless upload&.import_file&.file
   
Loading
@@ -105,10 +107,10 @@ module Gitlab
Loading
@@ -105,10 +107,10 @@ module Gitlab
def overwrite_project def overwrite_project
project = project_tree.restored_project project = project_tree.restored_project
   
return unless can?(@current_user, :admin_namespace, project.namespace) return unless can?(current_user, :admin_namespace, project.namespace)
   
if overwrite_project? if overwrite_project?
::Projects::OverwriteProjectService.new(project, @current_user) ::Projects::OverwriteProjectService.new(project, current_user)
.execute(project_to_overwrite) .execute(project_to_overwrite)
end end
   
Loading
@@ -116,7 +118,7 @@ module Gitlab
Loading
@@ -116,7 +118,7 @@ module Gitlab
end end
   
def original_path def original_path
@project.import_data&.data&.fetch('original_path', nil) project.import_data&.data&.fetch('original_path', nil)
end end
   
def overwrite_project? def overwrite_project?
Loading
@@ -125,9 +127,11 @@ module Gitlab
Loading
@@ -125,9 +127,11 @@ module Gitlab
   
def project_to_overwrite def project_to_overwrite
strong_memoize(:project_to_overwrite) do strong_memoize(:project_to_overwrite) do
Project.find_by_full_path("#{@project.namespace.full_path}/#{original_path}") Project.find_by_full_path("#{project.namespace.full_path}/#{original_path}")
end end
end end
end end
end end
end end
Gitlab::ImportExport::Importer.prepend_if_ee('EE::Gitlab::ImportExport::Importer')
Loading
@@ -93,6 +93,10 @@ module Gitlab
Loading
@@ -93,6 +93,10 @@ module Gitlab
end end
end end
   
def remove_feature_dependent_sub_relations(_relation_item)
# no-op
end
def project_relations_without_project_members def project_relations_without_project_members
# We remove `project_members` as they are deserialized separately # We remove `project_members` as they are deserialized separately
project_relations.except(:project_members) project_relations.except(:project_members)
Loading
@@ -171,6 +175,8 @@ module Gitlab
Loading
@@ -171,6 +175,8 @@ module Gitlab
next next
end end
   
remove_feature_dependent_sub_relations(relation_item)
# The transaction at this level is less speedy than one single transaction # The transaction at this level is less speedy than one single transaction
# But we can't have it in the upper level or GC won't get rid of the AR objects # But we can't have it in the upper level or GC won't get rid of the AR objects
# after we save the batch. # after we save the batch.
Loading
@@ -238,3 +244,5 @@ module Gitlab
Loading
@@ -238,3 +244,5 @@ module Gitlab
end end
end end
end end
Gitlab::ImportExport::ProjectTreeRestorer.prepend_if_ee('::EE::Gitlab::ImportExport::ProjectTreeRestorer')
Loading
@@ -34,13 +34,13 @@ module Gitlab
Loading
@@ -34,13 +34,13 @@ module Gitlab
   
PROJECT_REFERENCES = %w[project_id source_project_id target_project_id].freeze PROJECT_REFERENCES = %w[project_id source_project_id target_project_id].freeze
   
BUILD_MODELS = %w[Ci::Build commit_status].freeze BUILD_MODELS = %i[Ci::Build commit_status].freeze
   
IMPORTED_OBJECT_MAX_RETRIES = 5.freeze IMPORTED_OBJECT_MAX_RETRIES = 5.freeze
   
EXISTING_OBJECT_CHECK = %i[milestone milestones label labels project_label project_labels group_label group_labels project_feature].freeze EXISTING_OBJECT_CHECK = %i[milestone milestones label labels project_label project_labels group_label group_labels project_feature].freeze
   
TOKEN_RESET_MODELS = %w[Project Namespace Ci::Trigger Ci::Build Ci::Runner ProjectHook].freeze TOKEN_RESET_MODELS = %i[Project Namespace Ci::Trigger Ci::Build Ci::Runner ProjectHook].freeze
   
def self.create(*args) def self.create(*args)
new(*args).create new(*args).create
Loading
@@ -56,7 +56,7 @@ module Gitlab
Loading
@@ -56,7 +56,7 @@ module Gitlab
end end
   
def initialize(relation_sym:, relation_hash:, members_mapper:, user:, project:, excluded_keys: []) def initialize(relation_sym:, relation_hash:, members_mapper:, user:, project:, excluded_keys: [])
@relation_name = self.class.overrides[relation_sym] || relation_sym @relation_name = self.class.overrides[relation_sym]&.to_sym || relation_sym
@relation_hash = relation_hash.except('noteable_id') @relation_hash = relation_hash.except('noteable_id')
@members_mapper = members_mapper @members_mapper = members_mapper
@user = user @user = user
Loading
@@ -92,6 +92,10 @@ module Gitlab
Loading
@@ -92,6 +92,10 @@ module Gitlab
OVERRIDES OVERRIDES
end end
   
def self.existing_object_check
EXISTING_OBJECT_CHECK
end
private private
   
def setup_models def setup_models
Loading
@@ -105,7 +109,7 @@ module Gitlab
Loading
@@ -105,7 +109,7 @@ module Gitlab
update_group_references update_group_references
remove_duplicate_assignees remove_duplicate_assignees
   
setup_pipeline if @relation_name == 'Ci::Pipeline' setup_pipeline if @relation_name == :'Ci::Pipeline'
   
reset_tokens! reset_tokens!
remove_encrypted_attributes! remove_encrypted_attributes!
Loading
@@ -184,14 +188,14 @@ module Gitlab
Loading
@@ -184,14 +188,14 @@ module Gitlab
end end
   
def update_group_references def update_group_references
return unless EXISTING_OBJECT_CHECK.include?(@relation_name) return unless self.class.existing_object_check.include?(@relation_name)
return unless @relation_hash['group_id'] return unless @relation_hash['group_id']
   
@relation_hash['group_id'] = @project.namespace_id @relation_hash['group_id'] = @project.namespace_id
end end
   
def reset_tokens! def reset_tokens!
return unless Gitlab::ImportExport.reset_tokens? && TOKEN_RESET_MODELS.include?(@relation_name.to_s) return unless Gitlab::ImportExport.reset_tokens? && TOKEN_RESET_MODELS.include?(@relation_name)
   
# If we import/export a project to the same instance, tokens will have to be reset. # If we import/export a project to the same instance, tokens will have to be reset.
# We also have to reset them to avoid issues when the gitlab secrets file cannot be copied across. # We also have to reset them to avoid issues when the gitlab secrets file cannot be copied across.
Loading
@@ -255,7 +259,7 @@ module Gitlab
Loading
@@ -255,7 +259,7 @@ module Gitlab
# Only find existing records to avoid mapping tables such as milestones # Only find existing records to avoid mapping tables such as milestones
# Otherwise always create the record, skipping the extra SELECT clause. # Otherwise always create the record, skipping the extra SELECT clause.
@existing_or_new_object ||= begin @existing_or_new_object ||= begin
if EXISTING_OBJECT_CHECK.include?(@relation_name) if self.class.existing_object_check.include?(@relation_name)
attribute_hash = attribute_hash_for(['events']) attribute_hash = attribute_hash_for(['events'])
   
existing_object.assign_attributes(attribute_hash) if attribute_hash.any? existing_object.assign_attributes(attribute_hash) if attribute_hash.any?
Loading
@@ -284,7 +288,7 @@ module Gitlab
Loading
@@ -284,7 +288,7 @@ module Gitlab
end end
   
def legacy_trigger? def legacy_trigger?
@relation_name == 'Ci::Trigger' && @relation_hash['owner_id'].nil? @relation_name == :'Ci::Trigger' && @relation_hash['owner_id'].nil?
end end
   
def find_or_create_object! def find_or_create_object!
Loading
@@ -293,7 +297,7 @@ module Gitlab
Loading
@@ -293,7 +297,7 @@ module Gitlab
# Can't use IDs as validation exists calling `group` or `project` attributes # Can't use IDs as validation exists calling `group` or `project` attributes
finder_hash = parsed_relation_hash.tap do |hash| finder_hash = parsed_relation_hash.tap do |hash|
hash['group'] = @project.group if relation_class.attribute_method?('group_id') hash['group'] = @project.group if relation_class.attribute_method?('group_id')
hash['project'] = @project hash['project'] = @project if relation_class.reflect_on_association(:project)
hash.delete('project_id') hash.delete('project_id')
end end
   
Loading
Loading
Loading
@@ -6,19 +6,23 @@ module Gitlab
Loading
@@ -6,19 +6,23 @@ module Gitlab
include Gitlab::ImportExport::CommandLineUtil include Gitlab::ImportExport::CommandLineUtil
   
def initialize(project:, shared:, path_to_bundle:) def initialize(project:, shared:, path_to_bundle:)
@project = project @repository = project.repository
@path_to_bundle = path_to_bundle @path_to_bundle = path_to_bundle
@shared = shared @shared = shared
end end
   
def restore def restore
return true unless File.exist?(@path_to_bundle) return true unless File.exist?(path_to_bundle)
   
@project.repository.create_from_bundle(@path_to_bundle) repository.create_from_bundle(path_to_bundle)
rescue => e rescue => e
@shared.error(e) shared.error(e)
false false
end end
private
attr_accessor :repository, :path_to_bundle, :shared
end end
end end
end end
Loading
@@ -5,27 +5,35 @@ module Gitlab
Loading
@@ -5,27 +5,35 @@ module Gitlab
class RepoSaver class RepoSaver
include Gitlab::ImportExport::CommandLineUtil include Gitlab::ImportExport::CommandLineUtil
   
attr_reader :full_path attr_reader :project, :repository, :shared
   
def initialize(project:, shared:) def initialize(project:, shared:)
@project = project @project = project
@shared = shared @shared = shared
@repository = @project.repository
end end
   
def save def save
return true if @project.empty_repo? # it's ok to have no repo return true unless repository_exists? # it's ok to have no repo
   
@full_path = File.join(@shared.export_path, ImportExport.project_bundle_filename)
bundle_to_disk bundle_to_disk
end end
   
private private
   
def repository_exists?
repository.exists? && !repository.empty?
end
def bundle_full_path
File.join(shared.export_path, ImportExport.project_bundle_filename)
end
def bundle_to_disk def bundle_to_disk
mkdir_p(@shared.export_path) mkdir_p(shared.export_path)
@project.repository.bundle_to_disk(@full_path) repository.bundle_to_disk(bundle_full_path)
rescue => e rescue => e
@shared.error(e) shared.error(e)
false false
end end
end end
Loading
Loading
Loading
@@ -4,28 +4,16 @@ module Gitlab
Loading
@@ -4,28 +4,16 @@ module Gitlab
module ImportExport module ImportExport
class WikiRepoSaver < RepoSaver class WikiRepoSaver < RepoSaver
def save def save
@wiki = ProjectWiki.new(@project) wiki = ProjectWiki.new(project)
return true unless wiki_repository_exists? # it's okay to have no Wiki @repository = wiki.repository
   
bundle_to_disk(File.join(@shared.export_path, project_filename)) super
end
def bundle_to_disk(full_path)
mkdir_p(@shared.export_path)
@wiki.repository.bundle_to_disk(full_path)
rescue => e
@shared.error(e)
false
end end
   
private private
   
def project_filename def bundle_full_path
"project.wiki.bundle" File.join(shared.export_path, ImportExport.wiki_repo_bundle_filename)
end
def wiki_repository_exists?
@wiki.repository.exists? && !@wiki.repository.empty?
end end
end end
end end
Loading
Loading
Loading
@@ -6,19 +6,22 @@ module Gitlab
Loading
@@ -6,19 +6,22 @@ module Gitlab
def initialize(project:, shared:, path_to_bundle:, wiki_enabled:) def initialize(project:, shared:, path_to_bundle:, wiki_enabled:)
super(project: project, shared: shared, path_to_bundle: path_to_bundle) super(project: project, shared: shared, path_to_bundle: path_to_bundle)
   
@project = project
@wiki_enabled = wiki_enabled @wiki_enabled = wiki_enabled
end end
   
def restore def restore
@project.wiki if create_empty_wiki? project.wiki if create_empty_wiki?
   
super super
end end
   
private private
   
attr_accessor :project, :wiki_enabled
def create_empty_wiki? def create_empty_wiki?
!File.exist?(@path_to_bundle) && @wiki_enabled !File.exist?(path_to_bundle) && wiki_enabled
end end
end end
end end
Loading
Loading
Loading
@@ -5185,6 +5185,9 @@ msgstr ""
Loading
@@ -5185,6 +5185,9 @@ msgstr ""
msgid "Deselect all" msgid "Deselect all"
msgstr "" msgstr ""
   
msgid "Design Management files and data"
msgstr ""
msgid "DesignManagement|%{current_design} of %{designs_count}" msgid "DesignManagement|%{current_design} of %{designs_count}"
msgstr "" msgstr ""
   
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment