Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2024-03-25 21:09:16 +00:00
parent 0e3485a64c
commit 5d831256a4
41 changed files with 720 additions and 875 deletions

View File

@ -1 +1 @@
v16.11.0-rc1
v16.11.0-rc2

View File

@ -340,21 +340,23 @@ async function fetchMetrics(metricsUrl, { filters = {}, limit } = {}) {
}
}
const SUPPORTED_METRICS_DIMENSION_FILTER_OPERATORS = ['=', '!=', '=~', '!~'];
const SUPPORTED_METRICS_DIMENSIONS_OPERATORS = {
'!=': 'neq',
'=': 'eq',
'=~': 're',
'!~': 'nre',
};
function addMetricsAttributeFilterToQueryParams(dimensionFilter, params) {
if (!dimensionFilter || !params) return;
Object.entries(dimensionFilter).forEach(([filterName, values]) => {
const filterValues = Array.isArray(values) ? values : [];
const validFilters = filterValues.filter((f) =>
SUPPORTED_METRICS_DIMENSION_FILTER_OPERATORS.includes(f.operator),
Object.keys(SUPPORTED_METRICS_DIMENSIONS_OPERATORS).includes(f.operator),
);
validFilters.forEach(({ operator, value }) => {
const paramName = getFilterParamName(filterName, operator);
if (paramName && value) {
params.append(paramName, value);
}
const operatorName = SUPPORTED_METRICS_DIMENSIONS_OPERATORS[operator];
params.append('attrs', `${filterName},${operatorName},${value}`);
});
});
}

View File

@ -61,7 +61,16 @@ module Ci
# before we delete builds. By doing this, the relation should be empty and not fire any
# DELETE queries when the Ci::Build is destroyed. The next step is to remove `dependent: :destroy`.
# Details: https://gitlab.com/gitlab-org/gitlab/-/issues/24644#note_689472685
has_many :job_artifacts, class_name: 'Ci::JobArtifact', foreign_key: :job_id, dependent: :destroy, inverse_of: :job # rubocop:disable Cop/ActiveRecordDependent
# rubocop:disable Cop/ActiveRecordDependent -- See above
has_many :job_artifacts,
->(build) { in_partition(build) },
class_name: 'Ci::JobArtifact',
foreign_key: :job_id,
partition_foreign_key: :partition_id,
dependent: :destroy,
inverse_of: :job
# rubocop:enable Cop/ActiveRecordDependent
has_many :job_variables, class_name: 'Ci::JobVariable', foreign_key: :job_id, inverse_of: :job
has_many :job_annotations,
->(build) { in_partition(build) },
@ -73,8 +82,12 @@ module Ci
has_many :pages_deployments, foreign_key: :ci_build_id, inverse_of: :ci_build
Ci::JobArtifact.file_types.each do |key, value|
has_one :"job_artifacts_#{key}", -> { where(file_type: value) }, class_name: 'Ci::JobArtifact', foreign_key: :job_id, inverse_of: :job
Ci::JobArtifact.file_types.each_key do |key|
has_one :"job_artifacts_#{key}", ->(build) { in_partition(build).with_file_types([key]) },
class_name: 'Ci::JobArtifact',
foreign_key: :job_id,
partition_foreign_key: :partition_id,
inverse_of: :job
end
has_one :runner_manager_build,

View File

@ -13,7 +13,10 @@ module Ci
class_name: 'Ci::Build',
partition_foreign_key: :partition_id,
inverse_of: :trace_metadata
belongs_to :trace_artifact, class_name: 'Ci::JobArtifact'
belongs_to :trace_artifact, # rubocop:disable Rails/InverseOf -- No clear relation to be used
->(metadata) { in_partition(metadata) },
class_name: 'Ci::JobArtifact',
partition_foreign_key: :partition_id
partitionable scope: :build

View File

@ -25,7 +25,12 @@ module Ci
enum accessibility: { public: 0, private: 1, none: 2 }, _suffix: true
belongs_to :project
belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id, inverse_of: :job_artifacts
belongs_to :job,
->(artifact) { in_partition(artifact) },
class_name: "Ci::Build",
foreign_key: :job_id,
partition_foreign_key: :partition_id,
inverse_of: :job_artifacts
mount_file_store_uploader JobArtifactUploader, skip_store_file: true
update_project_statistics project_statistics_name: :build_artifacts_size
@ -150,6 +155,10 @@ module Ci
service.update_statistics
end
def self.use_partition_id_filter?
::Feature.enabled?(:use_partition_id_filter_on_ci_job_artifacts, Feature.current_request)
end
def local_store?
[nil, ::JobArtifactUploader::Store::LOCAL].include?(self.file_store)
end

View File

@ -69,7 +69,8 @@ module Ci
end
end
has_many :stages, -> { order(position: :asc) }, inverse_of: :pipeline
has_many :stages, -> (pipeline) { in_partition(pipeline).order(position: :asc) },
partition_foreign_key: :partition_id, inverse_of: :pipeline
#
# In https://gitlab.com/groups/gitlab-org/-/epics/9991, we aim to convert all CommitStatus related models to

View File

@ -12,12 +12,14 @@ module Ci
self.primary_key = :id
self.sequence_name = :ci_job_stages_id_seq
query_constraints :id, :partition_id
partitionable scope: :pipeline, partitioned: true
enum status: Ci::HasStatus::STATUSES_ENUM
belongs_to :project
belongs_to :pipeline
belongs_to :pipeline, ->(stage) { in_partition(stage) },
foreign_key: :pipeline_id, partition_foreign_key: :partition_id, inverse_of: :stages
has_many :statuses,
->(stage) { in_partition(stage) },

View File

@ -32,7 +32,7 @@ class CommitStatus < Ci::ApplicationRecord
belongs_to :project
belongs_to :pipeline, ->(build) { in_partition(build) }, class_name: 'Ci::Pipeline', foreign_key: :commit_id, inverse_of: :statuses, partition_foreign_key: :partition_id
belongs_to :auto_canceled_by, class_name: 'Ci::Pipeline', inverse_of: :auto_canceled_jobs
belongs_to :ci_stage, class_name: 'Ci::Stage', foreign_key: :stage_id
belongs_to :ci_stage, ->(build) { in_partition(build) }, class_name: 'Ci::Stage', foreign_key: :stage_id, partition_foreign_key: :partition_id
has_many :needs, class_name: 'Ci::BuildNeed', foreign_key: :build_id, inverse_of: :build

View File

@ -86,10 +86,12 @@ module Ci
builds_relation.each_batch(of: BATCH_SIZE) do |builds|
# rubocop: disable CodeReuse/ActiveRecord
Ci::JobArtifact.where(job_id: builds.pluck(:id)).each_batch(of: BATCH_SIZE) do |job_artifacts|
unlocked_count = Ci::JobArtifact
.where(id: job_artifacts.pluck(:id))
.update_all(locked: :unlocked)
Ci::JobArtifact.where(job_id: builds.pluck(:id), partition_id: partition_id)
.each_batch(of: BATCH_SIZE) do |job_artifacts|
unlocked_count = Ci::JobArtifact.where(
id: job_artifacts.pluck(:id),
partition_id: partition_id
).update_all(locked: :unlocked)
@unlocked_job_artifacts_count ||= 0
@unlocked_job_artifacts_count += unlocked_count
@ -110,6 +112,12 @@ module Ci
end
end
# All the partitionable entities connected to a pipeline
# belong to the same partition where the pipeline is.
def partition_id
pipeline.partition_id
end
def unlock_pipeline_artifacts
@unlocked_pipeline_artifacts_count = pipeline.pipeline_artifacts.update_all(locked: :unlocked)
end

View File

@ -14,6 +14,10 @@ module Integrations
Gitlab::DataBuilder::Push.build_sample(project, current_user)
end
def tag_push_events_data
Gitlab::DataBuilder::Push.build_sample(project, current_user, is_tag: true)
end
def note_events_data
note = NotesFinder.new(current_user, project: project, target: project, sort: 'id_desc').execute.first

View File

@ -16,8 +16,10 @@ module TestHooks
def data
strong_memoize(:data) do
case trigger
when 'push_events', 'tag_push_events'
when 'push_events'
push_events_data
when 'tag_push_events'
tag_push_events_data
when 'note_events'
note_events_data
when 'issues_events', 'confidential_issues_events'

View File

@ -0,0 +1,9 @@
---
name: use_partition_id_filter_on_ci_job_artifacts
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/430294
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145522
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/444191
milestone: '16.11'
group: group::pipeline execution
type: gitlab_com_derisk
default_enabled: false

View File

@ -529,7 +529,7 @@ For more information on configuring Gitaly Cluster, see [Configure Gitaly Cluste
### Upgrade Gitaly Cluster
To upgrade a Gitaly Cluster, follow the documentation for
[zero downtime upgrades](../../update/zero_downtime.md#gitaly-or-gitaly-cluster).
[zero downtime upgrades](../../update/zero_downtime.md).
### Downgrade Gitaly Cluster to a previous version

View File

@ -182,7 +182,7 @@ ote_pid | tls
Some database changes have to be done directly, and not through PgBouncer.
The main affected tasks are [database restores](../../administration/backup_restore/backup_gitlab.md#back-up-and-restore-for-installations-using-pgbouncer)
and [GitLab upgrades with database migrations](../../update/zero_downtime.md#postgresql).
and [GitLab upgrades with database migrations](../../update/zero_downtime.md).
1. To find the primary node, run the following on a database node:

View File

@ -45,14 +45,15 @@ Use the `page` and `per_page` [pagination](rest/index.md#offset-based-pagination
Supported attributes:
| Attribute | Type | Required | Description |
|-----------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| Attribute | Type | Required | Description |
|-----------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
Example request:
```shell
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" \
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/29/approval_rules"
```
@ -98,20 +99,21 @@ POST /groups/:id/approval_rules
Supported attributes:
| Attribute | Type | Required | Description |
|-------------------------------------|-------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a group](rest/index.md#namespaced-path-encoding). |
| `approvals_required` | integer | Yes | The number of required approvals for this rule. |
| `name` | string | Yes | The name of the approval rule. |
| `group_ids` | array | No | The IDs of groups as approvers. |
| `report_type` | string | No | The report type required when the rule type is `report_approver`. The supported report types are `license_scanning` [(Deprecated in GitLab 15.9)](../update/deprecations.md#license-check-and-the-policies-tab-on-the-license-compliance-page) and `code_coverage`. |
| `rule_type` | string | No | The type of rule. `any_approver` is a pre-configured default rule with `approvals_required` at `0`. Other rules are `regular` (used for regular [merge request approval rules](../../ee/user/project/merge_requests/approvals/rules.md)) and `report_approver`. `report_approver` is used automatically when an approval rule is created from configured and enabled [merge request approval policies](../../ee/user/application_security/policies/scan-result-policies.md) and should not be used to create approval rule with this API. |
| `user_ids` | array | No | The IDs of users as approvers. |
| Attribute | Type | Required | Description |
|----------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a group](rest/index.md#namespaced-path-encoding). |
| `approvals_required` | integer | Yes | The number of required approvals for this rule. |
| `name` | string | Yes | The name of the approval rule. |
| `group_ids` | array | No | The IDs of groups as approvers. |
| `report_type` | string | No | The report type required when the rule type is `report_approver`. The supported report types are `license_scanning` [(Deprecated in GitLab 15.9)](../update/deprecations.md#license-check-and-the-policies-tab-on-the-license-compliance-page) and `code_coverage`. |
| `rule_type` | string | No | The type of rule. `any_approver` is a pre-configured default rule with `approvals_required` at `0`. Other rules are `regular` (used for regular [merge request approval rules](../../ee/user/project/merge_requests/approvals/rules.md)) and `report_approver`. `report_approver` is used automatically when an approval rule is created from configured and enabled [merge request approval policies](../../ee/user/application_security/policies/scan-result-policies.md) and should not be used to create approval rule with this API. |
| `user_ids` | array | No | The IDs of users as approvers. |
Example request:
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/29/approval_rules?name=security&approvals_required=2"
```
@ -172,20 +174,21 @@ PUT /groups/:id/approval_rules/:approval_rule_id
Supported attributes:
| Attribute | Type | Required | Description |
|----------------------|-------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `approval_rule_id`. | integer | Yes | The ID of the approval rule. |
| `id` | integer or string | Yes | The ID or [URL-encoded path of a group](rest/index.md#namespaced-path-encoding). |
| `approvals_required` | string | No | The number of required approvals for this rule. |
| `group_ids` | integer | No | The IDs of users as approvers. |
| `name` | string | No | The name of the approval rule. |
| Attribute | Type | Required | Description |
|----------------------|-------------------|----------|-------------|
| `approval_rule_id`. | integer | Yes | The ID of the approval rule. |
| `id` | integer or string | Yes | The ID or [URL-encoded path of a group](rest/index.md#namespaced-path-encoding). |
| `approvals_required` | string | No | The number of required approvals for this rule. |
| `group_ids` | integer | No | The IDs of users as approvers. |
| `name` | string | No | The name of the approval rule. |
| `rule_type` | array | No | The type of rule. `any_approver` is a pre-configured default rule with `approvals_required` at `0`. Other rules are `regular` (used for regular [merge request approval rules](../../ee/user/project/merge_requests/approvals/rules.md)) and `report_approver`. `report_approver` is used automatically when an approval rule is created from configured and enabled [merge request approval policies](../../ee/user/application_security/policies/scan-result-policies.md) and should not be used to create approval rule with this API. |
| `user_ids` | array | No | The IDs of groups as approvers. |
| `user_ids` | array | No | The IDs of groups as approvers. |
Example request:
```shell
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" \
curl --request PUT \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/29/approval_rules/5?name=security2&approvals_required=1"
```
@ -236,9 +239,6 @@ Example response:
## Project-level MR approvals
### Get Configuration
> - Moved to GitLab Premium in 13.9.
> - The `approvers` and `approver_groups` fields were deprecated in GitLab 12.3 and always return empty. Use the [project level approval rules](#get-project-level-rules) to access this information.
You can request information about a project's approval configuration using the
@ -250,9 +250,9 @@ GET /projects/:id/approvals
Supported attributes:
| Attribute | Type | Required | Description |
|-----------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| Attribute | Type | Required | Description |
|-----------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
```json
{
@ -270,8 +270,6 @@ Supported attributes:
### Change configuration
> - Moved to GitLab Premium in 13.9.
If you are allowed to, you can change approval configuration using the following
endpoint:
@ -281,16 +279,16 @@ POST /projects/:id/approvals
Supported attributes:
| Attribute | Type | Required | Description |
|--------------------------------------------------|-------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approvals_before_merge` (deprecated) | integer | No | How many approvals are required before a merge request can be merged. [Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/11132) in GitLab 12.3. Use [Approval Rules](#create-project-level-rule) instead. |
| `disable_overriding_approvers_per_merge_request` | boolean | No | Allow or prevent overriding approvers per merge request. |
| `merge_requests_author_approval` | boolean | No | Allow or prevent authors from self approving merge requests; `true` means authors can self approve. |
| `merge_requests_disable_committers_approval` | boolean | No | Allow or prevent committers from self approving merge requests. |
| `require_password_to_approve` | boolean | No | Require approver to enter a password to authenticate before adding the approval. |
| `reset_approvals_on_push` | boolean | No | Reset approvals on a new push. |
| `selective_code_owner_removals` | boolean | No | Reset approvals from Code Owners if their files changed. Can be enabled only if `reset_approvals_on_push` is disabled. |
| Attribute | Type | Required | Description |
|--------------------------------------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approvals_before_merge` (deprecated) | integer | No | How many approvals are required before a merge request can be merged. [Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/11132) in GitLab 12.3. Use [Approval Rules](#create-project-level-rule) instead. |
| `disable_overriding_approvers_per_merge_request` | boolean | No | Allow or prevent overriding approvers per merge request. |
| `merge_requests_author_approval` | boolean | No | Allow or prevent authors from self approving merge requests; `true` means authors can self approve. |
| `merge_requests_disable_committers_approval` | boolean | No | Allow or prevent committers from self approving merge requests. |
| `require_password_to_approve` | boolean | No | Require approver to enter a password to authenticate before adding the approval. |
| `reset_approvals_on_push` | boolean | No | Reset approvals on a new push. |
| `selective_code_owner_removals` | boolean | No | Reset approvals from Code Owners if their files changed. Can be enabled only if `reset_approvals_on_push` is disabled. |
```json
{
@ -306,7 +304,6 @@ Supported attributes:
### Get project-level rules
> - Moved to GitLab Premium in 13.9.
> - Pagination support [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/31011) in GitLab 15.3 [with a flag](../administration/feature_flags.md) named `approval_rules_pagination`. Enabled by default.
> - `applies_to_all_protected_branches` property was [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/335316) in GitLab 15.3.
> - Pagination support [generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/366823) in GitLab 15.7. Feature flag `approval_rules_pagination` removed.
@ -322,9 +319,9 @@ Use the `page` and `per_page` [pagination](rest/index.md#offset-based-pagination
Supported attributes:
| Attribute | Type | Required | Description |
|-----------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| Attribute | Type | Required | Description |
|-----------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
```json
[
@ -412,7 +409,6 @@ Supported attributes:
### Get a single project-level rule
> - Introduced in GitLab 13.7.
> - `applies_to_all_protected_branches` property was [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/335316) in GitLab 15.3.
> - `usernames` property was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/102446) in GitLab 15.8.
@ -424,10 +420,10 @@ GET /projects/:id/approval_rules/:approval_rule_id
Supported attributes:
| Attribute | Type | Required | Description |
|--------------------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approval_rule_id` | integer | Yes | The ID of a approval rule. |
| Attribute | Type | Required | Description |
|--------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approval_rule_id` | integer | Yes | The ID of a approval rule. |
```json
{
@ -513,7 +509,6 @@ Supported attributes:
### Create project-level rule
> - Moved to GitLab Premium in 13.9.
> - [Removed](https://gitlab.com/gitlab-org/gitlab/-/issues/357300) the Vulnerability-Check feature in GitLab 15.0.
> - `applies_to_all_protected_branches` property was [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/335316) in GitLab 15.3.
> - `usernames` property was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/102446) in GitLab 15.8.
@ -526,18 +521,18 @@ POST /projects/:id/approval_rules
Supported attributes:
| Attribute | Type | Required | Description |
|-------------------------------------|-------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approvals_required` | integer | Yes | The number of required approvals for this rule. |
| `name` | string | Yes | The name of the approval rule. |
| `applies_to_all_protected_branches` | boolean | No | Whether the rule is applied to all protected branches. If set to `true`, the value of `protected_branch_ids` is ignored. Default is `false`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/335316) in GitLab 15.3. |
| `group_ids` | Array | No | The IDs of groups as approvers. |
| `protected_branch_ids` | Array | No | The IDs of protected branches to scope the rule by. To identify the ID, [use the API](protected_branches.md#list-protected-branches). |
| `report_type` | string | No | The report type required when the rule type is `report_approver`. The supported report types are `license_scanning` [(Deprecated in GitLab 15.9)](../update/deprecations.md#license-check-and-the-policies-tab-on-the-license-compliance-page) and `code_coverage`. |
| `rule_type` | string | No | The type of rule. `any_approver` is a pre-configured default rule with `approvals_required` at `0`. Other rules are `regular` (used for regular [merge request approval rules](../../ee/user/project/merge_requests/approvals/rules.md)) and `report_approver`. `report_approver` is used automatically when an approval rule is created from configured and enabled [merge request approval policies](../../ee/user/application_security/policies/scan-result-policies.md) and should not be used to create approval rule with this API. |
| `user_ids` | Array | No | The IDs of users as approvers. If you provide both `user_ids` and `usernames`, both lists of users are added. |
| `usernames` | string array | No | The usernames of approvers for this rule (same as `user_ids` but requires a list of usernames). If you provide both `user_ids` and `usernames`, both lists of users are added. |
| Attribute | Type | Required | Description |
|-------------------------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approvals_required` | integer | Yes | The number of required approvals for this rule. |
| `name` | string | Yes | The name of the approval rule. |
| `applies_to_all_protected_branches` | boolean | No | Whether the rule is applied to all protected branches. If set to `true`, the value of `protected_branch_ids` is ignored. Default is `false`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/335316) in GitLab 15.3. |
| `group_ids` | Array | No | The IDs of groups as approvers. |
| `protected_branch_ids` | Array | No | The IDs of protected branches to scope the rule by. To identify the ID, [use the API](protected_branches.md#list-protected-branches). |
| `report_type` | string | No | The report type required when the rule type is `report_approver`. The supported report types are `license_scanning` [(Deprecated in GitLab 15.9)](../update/deprecations.md#license-check-and-the-policies-tab-on-the-license-compliance-page) and `code_coverage`. |
| `rule_type` | string | No | The type of rule. `any_approver` is a pre-configured default rule with `approvals_required` at `0`. Other rules are `regular` (used for regular [merge request approval rules](../../ee/user/project/merge_requests/approvals/rules.md)) and `report_approver`. `report_approver` is used automatically when an approval rule is created from configured and enabled [merge request approval policies](../../ee/user/application_security/policies/scan-result-policies.md) and should not be used to create approval rule with this API. |
| `user_ids` | Array | No | The IDs of users as approvers. If you provide both `user_ids` and `usernames`, both lists of users are added. |
| `usernames` | string array | No | The usernames of approvers for this rule (same as `user_ids` but requires a list of usernames). If you provide both `user_ids` and `usernames`, both lists of users are added. |
```json
{
@ -624,7 +619,8 @@ Supported attributes:
You can increase the default number of 0 required approvers like this:
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header 'Content-Type: application/json' \
--data '{"name": "Any name", "rule_type": "any_approver", "approvals_required": 2}'
```
@ -632,15 +628,15 @@ curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
Another example is creating an additional, user-specific rule:
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header 'Content-Type: application/json' \
--data '{"name": "Name of your rule", "approvals_required": 3, "user_ids": [123, 456, 789]}' \
https://gitlab.example.com/api/v4/projects/<project_id>/approval_rules
--url "https://gitlab.example.com/api/v4/projects/<project_id>/approval_rules"
```
### Update project-level rule
> - Moved to GitLab Premium in 13.9.
> - [Removed](https://gitlab.com/gitlab-org/gitlab/-/issues/357300) the Vulnerability-Check feature in GitLab 15.0.
> - `applies_to_all_protected_branches` property was [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/335316) in GitLab 15.3.
> - `usernames` property was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/102446) in GitLab 15.8.
@ -660,18 +656,18 @@ not removed unintentionally when a user updates an approval rule.
Supported attributes:
| Attribute | Type | Required | Description |
|-------------------------------------|-------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approvals_required` | integer | Yes | The number of required approvals for this rule. |
| `approval_rule_id` | integer | Yes | The ID of a approval rule. |
| `name` | string | Yes | The name of the approval rule. |
| `applies_to_all_protected_branches` | boolean | No | Whether the rule is applied to all protected branches. If set to `true`, the value of `protected_branch_ids` is ignored. Default is `false`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/335316) in GitLab 15.3. |
| `group_ids` | Array | No | The IDs of groups as approvers. |
| `protected_branch_ids` | Array | No | The IDs of protected branches to scope the rule by. To identify the ID, [use the API](protected_branches.md#list-protected-branches). |
| `remove_hidden_groups` | boolean | No | Whether hidden groups should be removed from approval rule. |
| `user_ids` | Array | No | The IDs of users as approvers. If you provide both `user_ids` and `usernames`, both lists of users are added. |
| `usernames` | string array | No | The usernames of approvers for this rule (same as `user_ids` but requires a list of usernames). If you provide both `user_ids` and `usernames`, both lists of users are added.|
| Attribute | Type | Required | Description |
|-------------------------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approvals_required` | integer | Yes | The number of required approvals for this rule. |
| `approval_rule_id` | integer | Yes | The ID of a approval rule. |
| `name` | string | Yes | The name of the approval rule. |
| `applies_to_all_protected_branches` | boolean | No | Whether the rule is applied to all protected branches. If set to `true`, the value of `protected_branch_ids` is ignored. Default is `false`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/335316) in GitLab 15.3. |
| `group_ids` | Array | No | The IDs of groups as approvers. |
| `protected_branch_ids` | Array | No | The IDs of protected branches to scope the rule by. To identify the ID, [use the API](protected_branches.md#list-protected-branches). |
| `remove_hidden_groups` | boolean | No | Whether hidden groups should be removed from approval rule. |
| `user_ids` | Array | No | The IDs of users as approvers. If you provide both `user_ids` and `usernames`, both lists of users are added. |
| `usernames` | string array | No | The usernames of approvers for this rule (same as `user_ids` but requires a list of usernames). If you provide both `user_ids` and `usernames`, both lists of users are added. |
```json
{
@ -757,8 +753,6 @@ Supported attributes:
### Delete project-level rule
> - Moved to GitLab Premium in 13.9.
You can delete project approval rules using the following endpoint:
```plaintext
@ -767,19 +761,15 @@ DELETE /projects/:id/approval_rules/:approval_rule_id
Supported attributes:
| Attribute | Type | Required | Description |
|--------------------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approval_rule_id` | integer | Yes | The ID of a approval rule. |
| Attribute | Type | Required | Description |
|--------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approval_rule_id` | integer | Yes | The ID of a approval rule. |
## Merge request-level MR approvals
Configuration for approvals on a specific merge request. Must be authenticated for all endpoints.
### Get Configuration
> - Moved to GitLab Premium in 13.9.
You can request information about a merge request's approval status using the
following endpoint:
@ -789,10 +779,10 @@ GET /projects/:id/merge_requests/:merge_request_iid/approvals
Supported attributes:
| Attribute | Type | Required | Description |
|---------------------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `merge_request_iid` | integer | Yes | The IID of the merge request. |
| Attribute | Type | Required | Description |
|---------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `merge_request_iid` | integer | Yes | The IID of the merge request. |
```json
{
@ -824,8 +814,6 @@ Supported attributes:
### Get the approval state of merge requests
> - Moved to GitLab Premium in 13.9.
You can request information about a merge request's approval state by using the following endpoint:
```plaintext
@ -840,10 +828,10 @@ This includes additional information about the users who have already approved
Supported attributes:
| Attribute | Type | Required | Description |
|---------------------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `merge_request_iid` | integer | Yes | The IID of the merge request. |
| Attribute | Type | Required | Description |
|---------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `merge_request_iid` | integer | Yes | The IID of the merge request. |
```json
{
@ -896,7 +884,6 @@ Supported attributes:
### Get merge request level rules
> - Moved to GitLab Premium in 13.9.
> - Pagination support [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/31011) in GitLab 15.3 [with a flag](../administration/feature_flags.md) named `approval_rules_pagination`. Enabled by default.
> - Pagination support [generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/366823) in GitLab 15.7. Feature flag `approval_rules_pagination` removed.
@ -910,10 +897,10 @@ Use the `page` and `per_page` [pagination](rest/index.md#offset-based-pagination
Supported attributes:
| Attribute | Type | Required | Description |
|---------------------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `merge_request_iid` | integer | Yes | The IID of the merge request. |
| Attribute | Type | Required | Description |
|---------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `merge_request_iid` | integer | Yes | The IID of the merge request. |
```json
[
@ -987,11 +974,11 @@ GET /projects/:id/merge_requests/:merge_request_iid/approval_rules/:approval_rul
Supported attributes:
| Attribute | Type | Required | Description |
|---------------------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approval_rule_id` | integer | Yes | The ID of an approval rule. |
| `merge_request_iid` | integer | Yes | The IID of a merge request. |
| Attribute | Type | Required | Description |
|---------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approval_rule_id` | integer | Yes | The ID of an approval rule. |
| `merge_request_iid` | integer | Yes | The IID of a merge request. |
```json
{
@ -1053,8 +1040,6 @@ Supported attributes:
### Create merge request level rule
> - Moved to GitLab Premium in 13.9.
You can create merge request approval rules using the following endpoint:
```plaintext
@ -1074,7 +1059,8 @@ Supported attributes:
| `user_ids` | Array | No | The IDs of users as approvers. If you provide both `user_ids` and `usernames`, both lists of users are added. |
| `usernames` | string array | No | The usernames of approvers for this rule (same as `user_ids` but requires a list of usernames). If you provide both `user_ids` and `usernames`, both lists of users are added. |
**Important:** When `approval_project_rule_id` is set, the `name`, `users` and
NOTE:
When `approval_project_rule_id` is set, the `name`, `users` and
`groups` of project-level rule are copied. The `approvals_required` specified
is used.
@ -1138,18 +1124,15 @@ is used.
### Update merge request level rule
> - Moved to GitLab Premium in 13.9.
You can update merge request approval rules using the following endpoint:
```plaintext
PUT /projects/:id/merge_requests/:merge_request_iid/approval_rules/:approval_rule_id
```
**Important:** Approvers and groups not in the `users`/`groups` parameters are **removed**
Approvers and groups not in the `users` or `groups` parameters are **removed**.
**Important:** Updating a `report_approver` or `code_owner` rule is not allowed.
These are system generated rules.
You can't update `report_approver` or `code_owner` rules, as these rules are system-generated.
Supported attributes:
@ -1225,16 +1208,13 @@ Supported attributes:
### Delete merge request level rule
> - Moved to GitLab Premium in 13.9.
You can delete merge request approval rules using the following endpoint:
```plaintext
DELETE /projects/:id/merge_requests/:merge_request_iid/approval_rules/:approval_rule_id
```
**Important:** Deleting a `report_approver` or `code_owner` rule is not allowed.
These are system generated rules.
You can't update `report_approver` or `code_owner` rules, as these rules are system-generated.
Supported attributes:
@ -1246,8 +1226,6 @@ Supported attributes:
## Approve merge request
> - Moved to GitLab Premium in 13.9.
If you are allowed to, you can approve a merge request using the following
endpoint:
@ -1257,12 +1235,12 @@ POST /projects/:id/merge_requests/:merge_request_iid/approve
Supported attributes:
| Attribute | Type | Required | Description |
|---------------------|-------------------|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approval_password` | string | No | Current user's password. Required if [**Require user password to approve**](../user/project/merge_requests/approvals/settings.md#require-user-re-authentication-to-approve) is enabled in the project settings. |
| `merge_request_iid` | integer | Yes | The IID of the merge request. |
| `sha` | string | No | The `HEAD` of the merge request. |
| Attribute | Type | Required | Description |
|---------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `approval_password` | string | No | Current user's password. Required if [**Require user password to approve**](../user/project/merge_requests/approvals/settings.md#require-user-re-authentication-to-approve) is enabled in the project settings. |
| `merge_request_iid` | integer | Yes | The IID of the merge request. |
| `sha` | string | No | The `HEAD` of the merge request. |
The `sha` parameter works in the same way as
when [accepting a merge request](merge_requests.md#merge-a-merge-request): if it is passed, then it must
@ -1309,8 +1287,6 @@ does not match, the response code is `409`.
## Unapprove merge request
> - Moved to GitLab Premium in 13.9.
If you did approve a merge request, you can unapprove it using the following
endpoint:
@ -1320,10 +1296,10 @@ POST /projects/:id/merge_requests/:merge_request_iid/unapprove
Supported attributes:
| Attribute | Type | Required | Description |
|---------------------|-------------------|------------------------|-------------------------------------------------------------------------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `merge_request_iid` | integer | Yes | The IID of a merge request. |
| Attribute | Type | Required | Description |
|---------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of a project](rest/index.md#namespaced-path-encoding). |
| `merge_request_iid` | integer | Yes | The IID of a merge request. |
## Reset approvals of a merge request
@ -1336,11 +1312,13 @@ based on project or group tokens. Users without bot permissions receive a `401 U
PUT /projects/:id/merge_requests/:merge_request_iid/reset_approvals
```
| Attribute | Type | Required | Description |
|---------------------|-------------------|----------|-----------------------------------------------------------------------------------------------------------------|
| Attribute | Type | Required | Description |
|---------------------|-------------------|----------|-------------|
| `id` | integer or string | Yes | The ID or [URL-encoded path of the project](rest/index.md#namespaced-path-encoding) owned by the authenticated user. |
| `merge_request_iid` | integer | Yes | The internal ID of the merge request. |
| `merge_request_iid` | integer | Yes | The internal ID of the merge request. |
```shell
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/76/merge_requests/1/reset_approvals"
curl --request PUT \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/76/merge_requests/1/reset_approvals"
```

View File

@ -605,7 +605,7 @@ The table below is a comparison between the existing GitLab.com features, and no
1. How would we synchronize `users` across Cells?
We build out-of-bounds replication of tables marked as `main_clusterwide`. We have yet to define
We build out-of-band replication of tables marked as `main_clusterwide`. We have yet to define
if this would be better to do with an `API` that is part of Rails, or using the Dedicated service.
However, using Rails would likely be the simplest and most reliable solution, because the
application knows the expected data structure.

View File

@ -181,7 +181,7 @@ submitted. It's like `Projects::MergeRequests::CreationsController` but it execu
This API is defined in `ee/lib/api/merge_request_approvals.rb`.
The [Approvals API endpoint](../../api/merge_request_approvals.md#get-configuration-1)
The [Approvals API endpoint](../../api/merge_request_approvals.md#merge-request-level-mr-approvals)
is requested when a merge request page loads.
The `/projects/:id/merge_requests/:merge_request_iid/approval_settings` is a

View File

@ -333,8 +333,7 @@ sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workh
### 13. Update Gitaly
If Gitaly is located on its own server, or you use Gitaly Cluster, see [Gitaly or Gitaly Cluster](zero_downtime.md#gitaly-or-gitaly-cluster)
on the Zero downtime upgrades page.
If Gitaly is located on its own server, or you use Gitaly Cluster, see [Zero Downtime upgrades](zero_downtime.md).
#### Compile Gitaly

View File

@ -208,8 +208,7 @@ DETAILS:
- In GitLab 14.8, we are upgrading Redis from 6.0.16 to 6.2.6. This upgrade is expected to be fully backwards compatible.
If your instance has Redis HA with Sentinel, follow the upgrade steps documented in
[Redis HA (using Sentinel)](../zero_downtime.md#redis-ha-using-sentinel).
Follow [the zero downtime instructions](../zero_downtime.md) for upgrading your Redis HA cluster.
### Geo installations

View File

@ -826,8 +826,7 @@ Specific information applies to Linux package installations:
mentioning that the installed Redis version is different than the one running is
displayed at the end of reconfigure run until the restart is performed.
If your instance has Redis HA with Sentinel, follow the upgrade steps mentioned in
[Zero Downtime documentation](../zero_downtime.md#redis-ha-using-sentinel).
Follow [the zero downtime instructions](../zero_downtime.md) for upgrading your Redis HA cluster.
### Self-compiled installations

View File

@ -94,7 +94,7 @@ following principles when upgrading those servers:
## Upgrade the Gitaly nodes (Praefect / Gitaly Cluster)
If you're running Gitaly cluster, follow the [zero downtime process](zero_downtime.md#gitaly-or-gitaly-cluster)
If you're running Gitaly cluster, follow the [zero downtime process](zero_downtime.md)
for Gitaly cluster.
If you are using Amazon Machine Images (AMIs) on AWS, you can either upgrade the Gitaly nodes
@ -199,7 +199,7 @@ DETAILS:
**Tier:** Premium, Ultimate
**Offering:** Self-managed
Follow [the zero downtime instructions](zero_downtime.md#redis-ha-using-sentinel)
Follow [the zero downtime instructions](zero_downtime.md)
for upgrading your Redis HA cluster.
## Upgrade the Rails components

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,15 @@ DETAILS:
> - GraphQL support [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/352956) in GitLab 14.9 [with a flag](../../administration/feature_flags.md) named `saved_replies`. Disabled by default.
> - User interface [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/113232) in GitLab 15.10 [with a flag](../../administration/feature_flags.md) named `saved_replies`. Disabled by default. Enabled for GitLab team members only.
> - [Enabled on GitLab.com and self-managed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119468) in GitLab 16.0.
> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123363) in GitLab 16.6.
> - [Feature flag `saved_replies` removed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123363) in GitLab 16.6.
> - Group-level saved replies [introduced](https://gitlab.com/groups/gitlab-org/-/epics/12669) in GitLab 16.11 [with a flag](../../administration/feature_flags.md) named `group_saved_replies_flag`. Disabled by default.
> - Group-level saved replies [enabled](https://gitlab.com/gitlab-org/gitlab/-/issues/440817) on GitLab.com in GitLab 16.11.
FLAG:
On self-managed GitLab, by default group-level saved replies are not available.
To make them available, an administrator can [enable the feature flag](../../administration/feature_flags.md) named `group_saved_replies_flag`.
On GitLab.com, this feature is available.
On GitLab Dedicated, this feature is not available.
With comment templates, create and reuse text for any text area in:
@ -25,7 +33,7 @@ With comment templates, create and reuse text for any text area in:
Comment templates can be small, like approving a merge request and unassigning yourself from it,
or large, like chunks of boilerplate text you use frequently:
![Comment templates dropdown list](img/comment_template_v16_6.png)
![Comment templates dropdown list](img/group_comment_templates_v16_11.png)
## Use comment templates in a text area
@ -36,7 +44,13 @@ To include the text of a comment template in your comment:
## Create comment templates
To create a comment template for future use:
You can create comment templates for your own use, or to share with all members of a group.
::Tabs
:::TabTitle For myself
To create a comment template for your own use:
1. On the left sidebar, select your avatar.
1. From the dropdown list, select **Preferences**.
@ -47,18 +61,48 @@ To create a comment template for future use:
other GitLab text areas.
1. Select **Save**, and the page reloads with your comment template shown.
## View your comment templates
:::TabTitle For a group
To go to your comment templates:
To create a comment template shared with all members of a group:
1. In the editor toolbar for a comment, select **Comment templates**
(**{comment-lines}**), then select **Manage group comment templates**.
1. Select **Add new**.
1. Provide a **Name** for your comment template.
1. Enter the **Content** of your reply. You can use any formatting you use in
other GitLab text areas.
1. Select **Save**, and the page reloads with your comment template shown.
::EndTabs
## View comment templates
To see existing comment templates:
::Tabs
:::TabTitle For myself
1. On the left sidebar, select your avatar.
1. From the dropdown list, select **Preferences**.
1. On the left sidebar, select **Comment templates** (**{comment-lines}**).
1. Scroll to **Comment templates**.
:::TabTitle For a group
1. In the editor toolbar for a comment, select **Comment templates**
(**{comment-lines}**).
1. Select **Manage group comment templates**.
::EndTabs
## Edit or delete comment templates
To edit or delete a previously comment template:
To edit or delete an existing comment template:
::Tabs
:::TabTitle For myself
1. On the left sidebar, select your avatar.
1. From the dropdown list, select **Preferences**.
@ -66,3 +110,12 @@ To edit or delete a previously comment template:
1. Scroll to **Comment templates**, and identify the comment template you want to edit.
1. To edit, select **Edit** (**{pencil}**).
1. To delete, select **Delete** (**{remove}**), then select **Delete** again on the dialog.
:::TabTitle For a group
1. In the editor toolbar for a comment, select **Comment templates**
(**{comment-lines}**), then select **Manage group comment templates**.
1. To edit, select **Edit** (**{pencil}**).
1. To delete, select **Delete** (**{remove}**), then select **Delete** again on the dialog.
::EndTabs

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -65,7 +65,7 @@ GitLab CLI. The changelog output is formatted in Markdown, and
### From the API
To generate changelogs via the API with a `curl` command, see
To use the API to generate changelogs with a `curl` command, see
[Add changelog data to a changelog file](../../api/repositories.md#add-changelog-data-to-a-changelog-file)
in the API documentation.
@ -303,8 +303,6 @@ corresponding merge request, no merge request is displayed.
### Customize the tag format when extracting versions
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56889) in GitLab 13.11.
GitLab uses a regular expression (using the
[re2](https://github.com/google/re2/) engine and syntax) to extract a semantic
version from tag names. The default regular expression is:
@ -351,8 +349,6 @@ an error is produced when generating a changelog.
## Reverted commit handling
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55537) in GitLab 13.10.
To be treated as a revert commit, the commit message must contain the string
`This reverts commit <SHA>`, where `SHA` is the SHA of the commit to be reverted.
@ -380,3 +376,4 @@ Commit B is skipped.
## Related topics
- [Changelog-related endpoints](../../api/repositories.md) in the Repositories API.
- [`glab changelog`](https://gitlab.com/gitlab-org/cli/-/tree/main/docs/source/changelog) in the GitLab CLI documentation.

View File

@ -138,10 +138,7 @@ On this page, you can:
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88279) in GitLab 15.1 with a flag named `branch_rules`. Disabled by default.
> - [Enabled on GitLab.com](https://gitlab.com/gitlab-org/gitlab/-/issues/363170) in GitLab 15.10.
> - [Enabled on self-managed](https://gitlab.com/gitlab-org/gitlab/-/issues/363170) in GitLab 15.11.
FLAG:
On self-managed GitLab, by default this feature is available. To hide the feature, an administrator can [disable the feature flag](../../../feature_flags.md) named `branch_rules`.
On GitLab.com and GitLab Dedicated, this feature is available.
> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123368) in GitLab 16.1. Feature flag `branch_rules` removed.
Branches in your repository can be [protected](../../protected_branches.md) in multiple ways. You can:

View File

@ -50,6 +50,14 @@ module Gitlab
push_options: { ci: { skip: true } }
}.freeze
DEFAULT_TAG_NAME = 'v1.0.0'
SAMPLE_TAG_DATA =
{
object_kind: "tag_push",
event_name: "tag_push",
ref: "refs/tags/#{DEFAULT_TAG_NAME}"
}.freeze
# Produce a hash of post-receive data
#
# data = {
@ -147,12 +155,17 @@ module Gitlab
# This method provides a sample data generated with
# existing project and commits to test webhooks
def build_sample(project, user)
def build_sample(project, user, is_tag = false)
# Use sample data if repo has no commit
# (expect the case of test service configuration settings)
return sample_data if project.empty_repo?
return sample_data(is_tag) if project.empty_repo?
ref = if is_tag
"#{Gitlab::Git::TAG_REF_PREFIX}#{sample_tag_name(project) || DEFAULT_TAG_NAME}"
else
"#{Gitlab::Git::BRANCH_REF_PREFIX}#{project.default_branch}"
end
ref = "#{Gitlab::Git::BRANCH_REF_PREFIX}#{project.default_branch}"
commits = project.repository.commits(project.default_branch.to_s, limit: 3)
build(project: project,
@ -163,8 +176,12 @@ module Gitlab
commits: commits)
end
def sample_data
SAMPLE_DATA
def sample_data(is_tag = false)
if is_tag
SAMPLE_DATA.merge(SAMPLE_TAG_DATA)
else
SAMPLE_DATA
end
end
def checkout_sha(repository, newrev, ref)
@ -184,6 +201,10 @@ module Gitlab
newrev
end
end
def sample_tag_name(project)
project.repository.tags_sorted_by(:name_desc, limit: 1).first&.name
end
end
end
end

View File

@ -3,6 +3,8 @@
namespace :grape do
desc 'Print compiled grape routes'
task routes: :environment do
# Getting the source of the endpoints
# https://forum.gitlab.com/t/corresponding-ruby-file-for-route-api-v4-jobs-request/16663
API::API.routes.each do |route|
puts "#{route.options[:method]} #{route.path} - #{route_description(route.options)}"
end

View File

@ -16940,6 +16940,12 @@ msgstr ""
msgid "DeletionSettings|Deletion protection"
msgstr ""
msgid "DeletionSettings|Maximum deletion protection duration is 90 days."
msgstr ""
msgid "DeletionSettings|Minimum deletion protection duration is 1 day."
msgstr ""
msgid "DeletionSettings|Period that deleted groups and projects will remain restorable for. Personal projects are always deleted immediately."
msgstr ""

View File

@ -688,8 +688,18 @@ describe('buildClient', () => {
it('fetches metrics from the metrics URL', async () => {
const mockResponse = {
metrics: [
{ name: 'metric A', description: 'a counter metric called A', type: 'COUNTER' },
{ name: 'metric B', description: 'a gauge metric called B', type: 'GAUGE' },
{
name: 'metric A',
description: 'a counter metric called A',
type: 'COUNTER',
attributes: [],
},
{
name: 'metric B',
description: 'a gauge metric called B',
type: 'GAUGE',
attributes: [],
},
],
};
@ -844,25 +854,13 @@ describe('buildClient', () => {
});
expect(getQueryParam()).toBe(
'mname=name&mtype=type' +
'&attr_1=foo&not[attr_1]=bar' +
'&like[attr_2]=foo&not_like[attr_2]=bar',
'&attrs=attr_1,eq,foo' +
'&attrs=attr_1,neq,bar' +
'&attrs=attr_2,re,foo' +
'&attrs=attr_2,nre,bar',
);
});
it('handles repeated params', async () => {
await client.fetchMetric('name', 'type', {
filters: {
attributes: {
attr_1: [
{ operator: '=', value: 'v1' },
{ operator: '=', value: 'v2' },
],
},
},
});
expect(getQueryParam()).toContain('attr_1=v1&attr_1=v2');
});
it('ignores empty filters', async () => {
await client.fetchMetric('name', 'type', {
filters: { attributes: [] },

View File

@ -137,6 +137,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive, feature_category: :scalability do
allow_next_instance_of(Ci::JobArtifact) do |artifact|
artifact.job_id = job.id
artifact.partition_id = job.partition_id
expect(artifact)
.to receive(:store_file!)

View File

@ -40,21 +40,35 @@ RSpec.describe Gitlab::DataBuilder::Push do
end
end
describe '.build_sample' do
describe '.build_sample push event' do
let(:data) { described_class.build_sample(project, user) }
it { expect(data).to be_a(Hash) }
it { expect(data[:before]).to eq('1b12f15a11fc6e62177bef08f47bc7b5ce50b141') }
it { expect(data[:after]).to eq('b83d6e391c22777fca1ed3012fce84f633d7fed0') }
it { expect(data[:object_kind]).to eq('push') }
it { expect(data[:event_name]).to eq('push') }
it { expect(data[:ref]).to eq('refs/heads/master') }
it { expect(data[:commits].size).to eq(3) }
it { expect(data[:total_commits_count]).to eq(3) }
it { expect(data[:commits].first[:added]).to eq(['bar/branch-test.txt']) }
it { expect(data[:commits].first[:modified]).to eq([]) }
it { expect(data[:commits].first[:removed]).to eq([]) }
include_examples 'project hook data with deprecateds'
include_examples 'deprecated repository hook data'
include_examples 'push hook data'
end
describe '.build_sample with tag push event' do
let(:data) { described_class.build_sample(project, user, is_tag: true) }
it { expect(data[:object_kind]).to eq('tag_push') }
it { expect(data[:event_name]).to eq('tag_push') }
it { expect(data[:ref]).to eq('refs/tags/v1.1.1') }
describe "empty repository" do
let_it_be(:project) { create(:project_empty_repo) }
let(:data) { described_class.build_sample(project, user, is_tag: true) }
it { expect(data[:ref]).to eq('refs/tags/v1.0.0') }
end
include_examples 'project hook data with deprecateds'
include_examples 'deprecated repository hook data'
include_examples 'push hook data'
end
describe '.sample_data' do

View File

@ -115,7 +115,9 @@ RSpec.describe Ci::UnlockPipelineService, :unlock_pipelines, :clean_gitlab_redis
before do
mock_relation = instance_double('Ci::JobArtifact::ActiveRecord_Relation')
allow(Ci::JobArtifact).to receive(:where).and_call_original
allow(Ci::JobArtifact).to receive(:where).with(id: [last_artifact.id]).and_return(mock_relation)
allow(Ci::JobArtifact).to receive(:where)
.with(id: [last_artifact.id], partition_id: last_artifact.partition_id)
.and_return(mock_relation)
allow(mock_relation).to receive(:update_all).and_raise('An error')
end

View File

@ -125,7 +125,8 @@ RSpec.describe DesignManagement::SaveDesignsService, feature_category: :design_m
subject(:service_action) { run_service }
end
it 'can run the same command in parallel' do
it 'can run the same command in parallel',
quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/450483' do
parellism = 4
blocks = Array.new(parellism).map do

View File

@ -47,7 +47,10 @@ RSpec.describe TestHooks::ProjectService, feature_category: :code_testing do
let(:trigger_key) { :tag_push_hooks }
it 'executes hook' do
allow(Gitlab::DataBuilder::Push).to receive(:build_sample).and_return(sample_data)
allow(Gitlab::DataBuilder::Push)
.to receive(:build_sample)
.with(project, current_user, is_tag: true)
.and_return(sample_data)
expect(hook).to receive(:execute).with(sample_data, trigger_key, force: true).and_return(success_result)
expect(service.execute).to include(success_result)

View File

@ -42,3 +42,16 @@ RSpec.shared_examples 'deprecated repository hook data' do
expect(data[:repository][:homepage]).to eq(project.web_url)
end
end
RSpec.shared_examples 'push hook data' do
it 'contains commit data' do
expect(data).to be_a(Hash)
expect(data[:before]).to eq('1b12f15a11fc6e62177bef08f47bc7b5ce50b141')
expect(data[:after]).to eq('b83d6e391c22777fca1ed3012fce84f633d7fed0')
expect(data[:commits].size).to eq(3)
expect(data[:total_commits_count]).to eq(3)
expect(data[:commits].first[:added]).to eq(['bar/branch-test.txt'])
expect(data[:commits].first[:modified]).to eq([])
expect(data[:commits].first[:removed]).to eq([])
end
end

View File

@ -120,7 +120,6 @@ RSpec.describe 'Every Sidekiq worker', feature_category: :shared do
{
'AdjournedProjectDeletionWorker' => 3,
'AdminEmailsWorker' => 3,
'Ai::SyncServiceTokenWorker' => 3, # TODO: remove starting 16.11, see https://gitlab.com/groups/gitlab-org/-/epics/12544
'Analytics::CodeReviewMetricsWorker' => 3,
'Analytics::DevopsAdoption::CreateSnapshotWorker' => 3,
'Analytics::UsageTrends::CounterJobWorker' => 3,

View File

@ -3,8 +3,8 @@
require_relative '../lib/tooling/gettext_extractor'
silent = ARGV.delete('--silent')
pot_file = ARGV.shift
silent = '--silent' in ARGV
if !pot_file || !Dir.exist?(File.dirname(pot_file))
abort <<~MSG

View File

@ -16,7 +16,7 @@ require (
github.com/johannesboyne/gofakes3 v0.0.0-20240217095638-c55a48f17be6
github.com/jpillora/backoff v1.0.0
github.com/mitchellh/copystructure v1.2.0
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/client_golang v1.19.0
github.com/redis/go-redis/v9 v9.5.1
github.com/sebest/xff v0.0.0-20210106013422-671bd2870b3a
github.com/sirupsen/logrus v1.9.3
@ -95,7 +95,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.46.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/prometheus v0.50.1 // indirect
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 // indirect

View File

@ -373,13 +373,13 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y=
github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ=
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/prometheus/prometheus v0.50.1 h1:N2L+DYrxqPh4WZStU+o1p/gQlBaqFbcLBTjlp3vpdXw=