Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-10-07 03:08:02 +00:00
parent b3e461ab0f
commit 26e0767a07
23 changed files with 166 additions and 46 deletions

View File

@ -37,7 +37,7 @@ gem 'view_component', '~> 2.71.0'
gem 'default_value_for', '~> 3.4.0'
# Supported DBs
gem 'pg', '~> 1.4.0'
gem 'pg', '~> 1.4.3'
gem 'rugged', '~> 1.2'
gem 'grape-path-helpers', '~> 1.7.1'
@ -334,7 +334,7 @@ gem 'sentry-sidekiq', '~> 5.1.1'
# PostgreSQL query parsing
#
gem 'pg_query', '~> 2.1.0'
gem 'pg_query', '~> 2.1.4'
gem 'premailer-rails', '~> 1.10.3'

View File

@ -401,10 +401,10 @@
{"name":"parslet","version":"1.8.2","platform":"ruby","checksum":"08d1ab3721cd3f175bfbee8788b2ddff71f92038f2d69bd65454c22bb9fbd98a"},
{"name":"pastel","version":"0.8.0","platform":"ruby","checksum":"481da9fb7d2f6e6b1a08faf11fa10363172dc40fd47848f096ae21209f805a75"},
{"name":"peek","version":"1.1.0","platform":"ruby","checksum":"d6501ead8cde46d8d8ed0d59eb6f0ba713d0a41c11a2c4a81447b2dce37b3ecc"},
{"name":"pg","version":"1.4.1","platform":"ruby","checksum":"386bbffad223cce1dda903dad2c59268e41f3d183792506671ae526011ff0487"},
{"name":"pg","version":"1.4.1","platform":"x64-mingw-ucrt","checksum":"de35769d4e7c25daa035f2dc33447e74711ab0dc8b73f685a846987e0080d030"},
{"name":"pg","version":"1.4.1","platform":"x64-mingw32","checksum":"3457bf6bfdda7144097ef23d490a83980ba4572c78c58689aadaf58940a1989d"},
{"name":"pg","version":"1.4.1","platform":"x86-mingw32","checksum":"323d09138b7bbfc6ae8eb427774d3639fc0e995983e65bb729527bf8e859fc29"},
{"name":"pg","version":"1.4.3","platform":"ruby","checksum":"ab0219cdd9e5750abb04b8bca5a5a490f60abdf37503027fd2f90d0c2d31f2fa"},
{"name":"pg","version":"1.4.3","platform":"x64-mingw-ucrt","checksum":"9f4d1d39af5ae5eea9f3c6b1e3092cbd5d26b716ff0e1283cf71c0690c69b36c"},
{"name":"pg","version":"1.4.3","platform":"x64-mingw32","checksum":"3265afd0e00331c7c70e50d4a13eea9083e5b683ebcd808bd671af70d92b189e"},
{"name":"pg","version":"1.4.3","platform":"x86-mingw32","checksum":"08a6ef4c702e313c1a04ad6b088b1843361ca8606843c7cd607e181e0d4e5508"},
{"name":"pg_query","version":"2.1.4","platform":"ruby","checksum":"48f1363f88cf9d86fa11d76d1b0f839ca3723b8bd397b7cbc4b578e1ca82d0bb"},
{"name":"plist","version":"3.6.0","platform":"ruby","checksum":"f468bcf6b72ec6d1585ed6744eb4817c1932a5bf91895ed056e69b7f12ca10f2"},
{"name":"png_quantizator","version":"0.2.1","platform":"ruby","checksum":"6023d4d064125c3a7e02929c95b7320ed6ac0d7341f9e8de0c9ea6576ef3106b"},

View File

@ -1024,7 +1024,7 @@ GEM
tty-color (~> 0.5)
peek (1.1.0)
railties (>= 4.0.0)
pg (1.4.1)
pg (1.4.3)
pg_query (2.1.4)
google-protobuf (>= 3.19.2)
plist (3.6.0)
@ -1720,8 +1720,8 @@ DEPENDENCIES
parallel (~> 1.19)
parslet (~> 1.8)
peek (~> 1.1)
pg (~> 1.4.0)
pg_query (~> 2.1.0)
pg (~> 1.4.3)
pg_query (~> 2.1.4)
png_quantizator (~> 0.2.1)
premailer-rails (~> 1.10.3)
prometheus-client-mmap (~> 0.16)

View File

@ -518,6 +518,7 @@ function continueOlText(listLineMatch, nextLineMatch) {
}
function handleContinueList(e, textArea) {
if (!gon.markdown_automatic_lists) return;
if (!(e.key === 'Enter')) return;
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
if (textArea.selectionStart !== textArea.selectionEnd) return;

View File

@ -383,9 +383,7 @@ function UsersSelect(currentUser, els, options = {}) {
},
suggestedUsers(users) {
const selected = getSelected().filter((i) => i !== 0);
const suggestedUsers = users
.filter((u) => u.suggested && selected.indexOf(u.id) === -1)
.sort((a, b) => a.name > b.name);
const suggestedUsers = users.filter((u) => u.suggested && selected.indexOf(u.id) === -1);
if (!suggestedUsers.length) return [];

View File

@ -55,7 +55,8 @@ class Profiles::PreferencesController < Profiles::ApplicationController
:sourcegraph_enabled,
:gitpod_enabled,
:render_whitespace_in_code,
:markdown_surround_selection
:markdown_surround_selection,
:markdown_automatic_lists
]
end
end

View File

@ -74,10 +74,22 @@ class MergeRequest < ApplicationRecord
manual_inverse_association :latest_merge_request_diff, :merge_request
def suggested_reviewer_users
return [] unless predictions && predictions.suggested_reviewers.is_a?(Hash)
return User.none unless predictions && predictions.suggested_reviewers.is_a?(Hash)
usernames = Array.wrap(suggested_reviewers["reviewers"])
project.authorized_users.active.by_username(usernames)
return User.none if usernames.empty?
# Preserve the orginal order of suggested usernames
join_sql = MergeRequest.sanitize_sql_array(
[
'JOIN UNNEST(ARRAY[?]::varchar[]) WITH ORDINALITY AS t(username, ord) USING(username)',
usernames
]
)
project.authorized_users.active
.joins(Arel.sql(join_sql))
.order('t.ord')
end
# This is the same as latest_merge_request_diff unless:

View File

@ -339,6 +339,7 @@ class User < ApplicationRecord
:setup_for_company, :setup_for_company=,
:render_whitespace_in_code, :render_whitespace_in_code=,
:markdown_surround_selection, :markdown_surround_selection=,
:markdown_automatic_lists, :markdown_automatic_lists=,
:diffs_deletion_color, :diffs_deletion_color=,
:diffs_addition_color, :diffs_addition_color=,
to: :user_preference

View File

@ -29,7 +29,6 @@ class UserPreference < ApplicationRecord
default_value_for :time_display_relative, value: true, allows_nil: false
default_value_for :time_format_in_24h, value: false, allows_nil: false
default_value_for :render_whitespace_in_code, value: false, allows_nil: false
default_value_for :markdown_surround_selection, value: true, allows_nil: false
class << self
def notes_filters

View File

@ -104,6 +104,10 @@
= f.gitlab_ui_checkbox_component :markdown_surround_selection,
s_('Preferences|Surround text selection when typing quotes or brackets'),
help_text: sprintf(s_( "Preferences|When you type in a description or comment box, selected text is surrounded by the corresponding character after typing one of the following characters: %{supported_characters}."), { supported_characters: supported_characters }).html_safe
.form-group
= f.gitlab_ui_checkbox_component :markdown_automatic_lists,
s_('Preferences|Automatically add new list items'),
help_text: html_escape(s_('Preferences|When you type in a description or comment box, pressing %{kbdOpen}Enter%{kbdClose} in a list adds a new item below.')) % { kbdOpen: '<kbd>'.html_safe, kbdClose: '</kbd>'.html_safe }
.form-group
= f.label :tab_width, s_('Preferences|Tab width'), class: 'label-bold'

View File

@ -0,0 +1,13 @@
# frozen_string_literal: true
class AddUserPreferenceToTurnOffAutomaticLists < Gitlab::Database::Migration[2.0]
enable_lock_retries!
def up
add_column :user_preferences, :markdown_automatic_lists, :boolean, default: true, null: false
end
def down
remove_column :user_preferences, :markdown_automatic_lists, :boolean
end
end

View File

@ -0,0 +1 @@
364a2f729196e4bd4bde635f7550df3cf0c005fa002840fa12745d8919a99147

View File

@ -22205,6 +22205,7 @@ CREATE TABLE user_preferences (
markdown_surround_selection boolean DEFAULT true NOT NULL,
diffs_deletion_color text,
diffs_addition_color text,
markdown_automatic_lists boolean DEFAULT true NOT NULL,
CONSTRAINT check_89bf269f41 CHECK ((char_length(diffs_deletion_color) <= 7)),
CONSTRAINT check_d07ccd35f7 CHECK ((char_length(diffs_addition_color) <= 7))
);

View File

@ -313,7 +313,7 @@ the nested architecture of container execution, the registry prefix must
be specifically configured to be passed down into CodeClimate's subsequent
`docker pull` commands for individual engines.
The following two variables can address all of the required image pulls:
The following variables can address all of the required image pulls:
- `CODE_QUALITY_IMAGE`: A fully prefixed image name that can be located anywhere
accessible from your job environment. GitLab Container Registry can be used here
@ -322,6 +322,8 @@ The following two variables can address all of the required image pulls:
is a configuration option supported by [CodeClimate CLI](https://github.com/codeclimate/codeclimate/pull/948). You must:
- Include a trailing slash (`/`).
- Not include a protocol prefix, such as `https://`.
- `CODECLIMATE_REGISTRY_USERNAME`: An optional variable to specify the username for the registry domain parsed from `CODECLIMATE_PREFIX`.
- `CODECLIMATE_REGISTRY_PASSWORD`: An optional variable to specify the password for the registry domain parsed from `CODECLIMATE_PREFIX`.
```yaml
include:
@ -333,13 +335,49 @@ code_quality:
CODECLIMATE_PREFIX: "my-private-registry.local:12345/"
```
The images in the private container image registry must be available without authentication.
Follow [this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/355814) for more information.
This example is specific to GitLab Code Quality. For more general
instructions on how to configure DinD with a registry mirror, see the
relevant [documentation](../docker/using_docker_build.md#enable-registry-mirror-for-dockerdind-service).
#### Configure Code Quality to use the Dependency Proxy
Prerequisite:
- The project must be in a group where the [Dependency Proxy](../../user/packages/dependency_proxy/index.md) is enabled.
Here is an example of how to configure Code Quality to use the Dependency Proxy:
```yaml
include:
- template: Jobs/Code-Quality.gitlab-ci.yml
code_quality:
variables:
CODE_QUALITY_IMAGE: "$CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/codequality:0.85.24"
## You must add a trailing slash to `$CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX`.
CODECLIMATE_PREFIX: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/
CODECLIMATE_REGISTRY_USERNAME: $CI_DEPENDENCY_PROXY_USER
CODECLIMATE_REGISTRY_PASSWORD: $CI_DEPENDENCY_PROXY_PASSWORD
```
#### Configure Code Quality to use Dockerhub with authentication
Here is an example of how to configure Code Quality to use Dockerhub with authentication:
```yaml
include:
- template: Jobs/Code-Quality.gitlab-ci.yml
code_quality:
variables:
CODECLIMATE_PREFIX: "registry-1.docker.io/"
CODECLIMATE_REGISTRY_USERNAME: $DOCKERHUB_USERNAME
CODECLIMATE_REGISTRY_PASSWORD: $DOCKERHUB_PASSWORD
```
You should add the username and password as [protected CI/CD variables](../variables/index.md#add-a-cicd-variable-to-a-project)
in the project.
## Configuring jobs using variables
The Code Quality job supports environment variables that users can set to

View File

@ -26,6 +26,11 @@ code_quality:
echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME "
done
}
- |
if [ -n "$CODECLIMATE_REGISTRY_USERNAME" ] && [ -n "$CODECLIMATE_REGISTRY_PASSWORD" ] && [ -n "$CODECLIMATE_PREFIX" ]; then
CODECLIMATE_REGISTRY=${CODECLIMATE_PREFIX%%/*}
docker login "$CODECLIMATE_REGISTRY" --username "$CODECLIMATE_REGISTRY_USERNAME" --password "$CODECLIMATE_REGISTRY_PASSWORD"
fi
- docker pull --quiet "$CODE_QUALITY_IMAGE"
- |
docker run --rm \
@ -38,6 +43,8 @@ code_quality:
REPORT_FORMAT \
ENGINE_MEMORY_LIMIT_BYTES \
CODECLIMATE_PREFIX \
CODECLIMATE_REGISTRY_USERNAME \
CODECLIMATE_REGISTRY_PASSWORD \
) \
--volume "$PWD":/code \
--volume /var/run/docker.sock:/var/run/docker.sock \

View File

@ -15,6 +15,7 @@ module Gitlab
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
gon.markdown_surround_selection = current_user&.markdown_surround_selection
gon.markdown_automatic_lists = current_user&.markdown_automatic_lists
if Gitlab.config.sentry.enabled
gon.sentry_dsn = Gitlab.config.sentry.clientside_dsn

View File

@ -30369,6 +30369,9 @@ msgstr ""
msgid "Preferences saved."
msgstr ""
msgid "Preferences|Automatically add new list items"
msgstr ""
msgid "Preferences|Behavior"
msgstr ""
@ -30480,6 +30483,9 @@ msgstr ""
msgid "Preferences|Use relative times"
msgstr ""
msgid "Preferences|When you type in a description or comment box, pressing %{kbdOpen}Enter%{kbdClose} in a list adds a new item below."
msgstr ""
msgid "Preferences|When you type in a description or comment box, selected text is surrounded by the corresponding character after typing one of the following characters: %{supported_characters}."
msgstr ""

View File

@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe "GitLab Flavored Markdown" do
include CycleAnalyticsHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
@ -24,7 +22,12 @@ RSpec.describe "GitLab Flavored Markdown" do
let(:commit) { project.commit }
before do
create_commit("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details", project, user, 'master')
project.repository.commit_files(
user,
branch_name: 'master',
message: "fix #{issue.to_reference}\n\nask #{fred.to_reference} for details",
actions: [{ action: :create, file_path: 'a/new.file', content: 'This is a file' }]
)
end
it "renders title in commits#index" do

View File

@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe 'User searches for commits', :js do
include CycleAnalyticsHelpers
let(:project) { create(:project, :repository) }
let(:sha) { '6d394385cf567f80a8fd85055db1ab4c5295806f' }
let(:user) { create(:user) }
@ -34,7 +32,12 @@ RSpec.describe 'User searches for commits', :js do
context 'when searching by message' do
it 'finds a commit and holds on /search page' do
create_commit('Message referencing another sha: "deadbeef"', project, user, 'master')
project.repository.commit_files(
user,
message: 'Message referencing another sha: "deadbeef"',
branch_name: 'master',
actions: [{ action: :create, file_path: 'a/new.file', contents: 'new file' }]
)
submit_search('deadbeef')

View File

@ -198,6 +198,7 @@ describe('init markdown', () => {
textArea.addEventListener('keydown', keypressNoteText);
textArea.addEventListener('compositionstart', compositionStartNoteText);
textArea.addEventListener('compositionend', compositionEndNoteText);
gon.markdown_automatic_lists = true;
});
it.each`
@ -317,6 +318,18 @@ describe('init markdown', () => {
expect(textArea.value).toEqual(expected);
expect(textArea.selectionStart).toBe(expected.length);
});
it('does nothing if user preference disabled', () => {
const text = '- test';
gon.markdown_automatic_lists = false;
textArea.value = text;
textArea.setSelectionRange(text.length, text.length);
textArea.dispatchEvent(enterEvent);
expect(textArea.value).toEqual(text);
});
});
});

View File

@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe Ci::PipelineEditorHelper do
include CycleAnalyticsHelpers
let_it_be(:project) { create(:project) }
describe 'can_view_pipeline_editor?' do
@ -125,7 +123,12 @@ RSpec.describe Ci::PipelineEditorHelper do
let(:user) { create(:user) }
before do
create_commit('Message', project, user, 'feature')
project.repository.commit_files(
user,
branch_name: 'feature',
message: 'Message',
actions: [{ action: :create, file_path: 'a/new.file', content: 'This is a new file' }]
)
controller.params[:branch_name] = 'feature'
end

View File

@ -5417,21 +5417,21 @@ RSpec.describe MergeRequest, factory_default: :keep do
subject(:suggested_reviewer_users) { merge_request.suggested_reviewer_users }
shared_examples 'blank suggestions' do
it 'returns blank' do
expect(suggested_reviewer_users).to eq([])
it 'returns an empty relation' do
expect(suggested_reviewer_users).to be_empty
end
end
context 'predictions is nil' do
context 'when predictions is nil' do
it_behaves_like 'blank suggestions'
end
context 'predictions is not nil' do
context 'when predictions is not nil' do
before do
merge_request.build_predictions
end
context 'a non hash' do
context 'when predictions is a non hash' do
before do
merge_request.build_predictions
merge_request.predictions.suggested_reviewers = 1
@ -5440,7 +5440,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
it_behaves_like 'blank suggestions'
end
context 'an empty hash' do
context 'when predictions is an empty hash' do
before do
merge_request.predictions.suggested_reviewers = {}
end
@ -5448,7 +5448,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
it_behaves_like 'blank suggestions'
end
context 'suggests a user which is not a member' do
context 'when suggests a user who is not a member' do
let_it_be(:non_member) { create(:user) }
before do
@ -5458,25 +5458,37 @@ RSpec.describe MergeRequest, factory_default: :keep do
it_behaves_like 'blank suggestions'
end
context 'suggests a user which is a non member' do
let_it_be(:member) { create(:user) }
context 'when suggests users who are members' do
let_it_be(:first_member) { create(:user) }
let_it_be(:second_member) { create(:user) }
before_all do
project.add_developer(first_member)
project.add_developer(second_member)
end
before do
project.add_developer(member)
merge_request.predictions.suggested_reviewers = { 'reviewers' => [member.username] }
merge_request.predictions.suggested_reviewers = {
'reviewers' => [
second_member.username,
first_member.username
]
}
end
context 'user is nonactive' do
context 'when a user is inactive' do
before do
member.deactivate
second_member.deactivate
end
it_behaves_like 'blank suggestions'
it 'returns only active users' do
expect(suggested_reviewer_users).to eq([first_member])
end
end
context 'user is active' do
it 'returns the user' do
expect(suggested_reviewer_users).to eq([member])
context 'when all users are active' do
it 'returns users in correct suggested order' do
expect(suggested_reviewer_users).to eq([second_member, first_member])
end
end
end

View File

@ -69,6 +69,9 @@ RSpec.describe User do
it { is_expected.to delegate_method(:markdown_surround_selection).to(:user_preference) }
it { is_expected.to delegate_method(:markdown_surround_selection=).to(:user_preference).with_arguments(:args) }
it { is_expected.to delegate_method(:markdown_automatic_lists).to(:user_preference) }
it { is_expected.to delegate_method(:markdown_automatic_lists=).to(:user_preference).with_arguments(:args) }
it { is_expected.to delegate_method(:diffs_deletion_color).to(:user_preference) }
it { is_expected.to delegate_method(:diffs_deletion_color=).to(:user_preference).with_arguments(:args) }