Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-01-18 06:11:59 +00:00
parent 104ac5e939
commit eef9e3fbb5
23 changed files with 118 additions and 70 deletions

View file

@ -419,6 +419,30 @@
height: $gl-font-size * $code-line-height * 0.9; height: $gl-font-size * $code-line-height * 0.9;
} }
@mixin email-code-block {
.code.language-email {
font-family: inherit;
font-size: inherit;
code {
white-space: pre-wrap;
font-family: inherit;
// Rouge `Name.Tag` and `Operator` token (email header key + ':')
.nt,
.o {
color: inherit;
font-weight: bold;
}
// Rouge `Name.Attribute` token (email header value)
.na {
color: inherit;
}
}
}
}
@mixin avatar-counter($border-radius: 1em) { @mixin avatar-counter($border-radius: 1em) {
background-color: $gray-darkest; background-color: $gray-darkest;
color: $white; color: $white;

View file

@ -597,6 +597,8 @@
.text-justify { .text-justify {
text-align: justify !important; text-align: justify !important;
} }
@include email-code-block;
} }
/** /**

View file

@ -1,3 +1,4 @@
@import 'framework/mixins';
@import 'framework/variables'; @import 'framework/variables';
img { img {
@ -38,3 +39,14 @@ pre.commit-message {
.gl-label-text-dark { .gl-label-text-dark {
color: $gl-text-color; color: $gl-text-color;
} }
.content {
.markdown-code-block pre.code {
padding: $gl-padding-8 $input-horizontal-padding;
margin: 0 0 $gl-padding-8;
border: 1px solid $gray-100;
border-radius: $border-radius-small;
}
@include email-code-block;
}

View file

@ -27,6 +27,7 @@ class Member < ApplicationRecord
belongs_to :created_by, class_name: "User" belongs_to :created_by, class_name: "User"
belongs_to :user belongs_to :user
belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
belongs_to :member_namespace, inverse_of: :namespace_members, foreign_key: 'member_namespace_id', class_name: 'Namespace'
has_one :member_task has_one :member_task
delegate :name, :username, :email, :last_activity_on, to: :user, prefix: true delegate :name, :username, :email, :last_activity_on, to: :user, prefix: true

View file

@ -44,6 +44,7 @@ class Namespace < ApplicationRecord
has_many :project_statistics has_many :project_statistics
has_one :namespace_settings, inverse_of: :namespace, class_name: 'NamespaceSetting', autosave: true has_one :namespace_settings, inverse_of: :namespace, class_name: 'NamespaceSetting', autosave: true
has_one :namespace_route, foreign_key: :namespace_id, autosave: false, inverse_of: :namespace, class_name: 'Route' has_one :namespace_route, foreign_key: :namespace_id, autosave: false, inverse_of: :namespace, class_name: 'Route'
has_many :namespace_members, foreign_key: :member_namespace_id, inverse_of: :member_namespace, class_name: 'Member'
has_many :runner_namespaces, inverse_of: :namespace, class_name: 'Ci::RunnerNamespace' has_many :runner_namespaces, inverse_of: :namespace, class_name: 'Ci::RunnerNamespace'
has_many :runners, through: :runner_namespaces, source: :runner, class_name: 'Ci::Runner' has_many :runners, through: :runner_namespaces, source: :runner, class_name: 'Ci::Runner'

View file

@ -1,8 +0,0 @@
---
name: opt_in_sidekiq_status
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77349
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343964
milestone: '14.7'
type: development
group: group::scalability
default_enabled: false

View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
class RemoveNoteIdIndex < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
TABLE = :suggestions
INDEX_NAME = 'index_suggestions_on_note_id'
def up
remove_concurrent_index_by_name TABLE, INDEX_NAME
end
def down
add_concurrent_index TABLE, :note_id, name: INDEX_NAME
end
end

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
class AddMemberNamespaceReference < Gitlab::Database::Migration[1.0]
enable_lock_retries!
def up
add_column :members, :member_namespace_id, :bigint unless column_exists?(:members, :member_namespace_id)
end
def down
remove_column :members, :member_namespace_id if column_exists?(:members, :member_namespace_id)
end
end

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
class AddMemberNamespaceIndex < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = 'index_members_on_member_namespace_id'
def up
add_concurrent_index :members, :member_namespace_id, unique: false, name: INDEX_NAME
add_concurrent_foreign_key :members, :namespaces, column: :member_namespace_id, on_delete: :nullify, reverse_lock_order: true
end
def down
with_lock_retries do
remove_foreign_key_if_exists :members, column: :member_namespace_id
end
remove_concurrent_index_by_name :members, INDEX_NAME
end
end

View file

@ -0,0 +1 @@
72639ba84675a6687864ef4cb6f02d0429124d7deb9ce9f3c8e255591e2f0a8d

View file

@ -0,0 +1 @@
775ac42ad194bd0175a6925e1c2e83c11d57a8d4430ad08a70e3d5275ca2e709

View file

@ -0,0 +1 @@
4813b55e933564851f2fec9a2fa5900409eff226fec34ae0be1895307f603904

View file

@ -15979,7 +15979,8 @@ CREATE TABLE members (
ldap boolean DEFAULT false NOT NULL, ldap boolean DEFAULT false NOT NULL,
override boolean DEFAULT false NOT NULL, override boolean DEFAULT false NOT NULL,
state smallint DEFAULT 0, state smallint DEFAULT 0,
invite_email_success boolean DEFAULT true NOT NULL invite_email_success boolean DEFAULT true NOT NULL,
member_namespace_id bigint
); );
CREATE SEQUENCE members_id_seq CREATE SEQUENCE members_id_seq
@ -26567,6 +26568,8 @@ CREATE INDEX index_members_on_invite_email ON members USING btree (invite_email)
CREATE UNIQUE INDEX index_members_on_invite_token ON members USING btree (invite_token); CREATE UNIQUE INDEX index_members_on_invite_token ON members USING btree (invite_token);
CREATE INDEX index_members_on_member_namespace_id ON members USING btree (member_namespace_id);
CREATE INDEX index_members_on_requested_at ON members USING btree (requested_at); CREATE INDEX index_members_on_requested_at ON members USING btree (requested_at);
CREATE INDEX index_members_on_source_id_and_source_type ON members USING btree (source_id, source_type); CREATE INDEX index_members_on_source_id_and_source_type ON members USING btree (source_id, source_type);
@ -29586,6 +29589,9 @@ ALTER TABLE ONLY epics
ALTER TABLE ONLY dast_profiles ALTER TABLE ONLY dast_profiles
ADD CONSTRAINT fk_aa76ef30e9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; ADD CONSTRAINT fk_aa76ef30e9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY members
ADD CONSTRAINT fk_aa82dcc1c6 FOREIGN KEY (member_namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL;
ALTER TABLE ONLY alert_management_alerts ALTER TABLE ONLY alert_management_alerts
ADD CONSTRAINT fk_aad61aedca FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE SET NULL; ADD CONSTRAINT fk_aad61aedca FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE SET NULL;

View file

@ -48,4 +48,4 @@
{{end -}} {{end -}}
{{end -}} {{end -}}
{{- $e}} {{"errors" | red}}, {{$w}} {{"warnings" | yellow}}, and {{$s}} {{"suggestions" | blue}} found in {{$f}} {{$f | int | plural "file" "files"}}. {{- $e}} {{"errors" | red}}, {{$w}} {{"warnings" | yellow}}, and {{$s}} {{"suggestions" | blue}} found.

View file

@ -5,7 +5,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
description: Require approvals prior to deploying to a Protected Environment description: Require approvals prior to deploying to a Protected Environment
--- ---
# Deployment Approvals **(PREMIUM)** # Deployment approvals **(PREMIUM)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/215888) in GitLab 14.7 with a flag named `deployment_approvals`. Disabled by default. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/215888) in GitLab 14.7 with a flag named `deployment_approvals`. Disabled by default.

View file

@ -248,9 +248,9 @@ NOTE:
Configuration [with the UI](https://gitlab.com/gitlab-org/gitlab/-/issues/325249) Configuration [with the UI](https://gitlab.com/gitlab-org/gitlab/-/issues/325249)
is scheduled for a later release. is scheduled for a later release.
## Deployment Approvals ## Deployment approvals
Protected Environments can also be used to require manual approvals before deployments. See [Deployment Approvals](deployment_approvals.md) for more information. Protected environments can also be used to require manual approvals before deployments. See [Deployment approvals](deployment_approvals.md) for more information.
<!-- ## Troubleshooting <!-- ## Troubleshooting

View file

@ -183,8 +183,6 @@ include: # Execute individual project's configuration (if project contains .git
project: '$CI_PROJECT_PATH' project: '$CI_PROJECT_PATH'
file: '$CI_CONFIG_PATH' file: '$CI_CONFIG_PATH'
ref: '$CI_COMMIT_REF_NAME' # Must be defined or MR pipelines always use the use default branch ref: '$CI_COMMIT_REF_NAME' # Must be defined or MR pipelines always use the use default branch
rules:
- exists: '$CI_CONFIG_PATH'
``` ```
##### Ensure compliance jobs are always run ##### Ensure compliance jobs are always run

View file

@ -904,6 +904,7 @@ excluded_attributes:
- :release_id - :release_id
project_members: project_members:
- :source_id - :source_id
- :member_namespace_id
- :invite_email_success - :invite_email_success
- :state - :state
group_members: group_members:

View file

@ -4,13 +4,7 @@ module Gitlab
module SidekiqStatus module SidekiqStatus
class ClientMiddleware class ClientMiddleware
def call(_, job, _, _) def call(_, job, _, _)
status_expiration = job['status_expiration'] Gitlab::SidekiqStatus.set(job['jid'], job['status_expiration'])
unless ::Feature.enabled?(:opt_in_sidekiq_status, default_enabled: :yaml)
status_expiration ||= Gitlab::SidekiqStatus::DEFAULT_EXPIRATION
end
Gitlab::SidekiqStatus.set(job['jid'], status_expiration)
yield yield
end end

View file

@ -136,6 +136,7 @@ project_members:
- source - source
- project - project
- member_task - member_task
- member_namespace
merge_requests: merge_requests:
- status_check_responses - status_check_responses
- subscriptions - subscriptions

View file

@ -1,61 +1,24 @@
# frozen_string_literal: true # frozen_string_literal: true
# This can use fast_spec_helper when the feature flag stubbing is removed. require 'fast_spec_helper'
require 'spec_helper'
RSpec.describe Gitlab::SidekiqStatus::ClientMiddleware, :clean_gitlab_redis_queues do RSpec.describe Gitlab::SidekiqStatus::ClientMiddleware, :clean_gitlab_redis_queues do
describe '#call' do describe '#call' do
context 'when opt_in_sidekiq_status is disabled' do context 'when the job has status_expiration set' do
before do it 'tracks the job in Redis' do
stub_feature_flags(opt_in_sidekiq_status: false) expect(Gitlab::SidekiqStatus).to receive(:set).with('123', 1.hour.to_i)
end
context 'when the job has status_expiration set' do described_class.new
it 'tracks the job in Redis' do .call('Foo', { 'jid' => '123', 'status_expiration' => 1.hour.to_i }, double(:queue), double(:pool)) { nil }
expect(Gitlab::SidekiqStatus).to receive(:set).with('123', 1.hour.to_i).and_call_original
described_class.new
.call('Foo', { 'jid' => '123', 'status_expiration' => 1.hour.to_i }, double(:queue), double(:pool)) { nil }
expect(Gitlab::SidekiqStatus.num_running(['123'])).to eq(1)
end
end
context 'when the job does not have status_expiration set' do
it 'tracks the job in Redis' do
expect(Gitlab::SidekiqStatus).to receive(:set).with('123', 30.minutes.to_i).and_call_original
described_class.new
.call('Foo', { 'jid' => '123' }, double(:queue), double(:pool)) { nil }
expect(Gitlab::SidekiqStatus.num_running(['123'])).to eq(1)
end
end end
end end
context 'when opt_in_sidekiq_status is enabled' do context 'when the job does not have status_expiration set' do
before do it 'does not track the job in Redis' do
stub_feature_flags(opt_in_sidekiq_status: true) expect(Gitlab::SidekiqStatus).to receive(:set).with('123', nil)
end
context 'when the job has status_expiration set' do described_class.new
it 'tracks the job in Redis' do .call('Foo', { 'jid' => '123' }, double(:queue), double(:pool)) { nil }
expect(Gitlab::SidekiqStatus).to receive(:set).with('123', 1.hour.to_i).and_call_original
described_class.new
.call('Foo', { 'jid' => '123', 'status_expiration' => 1.hour.to_i }, double(:queue), double(:pool)) { nil }
expect(Gitlab::SidekiqStatus.num_running(['123'])).to eq(1)
end
end
context 'when the job does not have status_expiration set' do
it 'does not track the job in Redis' do
described_class.new
.call('Foo', { 'jid' => '123' }, double(:queue), double(:pool)) { nil }
expect(Gitlab::SidekiqStatus.num_running(['123'])).to be_zero
end
end end
end end
end end

View file

@ -9,6 +9,7 @@ RSpec.describe Member do
describe 'Associations' do describe 'Associations' do
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:member_namespace) }
it { is_expected.to have_one(:member_task) } it { is_expected.to have_one(:member_task) }
end end

View file

@ -29,6 +29,7 @@ RSpec.describe Namespace do
it { is_expected.to have_one :admin_note } it { is_expected.to have_one :admin_note }
it { is_expected.to have_many :pending_builds } it { is_expected.to have_many :pending_builds }
it { is_expected.to have_one :namespace_route } it { is_expected.to have_one :namespace_route }
it { is_expected.to have_many :namespace_members }
describe '#children' do describe '#children' do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }