Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-12-01 21:13:44 +00:00
parent 5fc2d78fb9
commit 7b78125a38
26 changed files with 144 additions and 105 deletions

View File

@ -1 +1 @@
f87bc1e983d11788fdbce953dced45ec5554af23
4dd8bfe1307ffcc5a2a3f4eb70da7977a7c1d915

View File

@ -171,7 +171,7 @@ export default {
:icon-name="statusIconName"
/>
<div
class="media-body gl-display-flex gl-flex-direction-row!"
class="media-body gl-display-flex gl-flex-direction-row! gl-align-self-center"
data-testid="widget-extension-top-level"
>
<div class="gl-flex-grow-1">

View File

@ -9,7 +9,7 @@ export default {
pipelineFailed: s__(
'mrWidget|The pipeline for this merge request did not complete. Push a new commit to fix the failure.',
),
approvalNeeded: s__('mrWidget|You can only merge once this merge request is approved.'),
approvalNeeded: s__('mrWidget|Merge blocked: this merge request must be approved.'),
unresolvedDiscussions: s__('mrWidget|Merge blocked: all threads must be resolved.'),
},
components: {

View File

@ -85,7 +85,7 @@ export default {
);
},
i18n: {
buttonLabel: s__('SecurityConfiguration|Configure via Merge Request'),
buttonLabel: s__('SecurityConfiguration|Configure with a merge request'),
noSuccessPathError: s__(
'SecurityConfiguration|%{featureName} merge request creation mutation failed',
),

View File

@ -57,7 +57,7 @@ class Projects::NotesController < Projects::ApplicationController
def outdated_line_change
diff_lines = Rails.cache.fetch(['note', note.id, 'oudated_line_change'], expires_in: 7.days) do
::MergeRequests::OutdatedDiscussionDiffLinesService.new(project: @project, note: note).execute.to_json
::MergeRequests::OutdatedDiscussionDiffLinesService.new(project: note.noteable.source_project, note: note).execute.to_json
end
render json: diff_lines

View File

@ -603,6 +603,15 @@ class Note < ApplicationRecord
})
end
def show_outdated_changes?
return false unless for_merge_request?
return false unless Feature.enabled?(:display_outdated_line_diff, noteable.source_project, default_enabled: :yaml)
return false unless system?
return false unless change_position&.line_range
change_position.line_range["end"] || change_position.line_range["start"]
end
private
def system_note_viewable_by?(user)

View File

@ -51,7 +51,7 @@ class NoteEntity < API::Entities::Note
SystemNoteHelper.system_note_icon_name(note)
end
expose :outdated_line_change_path, if: -> (note, _) { note.system? && note.change_position&.line_range && Feature.enabled?(:display_outdated_line_diff, note.project, default_enabled: :yaml) } do |note|
expose :outdated_line_change_path, if: -> (note, _) { note.show_outdated_changes? } do |note|
outdated_line_change_namespace_project_note_path(namespace_id: note.project.namespace, project_id: note.project, id: note)
end

View File

@ -14,12 +14,12 @@ module MergeRequests
end
def execute
end_position = position.line_range["end"]
line_position = position.line_range["end"] || position.line_range["start"]
diff_line_index = diff_lines.find_index do |l|
if end_position["new_line"]
l.new_line == end_position["new_line"]
elsif end_position["old_line"]
l.old_line == end_position["old_line"]
if line_position["new_line"]
l.new_line == line_position["new_line"]
elsif line_position["old_line"]
l.old_line == line_position["old_line"]
end
end
initial_line_index = [diff_line_index - OVERFLOW_LINES_COUNT, 0].max

View File

@ -171,10 +171,8 @@ we should track our progress through the exception list.
When auto-generating the `.rubocop_todo.yml` exception list for a particular Cop,
and more than 15 files are affected, we should add the exception list to
a different file within `.rubocop_todo/` directory.
For example, the configuration for the cop `Gitlab/NamespacedClass` is located
in `.rubocop_todo/gitlab/namespaced_class.yml`.
a different file in the directory `.rubocop_todo/`. For example, the configuration for the cop
`Gitlab/NamespacedClass` is in `.rubocop_todo/gitlab/namespaced_class.yml`.
This ensures that our list isn't mistakenly removed by another auto generation of
the `.rubocop_todo.yml`. This also allows us greater visibility into the exceptions

View File

@ -232,11 +232,11 @@ To enable or disable the banner:
## Required pipeline configuration **(PREMIUM SELF)**
WARNING:
This feature is being re-evaluated in favor of a different
[compliance solution](https://gitlab.com/groups/gitlab-org/-/epics/3156).
We recommend that users who haven't yet implemented this feature wait for
the new solution.
NOTE:
An alternative [compliance solution](../../project/settings/index.md#compliance-pipeline-configuration)
is available for Ultimate tier users on both SaaS and self-managed instances.
We recommend this alternative solution for Ultimate-tier users because it provides greater flexibility,
allowing required pipelines to be assigned to specific compliance framework labels.
You can set a [CI/CD template](../../../ci/examples/index.md#cicd-templates)
as a required pipeline configuration for all projects on a GitLab instance. You can

View File

@ -46,14 +46,14 @@ You can configure the following security controls:
- Select **Manage scans** to manage the saved DAST scans, site profiles, and scanner profiles.
For more details, read [DAST on-demand scans](../dast/index.md#on-demand-scans).
- [Dependency Scanning](../dependency_scanning/index.md)
- Select **Configure via Merge Request** to create a merge request with the changes required to
- Select **Configure with a merge request** to create a merge request with the changes required to
enable Dependency Scanning. For more details, see [Enable Dependency Scanning via an automatic merge request](../dependency_scanning/index.md#enable-dependency-scanning-via-an-automatic-merge-request).
- [Container Scanning](../container_scanning/index.md)
- Can be configured with `.gitlab-ci.yml`. For more details, read [Container Scanning](../../../user/application_security/container_scanning/index.md#configuration).
- [Cluster Image Scanning](../cluster_image_scanning/index.md)
- Can be configured with `.gitlab-ci.yml`. For more details, read [Cluster Image Scanning](../../../user/application_security/cluster_image_scanning/#configuration).
- [Secret Detection](../secret_detection/index.md)
- Select **Configure via Merge Request** to create a merge request with the changes required to
- Select **Configure with a merge request** to create a merge request with the changes required to
enable Secret Detection. For more details, read [Enable Secret Detection via an automatic merge request](../secret_detection/index.md#enable-secret-detection-via-an-automatic-merge-request).
- [API Fuzzing](../api_fuzzing/index.md)
- Select **Enable API Fuzzing** to use API Fuzzing for the current project. For more details, read [API Fuzzing](../../../user/application_security/api_fuzzing/index.md#enable-web-api-fuzzing).

View File

@ -9,7 +9,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
INFO:
Try out Dependency Scanning in GitLab Ultimate.
[It's free for 30 days](https://about.gitlab.com/free-trial?glm_source=docs.gitlab.com&glm_content=u-dependency-scanning-docs).
[It's free for 30 days](https://about.gitlab.com/free-trial?glm_source=docs.gitlab.com&glm_content=u-dependency-scanning-docs).
The Dependency Scanning feature can automatically find security vulnerabilities in your
dependencies while you're developing and testing your applications. For example, dependency scanning
@ -444,7 +444,7 @@ from the Security Configuration page.
1. In the project where you want to enable Dependency Scanning, navigate to
**Security & Compliance > Configuration**.
1. In the **Dependency Scanning** row, select **Configure via Merge Request**.
1. In the **Dependency Scanning** row, select **Configure with a merge request**.
This automatically creates a merge request with the changes necessary to enable Dependency Scanning
that you can review and merge to complete the configuration.

View File

@ -39,7 +39,7 @@ GitLab IaC scanning supports a variety of IaC configuration files. Our IaC secur
### Making IaC analyzers available to all GitLab tiers
All open source (OSS) analyzers are availibile with the GitLab Free tier. Future propietary analyzers may be restricted to higher tiers.
All open source (OSS) analyzers are availibile with the GitLab Free tier. Future propietary analyzers may be restricted to higher tiers.
#### Summary of features per tier
@ -84,7 +84,7 @@ from the Security Configuration page:
1. On the top bar, select **Menu > Projects** and find your project.
1. On the left sidebar, select **Security & Compliance > Configuration**.
1. In the **Infrastructure as Code (IaC) Scanning** row, select **Configure via Merge Request**.
1. In the **Infrastructure as Code (IaC) Scanning** row, select **Configure with a merge request**.
This automatically creates a merge request with the changes necessary to enable IaC Scanning
that you can review and merge to complete the configuration.

View File

@ -123,10 +123,10 @@ from the Security Configuration page.
1. In the project where you want to enable Secret Detection, go to
**Security & Compliance > Configuration**.
1. In the **Secret Detection** row, select **Configure via Merge Request**.
1. In the **Secret Detection** row, select **Configure with a merge request**.
This automatically creates a merge request with the changes necessary to enable Secret Detection
that you can review and merge to complete the configuration.
that you can review and merge to complete the configuration.
NOTE:
The configuration tool works best with no existing `.gitlab-ci.yml` file, or with a minimal

View File

@ -17,7 +17,7 @@ to securely store the state files in local storage (the default) or
WARNING:
Using local storage (the default) on clustered deployments of GitLab will result in
a split state across nodes, making subsequent executions of Terraform inconsistent.
You are highly advised to use a remote storage in that case.
You are highly advised to use a remote storage resource in that case.
The GitLab managed Terraform state backend can store your Terraform state easily and
securely, and spares you from setting up additional remote resources like
@ -28,7 +28,7 @@ Amazon S3 or Google Cloud Storage. Its features include:
- Locking and unlocking state.
- Remote Terraform plan and apply execution.
A GitLab **administrator** must [setup the Terraform state storage configuration](../../../administration/terraform_state.md)
A GitLab **administrator** must [set up the Terraform state storage configuration](../../../administration/terraform_state.md)
before using this feature.
## Permissions for using Terraform
@ -89,7 +89,7 @@ local machine, this is a simple way to get started:
```
If you already have a GitLab-managed Terraform state, you can use the `terraform init` command
with the prepopulated parameters values:
with the pre-populated parameters values:
1. On the top bar, select **Menu > Projects** and find your project.
1. On the left sidebar, select **Infrastructure > Terraform**.
@ -300,7 +300,7 @@ any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
re-run this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
```

View File

@ -177,12 +177,16 @@ entries under **Database**. The entries defined under the sections **Documentati
### Make a Code Owners section optional
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/232995) in GitLab Premium 13.8 behind a feature flag, enabled by default.
> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53227) in GitLab 13.9.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/232995) in GitLab Premium 13.8.
You can make a section optional, so that approval from the Code Owners in that section is optional.
You can designate optional sections in your Code Owners file. Prepend the
section name with the caret `^` character to treat the entire section as optional.
Optional sections enable you to designate responsible parties for various parts
of your codebase, but not require approval from them. This approach provides
a more relaxed policy for parts of your project that are frequently updated,
but don't require stringent reviews.
Put a caret `^` character before the Code Owners section name. For example:
In this example, the `[Go]` section is optional:
```plaintext
[Documentation]
@ -204,8 +208,12 @@ If a section is duplicated in the file, and one of them is marked as optional an
Optional sections in the `CODEOWNERS` file are treated as optional only
when changes are submitted by using merge requests. If a change is submitted directly
to the protected branch, approval from Code Owners is still required, even if the
section is marked as optional. [An issue exists](https://gitlab.com/gitlab-org/gitlab/-/issues/297638)
to allow direct pushes to the protected branch for sections marked as optional.
section is marked as optional.
### Allowed to Push
The Code Owner approval and protected branch features do not apply to users who
are **Allowed to push**.
## Example `CODEOWNERS` file

View File

@ -85,6 +85,7 @@ module Gitlab
# Requeue pending jobs previously queued with #queue_background_migration_jobs_by_range_at_intervals
#
# This method is useful to schedule jobs that had previously failed.
# It can only be used if the previous background migration used job tracking like the queue_background_migration_jobs_by_range_at_intervals helper.
#
# job_class_name - The background migration job class as a string
# delay_interval - The duration between each job's scheduled time
@ -129,6 +130,7 @@ module Gitlab
# 4. Optionally remove job tracking information.
#
# This method does not garauntee that all jobs completed successfully.
# It can only be used if the previous background migration used the queue_background_migration_jobs_by_range_at_intervals helper.
def finalize_background_migration(class_name, delete_tracking_jobs: ['succeeded'])
# Empty the sidekiq queue.
Gitlab::BackgroundMigration.steal(class_name)

View File

@ -73,6 +73,7 @@ module Gitlab
partition_name: partition.partition_name,
table_name: partition.table)
end
model.partitioning_strategy.after_adding_partitions
end
end

View File

@ -15,11 +15,21 @@ module Gitlab
exception: exception,
import_state: import_state,
project_id: project_id,
error_source: error_source
).execute(fail_import: fail_import, metrics: metrics)
error_source: error_source,
fail_import: fail_import,
metrics: metrics
).execute
end
def initialize(exception:, import_state: nil, project_id: nil, error_source: nil)
def initialize(
exception:,
import_state: nil,
project_id: nil,
error_source: nil,
fail_import: false,
metrics: false
)
if import_state.blank? && project_id.blank?
raise ArgumentError, 'import_state OR project_id must be provided'
end
@ -34,9 +44,11 @@ module Gitlab
@exception = exception
@error_source = error_source
@fail_import = fail_import
@metrics = metrics
end
def execute(fail_import:, metrics:)
def execute
track_exception
persist_failure
@ -46,7 +58,7 @@ module Gitlab
private
attr_reader :exception, :import_state, :project, :error_source
attr_reader :exception, :import_state, :project, :error_source, :fail_import, :metrics
def track_exception
attributes = {
@ -65,12 +77,15 @@ module Gitlab
Gitlab::ErrorTracking.track_exception(exception, attributes)
end
# Failures with `retry_count: 0` are considered "hard_failures" and those
# are exposed on the REST API projects/:id/import
def persist_failure
project.import_failures.create(
source: error_source,
exception_class: exception.class.to_s,
exception_message: exception.message.truncate(255),
correlation_id_value: Labkit::Correlation::CorrelationId.current_or_new_id
correlation_id_value: Labkit::Correlation::CorrelationId.current_or_new_id,
retry_count: fail_import ? 0 : nil
)
end

View File

@ -30776,7 +30776,7 @@ msgstr ""
msgid "SecurityConfiguration|Configure %{feature}"
msgstr ""
msgid "SecurityConfiguration|Configure via Merge Request"
msgid "SecurityConfiguration|Configure with a merge request"
msgstr ""
msgid "SecurityConfiguration|Copy code and open .gitlab-ci.yml file"
@ -39736,9 +39736,6 @@ msgstr ""
msgid "You can only edit files when you are on a branch"
msgstr ""
msgid "You can only merge once this merge request is approved."
msgstr ""
msgid "You can only transfer the project to namespaces you manage."
msgstr ""
@ -41629,6 +41626,9 @@ msgstr ""
msgid "mrWidget|Merge blocked: pipeline must succeed. It's waiting for a manual action to continue."
msgstr ""
msgid "mrWidget|Merge blocked: this merge request must be approved."
msgstr ""
msgid "mrWidget|Merge failed."
msgstr ""
@ -41773,9 +41773,6 @@ msgstr ""
msgid "mrWidget|What is a merge train?"
msgstr ""
msgid "mrWidget|You can only merge once this merge request is approved."
msgstr ""
msgid "mrWidget|Your password"
msgstr ""

View File

@ -2,7 +2,7 @@
FactoryBot.define do
factory :protected_branch do
name
sequence(:name) { |n| "protected_branch_#{n}" }
project
transient do
@ -11,6 +11,20 @@ FactoryBot.define do
default_access_level { true }
end
trait :create_branch_on_repository do
association :project, factory: [:project, :repository]
transient do
repository_branch_name { name }
end
after(:create) do |protected_branch, evaluator|
project = protected_branch.project
project.repository.create_branch(evaluator.repository_branch_name, project.default_branch_or_main)
end
end
trait :developers_can_push do
transient do
default_push_level { false }

View File

@ -37,8 +37,8 @@ RSpec.describe Gitlab::Database::Partitioning::SlidingListStrategy do
describe '#current_partitions' do
it 'detects both partitions' do
expect(strategy.current_partitions).to eq([
Gitlab::Database::Partitioning::SingleNumericListPartition.new(table_name, 1, partition_name: '_test_partitioned_test_1'),
Gitlab::Database::Partitioning::SingleNumericListPartition.new(table_name, 2, partition_name: '_test_partitioned_test_2')
Gitlab::Database::Partitioning::SingleNumericListPartition.new(table_name, 1, partition_name: '_test_partitioned_test_1'),
Gitlab::Database::Partitioning::SingleNumericListPartition.new(table_name, 2, partition_name: '_test_partitioned_test_2')
])
end
end

View File

@ -7,58 +7,48 @@ RSpec.describe Gitlab::Import::ImportFailureService, :aggregate_failures do
let_it_be(:project) { create(:project, :import_started, import_type: import_type) }
let(:exception) { StandardError.new('some error') }
let(:arguments) { { project_id: project.id } }
let(:base_arguments) { { error_source: 'SomeImporter', exception: exception }.merge(arguments) }
let(:exe_arguments) { { fail_import: false, metrics: false } }
let(:import_state) { nil }
let(:fail_import) { false }
let(:metrics) { false }
let(:arguments) do
{
project_id: project.id,
error_source: 'SomeImporter',
exception: exception,
fail_import: fail_import,
metrics: metrics,
import_state: import_state
}
end
describe '.track' do
let(:instance) { double(:failure_service) }
context 'with all arguments provided' do
let(:instance) { double(:failure_service) }
let(:instance_arguments) do
let(:arguments) do
{
exception: exception,
import_state: '_import_state_',
project_id: '_project_id_',
error_source: '_error_source_'
}
end
let(:exe_arguments) do
{
error_source: '_error_source_',
fail_import: '_fail_import_',
metrics: '_metrics_'
}
end
it 'invokes a new instance and executes' do
expect(described_class).to receive(:new).with(**instance_arguments).and_return(instance)
expect(instance).to receive(:execute).with(**exe_arguments)
expect(described_class).to receive(:new).with(**arguments).and_return(instance)
expect(instance).to receive(:execute)
described_class.track(**instance_arguments.merge(exe_arguments))
described_class.track(**arguments)
end
end
context 'with only necessary arguments utilizing defaults' do
let(:instance) { double(:failure_service) }
let(:instance_arguments) do
{
exception: exception,
import_state: nil,
project_id: nil,
error_source: nil
}
end
let(:exe_arguments) do
{
fail_import: false,
metrics: false
}
end
it 'invokes a new instance and executes' do
expect(described_class).to receive(:new).with(**instance_arguments).and_return(instance)
expect(instance).to receive(:execute).with(**exe_arguments)
expect(described_class).to receive(:new).with(a_hash_including(exception: exception)).and_return(instance)
expect(instance).to receive(:execute)
described_class.track(exception: exception)
end
@ -66,7 +56,7 @@ RSpec.describe Gitlab::Import::ImportFailureService, :aggregate_failures do
end
describe '#execute' do
subject(:service) { described_class.new(**base_arguments) }
subject(:service) { described_class.new(**arguments) }
shared_examples 'logs the exception and fails the import' do
it 'when the failure does not abort the import' do
@ -89,13 +79,14 @@ RSpec.describe Gitlab::Import::ImportFailureService, :aggregate_failures do
source: 'SomeImporter'
)
service.execute(**exe_arguments)
service.execute
expect(project.import_state.reload.status).to eq('failed')
expect(project.import_failures).not_to be_empty
expect(project.import_failures.last.exception_class).to eq('StandardError')
expect(project.import_failures.last.exception_message).to eq('some error')
expect(project.import_failures.last.retry_count).to eq(0)
end
end
@ -120,32 +111,36 @@ RSpec.describe Gitlab::Import::ImportFailureService, :aggregate_failures do
source: 'SomeImporter'
)
service.execute(**exe_arguments)
service.execute
expect(project.import_state.reload.status).to eq('started')
expect(project.import_failures).not_to be_empty
expect(project.import_failures.last.exception_class).to eq('StandardError')
expect(project.import_failures.last.exception_message).to eq('some error')
expect(project.import_failures.last.retry_count).to eq(nil)
end
end
context 'when tracking metrics' do
let(:exe_arguments) { { fail_import: false, metrics: true } }
let(:metrics) { true }
it 'tracks the failed import' do
metrics = double(:metrics)
metrics_double = double(:metrics)
expect(Gitlab::Import::Metrics).to receive(:new).with("#{project.import_type}_importer", project).and_return(metrics)
expect(metrics).to receive(:track_failed_import)
expect(Gitlab::Import::Metrics)
.to receive(:new)
.with("#{project.import_type}_importer", project)
.and_return(metrics_double)
expect(metrics_double).to receive(:track_failed_import)
service.execute(**exe_arguments)
service.execute
end
end
context 'when using the project as reference' do
context 'when it fails the import' do
let(:exe_arguments) { { fail_import: true, metrics: false } }
let(:fail_import) { true }
it_behaves_like 'logs the exception and fails the import'
end
@ -156,10 +151,10 @@ RSpec.describe Gitlab::Import::ImportFailureService, :aggregate_failures do
end
context 'when using the import_state as reference' do
let(:arguments) { { import_state: project.import_state } }
let(:import_state) { project.import_state }
context 'when it fails the import' do
let(:exe_arguments) { { fail_import: true, metrics: false } }
let(:fail_import) { true }
it_behaves_like 'logs the exception and fails the import'
end

View File

@ -304,7 +304,7 @@ RSpec.describe Integrations::MicrosoftTeams do
context 'with protected branch' do
before do
create(:protected_branch, project: project, name: 'a-protected-branch')
create(:protected_branch, :create_branch_on_repository, project: project, name: 'a-protected-branch')
end
let(:pipeline) do

View File

@ -113,7 +113,7 @@ RSpec.shared_examples "chat integration" do |integration_name|
context "with protected branch" do
before do
create(:protected_branch, project: project, name: "a-protected-branch")
create(:protected_branch, :create_branch_on_repository, project: project, name: "a-protected-branch")
end
let(:sample_data) do
@ -309,7 +309,7 @@ RSpec.shared_examples "chat integration" do |integration_name|
context "with protected branch" do
before do
create(:protected_branch, project: project, name: "a-protected-branch")
create(:protected_branch, :create_branch_on_repository, project: project, name: "a-protected-branch")
end
let(:sample_data) do

View File

@ -305,7 +305,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch' do
before do
create(:protected_branch, project: project, name: 'a-protected-branch')
create(:protected_branch, :create_branch_on_repository, project: project, name: 'a-protected-branch')
end
let(:data) do
@ -347,7 +347,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch with protected branches defined using wildcards' do
before do
create(:protected_branch, project: project, name: '*-stable')
create(:protected_branch, :create_branch_on_repository, repository_branch_name: '1-stable', project: project, name: '*-stable')
end
let(:data) do
@ -560,7 +560,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch' do
before do
create(:protected_branch, project: project, name: 'a-protected-branch')
create(:protected_branch, :create_branch_on_repository, project: project, name: 'a-protected-branch')
end
let(:pipeline) do
@ -590,7 +590,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch with protected branches defined usin wildcards' do
before do
create(:protected_branch, project: project, name: '*-stable')
create(:protected_branch, :create_branch_on_repository, repository_branch_name: '1-stable', project: project, name: '*-stable')
end
let(:pipeline) do