Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-01-18 03:11:34 +00:00
parent 67bc0f801f
commit 104ac5e939
25 changed files with 231 additions and 52 deletions

View File

@ -1673,4 +1673,4 @@ DEPENDENCIES
yajl-ruby (~> 1.4.1)
BUNDLED WITH
2.3.5
2.1.4

View File

@ -56,6 +56,7 @@ export default {
</gl-sprintf>
</template>
<gl-sprintf
v-if="subjectName"
:message="
__(
`%{strongStart}${labelName}%{strongEnd} will be permanently deleted from ${subjectName}. This cannot be undone.`,
@ -66,6 +67,18 @@ export default {
<strong>{{ content }}</strong>
</template>
</gl-sprintf>
<gl-sprintf
v-else
:message="
__(
`%{strongStart}${labelName}%{strongEnd} will be permanently deleted. This cannot be undone.`,
)
"
>
<template #strong="{ content }">
<strong>{{ content }}</strong>
</template>
</gl-sprintf>
<template #modal-footer>
<gl-button category="secondary" @click="closeModal">{{ __('Cancel') }}</gl-button>
<gl-button

View File

@ -1,3 +1,5 @@
import Labels from '~/labels/labels';
import { initDeleteLabelModal } from '~/labels';
new Labels(); // eslint-disable-line no-new
initDeleteLabelModal();

View File

@ -1,4 +1,6 @@
import Labels from 'ee_else_ce/labels/labels';
import { initDeleteLabelModal } from '~/labels';
// eslint-disable-next-line no-new
new Labels();
initDeleteLabelModal();

View File

@ -1,3 +1,5 @@
import Labels from 'ee_else_ce/labels/labels';
import { initDeleteLabelModal } from '~/labels';
new Labels(); // eslint-disable-line no-new
initDeleteLabelModal();

View File

@ -260,7 +260,7 @@ class Label < ApplicationRecord
attributes
end
def present(attributes)
def present(attributes = {})
super(**attributes.merge(presenter_class: ::LabelPresenter))
end

View File

@ -2,7 +2,7 @@
class LabelPresenter < Gitlab::View::Presenter::Delegated
presents ::Label, as: :label
delegate :name, :full_name, to: :label_subject, prefix: :subject
delegate :name, :full_name, to: :label_subject, prefix: :subject, allow_nil: true
delegator_override :subject # TODO: Fix `Gitlab::View::Presenter::Delegated#subject` not to override `Label#subject`.
@ -10,6 +10,7 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated
case label
when GroupLabel then edit_group_label_path(label.group, label)
when ProjectLabel then edit_project_label_path(label.project, label)
else edit_admin_label_path(label)
end
end
@ -17,6 +18,7 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated
case label
when GroupLabel then group_label_path(label.group, label)
when ProjectLabel then project_label_path(label.project, label)
else admin_label_path(label)
end
end
@ -43,7 +45,7 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated
end
def label_subject
@label_subject ||= label.subject
@label_subject ||= label.subject if label.respond_to?(:subject)
end
private

View File

@ -26,9 +26,14 @@
%br
= _("Or you can choose one of the suggested colors below")
= render_suggested_colors
.form-actions
.gl-display-flex.gl-justify-content-space-between.gl-p-5.gl-bg-gray-10.gl-border-t-solid.gl-border-t-gray-100.gl-border-t-1
%div
- if @label.persisted?
= f.submit _('Save changes'), class: 'btn gl-button btn-confirm js-save-button'
- else
= f.submit _('Create label'), class: 'btn gl-button btn-confirm js-save-button qa-label-create-button'
= link_to _('Cancel'), back_path, class: 'btn gl-button btn-default btn-cancel'
- if @label.persisted?
= f.submit _('Save changes'), class: 'btn gl-button btn-confirm js-save-button'
- else
= f.submit _('Create label'), class: 'btn gl-button btn-confirm js-save-button qa-label-create-button'
= link_to _('Cancel'), back_path, class: 'btn gl-button btn-default btn-cancel'
- presented_label = @label.present
%button.btn.btn-danger.gl-button.btn-danger-secondary.js-delete-label-modal-button{ type: 'button', data: { label_name: presented_label.name, subject_name: presented_label.subject_name, destroy_path: presented_label.destroy_path } }
%span.gl-button-text= _('Delete')

View File

@ -1125,3 +1125,66 @@ Example:
"time":"2021-03-25T14:57:53.543Z"
}
```
## Repository consistency checks
Gitaly runs repository consistency checks:
- When triggering a repository check.
- When changes are fetched from a mirrored repository.
- When users push changes into repository.
These consistency checks verify that a repository has all required objects and
that these objects are valid objects. They can be categorized as:
- Basic checks that assert that a repository doesn't become corrupt. This
includes connectivity checks and checks that objects can be parsed.
- Security checks that recognize objects that are suitable to exploit past
security-related bugs in Git.
- Cosmetic checks that verify that all object metadata is valid. Older Git
versions and other Git implementations may have produced objects with invalid
metadata, but newer versions can interpret these malformed objects.
Removing malformed objects that fail the consistency checks requires a
rewrite of the repository's history, which often can't be done. Therefore,
Gitaly by default disables consistency checks for a range of cosmetic issues
that don't negatively impact repository consistency.
By default, Gitaly doesn't disable basic or security-related checks so
to not distribute objects that can trigger known vulnerabilities in Git
clients. This also limits the ability to import repositories containing such
objects even if the project doesn't have malicious intent.
### Override repository consistency checks
Instance administrators can override consistency checks if they must
process repositories that do not pass consistency checks.
For Omnibus GitLab installations, edit `/etc/gitlab/gitlab.rb` and set the
following keys (in this example, to disable the `hasDotgit` consistency check):
```ruby
ignored_git_errors = ["hasDotgit = ignore"]
omnibus_gitconfig['system'] = {
"fsck" => ignored_git_errors,
"fetch.fsck" => ignored_git_errors,
"receive.fsck" => ignored_git_errors,
}
```
For source installs, edit the Gitaly configuration (`gitaly.toml`) to do the
equivalent:
```toml
[[git.config]]
key = "fsck.hasDotgit"
value = "ignore"
[[git.config]]
key = "fetch.fsck.hasDotgit"
value = "ignore"
[[git.config]]
key = "receive.fsck.hasDotgit"
value = "ignore"
```

View File

@ -404,10 +404,7 @@ build:
If you change multiple files, but only one file ends in `.md`,
the `build` job is still skipped. The job does not run for any of the files.
Read more about how to use `only:changes` and `except:changes`:
- [New branches or tags *without* pipelines for merge requests](#use-onlychanges-without-pipelines-for-merge-requests).
- [Scheduled pipelines](#use-onlychanges-with-scheduled-pipelines).
With some configurations that use `changes`, [jobs or pipelines might run unexpectedly](#jobs-or-pipelines-run-unexpectedly-when-using-changes)
#### Use `only:changes` with pipelines for merge requests
@ -459,22 +456,6 @@ it doesn't matter that an earlier pipeline failed because of a change that has n
When you use this configuration, ensure that the most recent pipeline
properly corrects any failures from previous pipelines.
#### Use `only:changes` without pipelines for merge requests
Without [pipelines for merge requests](../pipelines/merge_request_pipelines.md), pipelines
run on branches or tags that don't have an explicit association with a merge request.
In this case, a previous SHA is used to calculate the diff, which is equivalent to `git diff HEAD~`.
This can result in some unexpected behavior, including:
- When pushing a new branch or a new tag to GitLab, the policy always evaluates to true.
- When pushing a new commit, the changed files are calculated by using the previous commit
as the base SHA.
#### Use `only:changes` with scheduled pipelines
`only:changes` always evaluates as true in [Scheduled pipelines](../pipelines/schedules.md).
All files are considered to have changed when a scheduled pipeline runs.
### Combine multiple keywords with `only` or `except`
If you use multiple keywords with `only` or `except`, the keywords are evaluated
@ -943,3 +924,23 @@ For example:
- `($VARIABLE1 =~ /^content.*/ || $VARIABLE2) && ($VARIABLE3 =~ /thing$/ || $VARIABLE4)`
- `($VARIABLE1 =~ /^content.*/ || $VARIABLE2 =~ /thing$/) && $VARIABLE3`
- `$CI_COMMIT_BRANCH == "my-branch" || (($VARIABLE1 == "thing" || $VARIABLE2 == "thing") && $VARIABLE3)`
## Troubleshooting
### Jobs or pipelines run unexpectedly when using `changes:`
You might have jobs or pipelines that run unexpectedly when using [`rules: changes`](../yaml/index.md#ruleschanges)
or [`only: changes`](../yaml/index.md#onlychanges--exceptchanges) without
[pipelines for merge requests](../pipelines/merge_request_pipelines.md).
Pipelines on branches or tags that don't have an explicit association with a merge request
use a previous SHA to calculate the diff. This calculation is equivalent to `git diff HEAD~`
and can cause unexpected behavior, including:
- The `changes` rule always evaluates to true when pushing a new branch or a new tag to GitLab.
- When pushing a new commit, the changed files are calculated by using the previous commit
as the base SHA.
Additionally, rules with `changes` always evaluate as true in [scheduled pipelines](../pipelines/schedules.md).
All files are considered to have changed when a scheduled pipeline runs, so jobs
might always be added to scheduled pipelines that use `changes`.

View File

@ -2508,8 +2508,7 @@ docker build:
- [`only: changes` and `except: changes` examples](../jobs/job_control.md#onlychanges--exceptchanges-examples).
- If you use `changes` with [only allow merge requests to be merged if the pipeline succeeds](../../user/project/merge_requests/merge_when_pipeline_succeeds.md#only-allow-merge-requests-to-be-merged-if-the-pipeline-succeeds),
you should [also use `only:merge_requests`](../jobs/job_control.md#use-onlychanges-with-pipelines-for-merge-requests).
- Use `changes` with [new branches or tags *without* pipelines for merge requests](../jobs/job_control.md#use-onlychanges-without-pipelines-for-merge-requests).
- Use `changes` with [scheduled pipelines](../jobs/job_control.md#use-onlychanges-with-scheduled-pipelines).
- [Jobs or pipelines can run unexpectedly when using `only: changes`](../jobs/job_control.md#jobs-or-pipelines-run-unexpectedly-when-using-changes).
#### `only:kubernetes` / `except:kubernetes`
@ -3125,6 +3124,10 @@ docker build:
- You can use `when: never` to implement a rule similar to [`except:changes`](#onlychanges--exceptchanges).
- `changes` resolves to `true` if any of the matching files are changed (an `OR` operation).
**Related topics**:
- [Jobs or pipelines can run unexpectedly when using `rules: changes`](../jobs/job_control.md#jobs-or-pipelines-run-unexpectedly-when-using-changes).
#### `rules:exists`
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/24021) in GitLab 12.4.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -7,13 +7,12 @@ type: reference
# Labels administration **(FREE SELF)**
In the Admin Area, you can manage labels for the GitLab instance. For more details, see [Labels](../project/labels.md).
To manage labels for the GitLab instance, select **Labels** (**{labels}**) from the Admin Area sidebar. For more details on how to manage labels, see [Labels](../project/labels.md).
## Default Labels
Labels created in the Admin Area are automatically added to new projects.
Updating or adding labels in the Admin Area does not modify labels in existing projects.
Labels created in the Admin Area become available to each _new_ project.
![Default label set](img/admin_labels.png)
![Default label set](img/admin_labels_v14_7.png)
<!-- ## Troubleshooting

View File

@ -90,9 +90,10 @@ label section of the right sidebar of an issue or a merge request:
color value for a specific color.
1. Click **Create**.
Once created, you can edit a label by clicking the pencil (**{pencil}**), or delete
a label by clicking the three dots (**{ellipsis_v}**) next to the **Subscribe** button
and selecting **Delete**.
To edit a label after you create it, select (**{pencil}**).
To delete a project label, select (**{ellipsis_v}**) next to the **Subscribe** button
and select **Delete** or select **Delete** when you edit a label.
WARNING:
If you delete a label, it is permanently deleted. All references to the label are removed from the system and you cannot undo the deletion.

View File

@ -63,7 +63,6 @@ WORKDIR /home/gitlab/qa
# Install qa dependencies or fetch from cache if unchanged
COPY ./qa/Gemfile* /home/gitlab/qa/
RUN gem install bundler --no-document --conservative --version 2.3.5
RUN bundle install --jobs=$(nproc) --retry=3 --without=development --quiet
##

View File

@ -355,4 +355,4 @@ DEPENDENCIES
zeitwerk (~> 2.4)
BUNDLED WITH
2.3.5
2.2.33

View File

@ -36,7 +36,6 @@ function bundle_install_script() {
exit 1;
fi;
gem install bundler --no-document --conservative --version 2.3.5
bundle --version
bundle config set path "$(pwd)/vendor"
bundle config set clean 'true'

View File

@ -47,7 +47,7 @@ RSpec.describe 'bin/metrics-server', :aggregate_failures do
if @pid
pgrp = Process.getpgid(@pid)
Timeout.timeout(10) do
Timeout.timeout(5) do
Process.kill('TERM', -pgrp)
Process.waitpid(@pid)
end
@ -63,7 +63,7 @@ RSpec.describe 'bin/metrics-server', :aggregate_failures do
it 'serves /metrics endpoint' do
expect do
Timeout.timeout(10) do
Timeout.timeout(5) do
http_ok = false
until http_ok
sleep 1

View File

@ -42,4 +42,6 @@ FactoryBot.define do
factory :group_label, traits: [:base_label] do
group
end
factory :admin_label, traits: [:base_label], class: 'Label'
end

View File

@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe 'admin issues labels' do
include Spec::Support::Helpers::ModalHelpers
let!(:bug_label) { Label.create!(title: 'bug', template: true) }
let!(:feature_label) { Label.create!(title: 'feature', template: true) }
@ -99,5 +101,19 @@ RSpec.describe 'admin issues labels' do
expect(page).to have_content('fix')
end
end
it 'allows user to delete label', :js do
visit edit_admin_label_path(bug_label)
click_button 'Delete'
within_modal do
expect(page).to have_content("#{bug_label.title} will be permanently deleted. This cannot be undone.")
click_link 'Delete label'
end
expect(page).to have_content('Label was removed')
end
end
end

View File

@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe 'Edit group label' do
include Spec::Support::Helpers::ModalHelpers
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:label) { create(:group_label, group: group) }
@ -20,4 +22,16 @@ RSpec.describe 'Edit group label' do
expect(current_path).to eq(root_path)
expect(label.reload.title).to eq('new label name')
end
it 'allows user to delete label', :js do
click_button 'Delete'
within_modal do
expect(page).to have_content("#{label.title} will be permanently deleted from #{group.name}. This cannot be undone.")
click_link 'Delete label'
end
expect(page).to have_content("#{label.title} deleted permanently")
end
end

View File

@ -3,6 +3,8 @@
require "spec_helper"
RSpec.describe "User edits labels" do
include Spec::Support::Helpers::ModalHelpers
let_it_be(:project) { create(:project_empty_repo, :public) }
let_it_be(:label) { create(:label, project: project) }
let_it_be(:user) { create(:user) }
@ -24,4 +26,16 @@ RSpec.describe "User edits labels" do
expect(page).to have_content(new_title).and have_no_content(label.title)
end
end
it 'allows user to delete label', :js do
click_button 'Delete'
within_modal do
expect(page).to have_content("#{label.title} will be permanently deleted from #{project.name}. This cannot be undone.")
click_link 'Delete label'
end
expect(page).to have_content('Label was removed')
end
end

View File

@ -13,6 +13,10 @@ describe('DeleteLabelModal', () => {
subjectName: 'GitLab Org',
destroyPath: `${TEST_HOST}/2`,
},
{
labelName: 'admin label',
destroyPath: `${TEST_HOST}/3`,
},
];
beforeEach(() => {
@ -22,8 +26,12 @@ describe('DeleteLabelModal', () => {
const button = document.createElement('button');
button.setAttribute('class', 'js-delete-label-modal-button');
button.setAttribute('data-label-name', x.labelName);
button.setAttribute('data-subject-name', x.subjectName);
button.setAttribute('data-destroy-path', x.destroyPath);
if (x.subjectName) {
button.setAttribute('data-subject-name', x.subjectName);
}
button.innerHTML = 'Action';
buttonContainer.appendChild(button);
});
@ -62,6 +70,7 @@ describe('DeleteLabelModal', () => {
index
${0}
${1}
${2}
`(`when multiple buttons exist`, ({ index }) => {
beforeEach(() => {
initDeleteLabelModal();
@ -69,14 +78,22 @@ describe('DeleteLabelModal', () => {
});
it('correct props are passed to gl-modal', () => {
expect(findModal().querySelector('.modal-title').innerHTML).toContain(
buttons[index].labelName,
);
expect(findModal().querySelector('.modal-body').innerHTML).toContain(
buttons[index].subjectName,
);
const button = buttons[index];
expect(findModal().querySelector('.modal-title').innerHTML).toContain(button.labelName);
if (button.subjectName) {
expect(findModal().querySelector('.modal-body').textContent).toContain(
`${button.labelName} will be permanently deleted from ${button.subjectName}. This cannot be undone.`,
);
} else {
expect(findModal().querySelector('.modal-body').textContent).toContain(
`${button.labelName} will be permanently deleted. This cannot be undone.`,
);
}
expect(findModal().querySelector('.modal-footer .btn-danger').href).toContain(
buttons[index].destroyPath,
button.destroyPath,
);
});
});

View File

@ -10,6 +10,7 @@ RSpec.describe LabelPresenter do
let(:label) { build_stubbed(:label, project: project).present(issuable_subject: project) }
let(:group_label) { build_stubbed(:group_label, group: group).present(issuable_subject: project) }
let(:admin_label) { build_stubbed(:admin_label).present(issuable_subject: nil) }
describe '#edit_path' do
context 'with group label' do
@ -23,6 +24,12 @@ RSpec.describe LabelPresenter do
it { is_expected.to eq(edit_project_label_path(project, label)) }
end
context 'with an admin label' do
subject { admin_label.edit_path }
it { is_expected.to eq(edit_admin_label_path(admin_label)) }
end
end
describe '#destroy_path' do
@ -37,6 +44,12 @@ RSpec.describe LabelPresenter do
it { is_expected.to eq(project_label_path(project, label)) }
end
context 'with an admin label' do
subject { admin_label.destroy_path }
it { is_expected.to eq(admin_label_path(admin_label)) }
end
end
describe '#filter_path' do
@ -91,6 +104,12 @@ RSpec.describe LabelPresenter do
it { is_expected.to eq(label.project.name) }
end
context 'with an admin label' do
subject { admin_label.subject_name }
it { is_expected.to be_nil }
end
end
describe '#subject_full_name' do
@ -105,5 +124,11 @@ RSpec.describe LabelPresenter do
it { is_expected.to eq(label.project.full_name) }
end
context 'with an admin label' do
subject { admin_label.subject_full_name }
it { is_expected.to be_nil }
end
end
end