Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-05-20 06:08:54 +00:00
parent 8f61d95047
commit 9558f52fd8
24 changed files with 261 additions and 84 deletions

View file

@ -483,7 +483,7 @@ gem 'ssh_data', '~> 1.2'
gem 'spamcheck', '~> 0.1.0'
# Gitaly GRPC protocol definitions
gem 'gitaly', '~> 14.10.0-rc1'
gem 'gitaly', '~> 15.0.0-rc3'
# KAS GRPC protocol definitions
gem 'kas-grpc', '~> 0.0.2'

View file

@ -465,7 +465,7 @@ GEM
rails (>= 3.2.0)
git (1.7.0)
rchardet (~> 1.8)
gitaly (14.10.0.pre.rc1)
gitaly (15.0.0.pre.rc3)
grpc (~> 1.0)
github-markup (1.7.0)
gitlab (4.16.1)
@ -1499,7 +1499,7 @@ DEPENDENCIES
gettext (~> 3.3)
gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3)
gitaly (~> 14.10.0.pre.rc1)
gitaly (~> 15.0.0.pre.rc3)
github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5)
gitlab-dangerfiles (~> 3.0)

View file

@ -9,6 +9,7 @@ module BulkImports
).freeze
LFS_OBJECTS_RELATION = 'lfs_objects'
REPOSITORY_BUNDLE_RELATION = 'repository_bundle'
def import_export_yaml
::Gitlab::ImportExport.config_file
@ -19,7 +20,7 @@ module BulkImports
end
def file_relations
[UPLOADS_RELATION, LFS_OBJECTS_RELATION]
[UPLOADS_RELATION, LFS_OBJECTS_RELATION, REPOSITORY_BUNDLE_RELATION]
end
end
end

View file

@ -30,6 +30,8 @@ module BulkImports
UploadsExportService.new(portable, export_path)
when FileTransfer::ProjectConfig::LFS_OBJECTS_RELATION
LfsObjectsExportService.new(portable, export_path)
when FileTransfer::ProjectConfig::REPOSITORY_BUNDLE_RELATION
RepositoryBundleExportService.new(portable, export_path)
else
raise BulkImports::Error, 'Unsupported relation export type'
end

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
module BulkImports
class RepositoryBundleExportService
FILENAME = 'project.bundle'
def initialize(portable, export_path)
@portable = portable
@export_path = export_path
@repository = portable.repository
end
def execute
repository.bundle_to_disk(bundle_filepath) if repository.exists?
end
private
attr_reader :portable, :export_path, :repository
def bundle_filepath
File.join(export_path, FILENAME)
end
end
end

View file

@ -1,4 +1,4 @@
- name: "Support for legacy format of `config/database.yml` removed"
- name: "Support for legacy format of `config/database.yml`"
announcement_milestone: "14.3"
announcement_date: "2021-09-22"
removal_milestone: "15.0"

View file

@ -1,4 +1,4 @@
- name: "Remove `promote-to-primary-node` command from `gitlab-ctl`"
- name: "`promote-to-primary-node` command from `gitlab-ctl`"
announcement_milestone: "14.5"
announcement_date: "2021-11-22"
removal_milestone: "15.0"

View file

@ -1,4 +1,4 @@
- name: "Remove dependency_proxy_for_private_groups feature flag" # The name of the feature to be deprecated
- name: "`dependency_proxy_for_private_groups` feature flag" # The name of the feature to be deprecated
announcement_milestone: "14.5" # The milestone when this feature was first announced as deprecated.
announcement_date: "2021-11-22" # The date of the milestone release when this feature was first announced as deprecated. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
removal_milestone: "15.0" # The milestone when this feature is planned to be removed

View file

@ -1,4 +1,4 @@
- name: "Remove Versions from PackageType"
- name: "Versions from `PackageType`"
announcement_milestone: "14.5" # The milestone when this feature was first announced as deprecated.
announcement_date: "2021-11-22" # The date of the milestone release when this feature was first announced as deprecated. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
removal_milestone: "15.0" # The milestone when this feature is planned to be removed

View file

@ -1,4 +1,4 @@
- name: "Removed feature flag PUSH_RULES_SUPERSEDE_CODE_OWNERS" # The name of the feature to be deprecated
- name: "`push_rules_supersede_code_owners` feature flag" # The name of the feature to be deprecated
announcement_milestone: "14.8" # The milestone when this feature was first announced as deprecated.
announcement_date: "2022-02-22" # The date of the milestone release when this feature was first announced as deprecated. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
removal_milestone: "15.0" # The milestone when this feature is planned to be removed
@ -6,7 +6,7 @@
breaking_change: true # If this deprecation is a breaking change, set this value to true
reporter: tlinz # GitLab username of the person reporting the deprecation
body: | # Do not modify this line, instead modify the lines below.
The feature flag `PUSH_RULES_SUPERSEDE_CODE_OWNERS` has been removed in GitLab 15.0. From now on, push rules will supersede CODEOWNERS. The CODEOWNERS feature is no longer available for access control.
The `push_rules_supersede_code_owners` feature flag has been removed in GitLab 15.0. From now on, push rules will supersede the `CODEOWNERS` file. The code owners feature is no longer available for access control.
# The following items are not published on the docs page, but may be used in the future.
stage: create # (optional - may be required in the future) String value of the stage that the feature was created in. e.g., Growth
tiers: # (optional - may be required in the future) An array of tiers that the feature is available in currently. e.g., [Free, Silver, Gold, Core, Premium, Ultimate]

View file

@ -1,4 +1,4 @@
- name: "Jaeger integration removed in GitLab 15.0" # The headline announcing the removal. i.e. "`CI_PROJECT_CONFIG_PATH` removed in Gitlab 14.0"
- name: "Jaeger integration" # The headline announcing the removal. i.e. "`CI_PROJECT_CONFIG_PATH` removed in Gitlab 14.0"
announcement_milestone: "14.7" # The milestone when this feature was first announced as deprecated.
announcement_date: "2022-01-22"
removal_milestone: "15.0" # The milestone when this feature is being removed.

View file

@ -1,4 +1,4 @@
- name: "Remove `type` and `types` keyword from CI/CD configuration"
- name: "`type` and `types` keyword from CI/CD configuration"
announcement_milestone: "14.6"
announcement_date: "2021-12-22"
removal_milestone: "15.0"

View file

@ -1,4 +1,4 @@
- name: "ELK stack logging removed in GitLab 15.0" # The headline announcing the removal. i.e. "`CI_PROJECT_CONFIG_PATH` removed in Gitlab 14.0"
- name: "ELK stack logging" # The headline announcing the removal. i.e. "`CI_PROJECT_CONFIG_PATH` removed in Gitlab 14.0"
announcement_milestone: "14.7" # The milestone when this feature was deprecated.
announcement_date: "2022-01-22" # The date of the milestone release when this feature was deprecated. This should almost always be the 22nd of a month (YYYY-MM-DD), unless you did an out of band blog post.
removal_milestone: "15.0" # The milestone when this feature is being removed.

View file

@ -1,4 +1,4 @@
- name: "Remove pipelines field from the version field" # The name of the feature to be deprecated
- name: "Pipelines field from the version field" # The name of the feature to be deprecated
announcement_milestone: "14.5" # The milestone when this feature was first announced as deprecated.
announcement_date: "2021-11-22" # The date of the milestone release when this feature was first announced as deprecated. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
removal_milestone: "15.0" # The milestone when this feature is planned to be removed

View file

@ -151,7 +151,7 @@ changes to your code, settings, or workflow.
For Dependency Scanning, the default version of Java that the scanner expects will be updated from 11 to 17. Java 17 is [the most up-to-date Long Term Support (LTS) version](https://en.wikipedia.org/wiki/Java_version_history). Dependency Scanning continues to support the same [range of versions (8, 11, 13, 14, 15, 16, 17)](https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#supported-languages-and-package-managers), only the default version is changing. If your project uses the previous default of Java 11, be sure to [set the `DS_JAVA_VERSION` variable to match](https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#configuring-specific-analyzers-used-by-dependency-scanning). Please note that consequently the default version of Gradle is now 7.3.3.
### ELK stack logging removed in GitLab 15.0
### ELK stack logging
WARNING:
This feature was changed or removed in 15.0
@ -253,7 +253,7 @@ The permissions model for GraphQL is being updated. After 15.0, users with the G
The issue for this removal is [GitLab-#350682](https://gitlab.com/gitlab-org/gitlab/-/issues/350682)
### Jaeger integration removed in GitLab 15.0
### Jaeger integration
WARNING:
This feature was changed or removed in 15.0
@ -364,62 +364,7 @@ As of GitLab 15.0, we've:
If you rely on Java 8 being present in the analyzer environment, you must take action as detailed in the [deprecation issue for this change](https://gitlab.com/gitlab-org/gitlab/-/issues/352549#breaking-change).
### Pseudonymizer
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
The Pseudonymizer feature is generally unused, can cause production issues with large databases, and can interfere with object storage development.
It was removed in GitLab 15.0.
### Remove Versions from PackageType
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
As part of the work to create a [Package Registry GraphQL API](https://gitlab.com/groups/gitlab-org/-/epics/6318), the Package group deprecated the `Version` type for the basic `PackageType` type and moved it to [`PackageDetailsType`](https://docs.gitlab.com/ee/api/graphql/reference/index.html#packagedetailstype).
In GitLab 15.0, we will completely remove `Version` from `PackageType`.
### Remove `promote-to-primary-node` command from `gitlab-ctl`
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
In GitLab 14.5, we introduced the command `gitlab-ctl promote` to promote any Geo secondary node to a primary during a failover. This command replaces `gitlab-ctl promote-to-primary-node` which was only usable for single-node Geo sites. `gitlab-ctl promote-to-primary-node` has been removed in GitLab 15.0.
### Remove `type` and `types` keyword from CI/CD configuration
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
The `type` and `types` CI/CD keywords is removed in GitLab 15.0, so pipelines that use these keywords fail with a syntax error. Switch to `stage` and `stages`, which have the same behavior.
### Remove dependency_proxy_for_private_groups feature flag
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
A feature flag was [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/11582) in GitLab 13.7 as part of the change to require authentication to use the Dependency Proxy. Before GitLab 13.7, you could use the Dependency Proxy without authentication.
In GitLab 15.0, we will remove the feature flag, and you must always authenticate when you use the Dependency Proxy.
### Remove pipelines field from the version field
### Pipelines field from the version field
WARNING:
This feature was changed or removed in 15.0
@ -434,7 +379,7 @@ In GraphQL, there are two `pipelines` fields that you can use in a [`PackageDeta
To mitigate possible performance problems, we will remove the `versions` field's `pipelines` field in GitLab 15.0. Although you will no longer be able to get all pipelines for all versions of a package, you can still get the pipelines of a single version through the remaining `pipelines` field for that version.
### Removed feature flag PUSH_RULES_SUPERSEDE_CODE_OWNERS
### Pseudonymizer
WARNING:
This feature was changed or removed in 15.0
@ -442,7 +387,8 @@ as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#brea
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
The feature flag `PUSH_RULES_SUPERSEDE_CODE_OWNERS` has been removed in GitLab 15.0. From now on, push rules will supersede CODEOWNERS. The CODEOWNERS feature is no longer available for access control.
The Pseudonymizer feature is generally unused, can cause production issues with large databases, and can interfere with object storage development.
It was removed in GitLab 15.0.
### Request profiling
@ -588,7 +534,7 @@ changes to your code, settings, or workflow.
Gitaly introduced a new directory that holds all runtime data Gitaly requires to operate correctly. This new directory replaces the old internal socket directory, and consequentially the usage of `gitaly['internal_socket_dir']` was deprecated in favor of `gitaly['runtime_dir']`.
### Support for legacy format of `config/database.yml` removed
### Support for legacy format of `config/database.yml`
WARNING:
This feature was changed or removed in 15.0
@ -641,6 +587,18 @@ In GitLab 15.0, support for the `tags` and `tags_count` parameters will be remov
The `GET /groups/:id/registry/repositories` endpoint will remain, but won't return any info about tags. To get the info about tags, you can use the existing `GET /registry/repositories/:id` endpoint, which will continue to support the `tags` and `tag_count` options as it does today. The latter must be called once per image repository.
### Versions from `PackageType`
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
As part of the work to create a [Package Registry GraphQL API](https://gitlab.com/groups/gitlab-org/-/epics/6318), the Package group deprecated the `Version` type for the basic `PackageType` type and moved it to [`PackageDetailsType`](https://docs.gitlab.com/ee/api/graphql/reference/index.html#packagedetailstype).
In GitLab 15.0, we will completely remove `Version` from `PackageType`.
### Vulnerability Check
WARNING:
@ -685,6 +643,18 @@ changes to your code, settings, or workflow.
The GraphQL API field `defaultMergeCommitMessageWithDescription` has been removed in GitLab 15.0. For projects with a commit message template set, it will ignore the template.
### `dependency_proxy_for_private_groups` feature flag
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
A feature flag was [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/11582) in GitLab 13.7 as part of the change to require authentication to use the Dependency Proxy. Before GitLab 13.7, you could use the Dependency Proxy without authentication.
In GitLab 15.0, we will remove the feature flag, and you must always authenticate when you use the Dependency Proxy.
### `omniauth-kerberos` gem
WARNING:
@ -700,6 +670,36 @@ to upgrade from the removed integration to the new supported one.
We are not removing Kerberos SPNEGO integration. We are removing the old password-based Kerberos.
### `promote-to-primary-node` command from `gitlab-ctl`
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
In GitLab 14.5, we introduced the command `gitlab-ctl promote` to promote any Geo secondary node to a primary during a failover. This command replaces `gitlab-ctl promote-to-primary-node` which was only usable for single-node Geo sites. `gitlab-ctl promote-to-primary-node` has been removed in GitLab 15.0.
### `push_rules_supersede_code_owners` feature flag
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
The `push_rules_supersede_code_owners` feature flag has been removed in GitLab 15.0. From now on, push rules will supersede the `CODEOWNERS` file. The code owners feature is no longer available for access control.
### `type` and `types` keyword from CI/CD configuration
WARNING:
This feature was changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
The `type` and `types` CI/CD keywords is removed in GitLab 15.0, so pipelines that use these keywords fail with a syntax error. Switch to `stage` and `stages`, which have the same behavior.
### bundler-audit Dependency Scanning tool
WARNING:

View file

@ -324,8 +324,12 @@ git config --global user.email <your email address>
## User activity
GitLab tracks user contribution activity.
You can follow or unfollow other users from their [user profiles](#access-your-user-profile).
GitLab tracks user contribution activity. You can follow or unfollow other users from either:
- Their [user profiles](#access-your-user-profile).
- The small popover that appears when you hover over a user's name ([introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76050)
in GitLab 15.0).
To view a user's activity in a top-level Activity view:
1. From a user's profile, select **Follow**.

View file

@ -74,7 +74,7 @@ The following items are **not** exported:
- [Child pipeline history](https://gitlab.com/gitlab-org/gitlab/-/issues/221088)
- Build traces and artifacts
- Container registry images
- Package and container registry images
- CI/CD variables
- Pipeline triggers
- Webhooks

View file

@ -163,6 +163,15 @@ module Gitlab
access_check_error = detailed_error.access_check
# These messages were returned from internal/allowed API calls
raise Gitlab::Git::PreReceiveError.new(fallback_message: access_check_error.error_message)
when :custom_hook
# Custom hooks may return messages via either stdout or stderr which have a specific prefix. If
# that prefix is present we'll want to print the hook's output, otherwise we'll want to print the
# Gitaly error as a fallback.
custom_hook_error = detailed_error.custom_hook
custom_hook_output = custom_hook_error.stderr.presence || custom_hook_error.stdout
error_message = EncodingHelper.encode!(custom_hook_output)
raise Gitlab::Git::PreReceiveError.new(error_message, fallback_message: e.details)
when :reference_update
# We simply ignore any reference update errors which are typically an
# indicator of multiple RPC calls trying to update the same reference

View file

@ -35328,6 +35328,12 @@ msgstr ""
msgid "SlackIntegration|Are you sure you want to remove this project from the Slack application?"
msgstr ""
msgid "SlackIntegration|Client ID"
msgstr ""
msgid "SlackIntegration|Client secret"
msgstr ""
msgid "SlackIntegration|GitLab for Slack"
msgstr ""
@ -35355,7 +35361,7 @@ msgstr ""
msgid "SlackIntegration|Sends notifications about project events to Slack channels."
msgstr ""
msgid "SlackIntegration|Signing Secret"
msgid "SlackIntegration|Signing secret"
msgstr ""
msgid "SlackIntegration|Team name"
@ -35364,6 +35370,9 @@ msgstr ""
msgid "SlackIntegration|This integration allows users to perform common operations on this project by entering slash commands in Slack."
msgstr ""
msgid "SlackIntegration|Verification token"
msgstr ""
msgid "SlackIntegration|You can now close this window and go to your Slack workspace."
msgstr ""

View file

@ -2,7 +2,7 @@
module QA
RSpec.describe 'Manage' do
describe 'Project access token' do
describe 'Project access token', :reliable do
before(:all) do
@project_access_token = QA::Resource::ProjectAccessToken.fabricate_via_api! do |pat|
pat.project = Resource::ReusableProject.fabricate_via_api!
@ -11,7 +11,7 @@ module QA
@user_api_client = Runtime::API::Client.new(:gitlab, personal_access_token: @project_access_token.token)
end
context 'for the same project', :reliable do
context 'for the same project' do
it 'can be used to create a file via the project API', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347858' do
expect do
Resource::File.fabricate_via_api! do |file|

View file

@ -212,6 +212,82 @@ RSpec.describe Gitlab::GitalyClient::OperationService do
end
end
context 'with a custom hook error' do
let(:stdout) { nil }
let(:stderr) { nil }
let(:error_message) { "error_message" }
let(:custom_hook_error) do
new_detailed_error(
GRPC::Core::StatusCodes::PERMISSION_DENIED,
error_message,
Gitaly::UserMergeBranchError.new(
custom_hook: Gitaly::CustomHookError.new(
stdout: stdout,
stderr: stderr,
hook_type: Gitaly::CustomHookError::HookType::HOOK_TYPE_PRERECEIVE
)))
end
shared_examples 'a failed merge' do
it 'raises a PreRecieveError' do
expect_any_instance_of(Gitaly::OperationService::Stub)
.to receive(:user_merge_branch).with(kind_of(Enumerator), kind_of(Hash))
.and_raise(custom_hook_error)
expect { subject }.to raise_error do |error|
expect(error).to be_a(Gitlab::Git::PreReceiveError)
expect(error.message).to eq(expected_message)
expect(error.raw_message).to eq(expected_raw_message)
end
end
end
context 'when details contain stderr without prefix' do
let(:stderr) { "something" }
let(:stdout) { "GL-HOOK-ERR: stdout is overridden by stderr" }
let(:expected_message) { error_message }
let(:expected_raw_message) { stderr }
it_behaves_like 'a failed merge'
end
context 'when details contain stderr with prefix' do
let(:stderr) { "GL-HOOK-ERR: something" }
let(:stdout) { "GL-HOOK-ERR: stdout is overridden by stderr" }
let(:expected_message) { "something" }
let(:expected_raw_message) { stderr }
it_behaves_like 'a failed merge'
end
context 'when details contain stdout without prefix' do
let(:stderr) { " \n" }
let(:stdout) { "something" }
let(:expected_message) { error_message }
let(:expected_raw_message) { stdout }
it_behaves_like 'a failed merge'
end
context 'when details contain stdout with prefix' do
let(:stderr) { " \n" }
let(:stdout) { "GL-HOOK-ERR: something" }
let(:expected_message) { "something" }
let(:expected_raw_message) { stdout }
it_behaves_like 'a failed merge'
end
context 'when details contain no stderr or stdout' do
let(:stderr) { " \n" }
let(:stdout) { "\n \n" }
let(:expected_message) { error_message }
let(:expected_raw_message) { "\n \n" }
it_behaves_like 'a failed merge'
end
end
context 'with an exception without the detailed error' do
let(:permission_error) do
GRPC::PermissionDenied.new

View file

@ -94,7 +94,7 @@ RSpec.describe BulkImports::FileTransfer::ProjectConfig do
describe '#file_relations' do
it 'returns project file relations' do
expect(subject.file_relations).to contain_exactly('uploads', 'lfs_objects')
expect(subject.file_relations).to contain_exactly('uploads', 'lfs_objects', 'repository_bundle')
end
end
end

View file

@ -5,7 +5,8 @@ require 'spec_helper'
RSpec.describe BulkImports::FileExportService do
let_it_be(:project) { create(:project) }
let_it_be(:export_path) { Dir.mktmpdir }
let_it_be(:relation) { BulkImports::FileTransfer::BaseConfig::UPLOADS_RELATION }
let(:relation) { BulkImports::FileTransfer::BaseConfig::UPLOADS_RELATION }
subject(:service) { described_class.new(project, export_path, relation) }
@ -21,7 +22,7 @@ RSpec.describe BulkImports::FileExportService do
end
context 'when relation is lfs objects' do
let_it_be(:relation) { BulkImports::FileTransfer::ProjectConfig::LFS_OBJECTS_RELATION }
let(:relation) { BulkImports::FileTransfer::ProjectConfig::LFS_OBJECTS_RELATION }
it 'executes lfs objects export service' do
expect_next_instance_of(BulkImports::LfsObjectsExportService) do |service|
@ -34,6 +35,22 @@ RSpec.describe BulkImports::FileExportService do
end
end
context 'when relation is repository bundle' do
let(:relation) { BulkImports::FileTransfer::ProjectConfig::REPOSITORY_BUNDLE_RELATION }
it 'executes repository bundle export service' do
expect_next_instance_of(BulkImports::RepositoryBundleExportService) do |service|
expect(service).to receive(:execute)
end
expect(subject)
.to receive(:tar_cf)
.with(archive: File.join(export_path, 'repository_bundle.tar'), dir: export_path)
subject.execute
end
end
context 'when unsupported relation is passed' do
it 'raises an error' do
service = described_class.new(project, export_path, 'unsupported')

View file

@ -0,0 +1,34 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::RepositoryBundleExportService do
let(:project) { build(:project) }
let(:export_path) { Dir.mktmpdir }
subject(:service) { described_class.new(project, export_path) }
after do
FileUtils.remove_entry(export_path) if Dir.exist?(export_path)
end
describe '#execute' do
context 'when repository exists' do
it 'bundles repository to disk' do
allow(project.repository).to receive(:exists?).and_return(true)
expect(project.repository).to receive(:bundle_to_disk).with(File.join(export_path, 'project.bundle'))
service.execute
end
end
context 'when repository does not exist' do
it 'does not bundle repository to disk' do
allow(project.repository).to receive(:exists?).and_return(false)
expect(project.repository).not_to receive(:bundle_to_disk)
service.execute
end
end
end
end