Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-01-26 00:08:57 +00:00
parent fba5aaeec6
commit 76215aab04
20 changed files with 202 additions and 65 deletions

View file

@ -94,7 +94,7 @@ export default {
data-qa-selector="detailed_metric_content"
>
<gl-button v-gl-modal="modalId" class="gl-mr-2" type="button" variant="link">
<span class="gl-text-blue-300">{{ metricDetailsLabel }}</span>
<span class="gl-text-blue-300 gl-font-weight-bold">{{ metricDetailsLabel }}</span>
</gl-button>
<gl-modal :modal-id="modalId" :title="header" size="lg" footer-class="d-none" scrollable>
<table class="table">

View file

@ -99,7 +99,7 @@ create a JSON response according to your needs.
```ruby
class PipelineSerializer < BaseSerializer
entity PipelineEntity
entity Ci::PipelineEntity
def represent_details(resource)
represent(resource, only: [:details])

View file

@ -9,7 +9,7 @@ class BuildDetailsEntity < JobEntity
expose :user, using: UserEntity
expose :runner, using: RunnerEntity
expose :metadata, using: BuildMetadataEntity
expose :pipeline, using: PipelineEntity
expose :pipeline, using: Ci::PipelineEntity
expose :deployment_status, if: -> (*) { build.starts_environment? } do
expose :deployment_status, as: :status

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class PipelineEntity < Grape::Entity
class Ci::PipelineEntity < Grape::Entity
include RequestAwareEntity
include Gitlab::Utils::StrongMemoize

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class PipelineDetailsEntity < PipelineEntity
class PipelineDetailsEntity < Ci::PipelineEntity
expose :project, using: ProjectEntity
expose :flags do

View file

@ -6,7 +6,7 @@
%button.btn.js-settings-toggle
= expanded ? _('Collapse') : _('Expand')
%p
= _("Clean up after running %{filter_repo} on the repository" % { filter_repo: link_to_filter_repo }).html_safe
= _("Clean up after running %{filter_repo} on the repository." % { filter_repo: link_to_filter_repo }).html_safe
= link_to sprite_icon('question-o'),
help_page_path('user/project/repository/reducing_the_repo_size_using_git.md'),
target: '_blank', rel: 'noopener noreferrer'
@ -24,6 +24,6 @@
= _("No file selected")
= f.file_field :bfg_object_map, class: "hidden js-object-map-input", required: true
.form-text.text-muted
= _("The maximum file size allowed is %{size}.") % { size: number_to_human_size(Gitlab::CurrentSettings.max_attachment_size.megabytes) }
= _("The maximum file size is %{size}.") % { size: number_to_human_size(Gitlab::CurrentSettings.max_attachment_size.megabytes) }
= f.submit _('Start cleanup'), class: 'gl-button btn btn-success'

View file

@ -0,0 +1,5 @@
---
title: Fix missing setting LDAP servers
merge_request: 52512
author:
type: fixed

View file

@ -0,0 +1,5 @@
---
title: Bold metricDetailsLabel in the performance bar
merge_request: 52417
author: Yogi (@yo)
type: other

View file

@ -12,6 +12,7 @@ Settings.encrypted_settings['path'] = Settings.absolute(Settings.encrypted_setti
Settings['ldap'] ||= Settingslogic.new({})
Settings.ldap['enabled'] = false if Settings.ldap['enabled'].nil?
Settings.ldap['servers'] ||= Settingslogic.new({})
Settings.ldap['prevent_ldap_sign_in'] = false if Settings.ldap['prevent_ldap_sign_in'].blank?
Settings.ldap['secret_file'] = Settings.absolute(Settings.ldap['secret_file'] || File.join(Settings.encrypted_settings['path'], "ldap.yaml.enc"))

View file

@ -7,30 +7,17 @@ module Gitlab
include ::Gitlab::Utils::StrongMemoize
Result = Struct.new(:when, :start_in, :allow_failure, :variables) do
def build_attributes(seed_attributes = {})
def build_attributes
{
when: self.when,
options: { start_in: start_in }.compact,
allow_failure: allow_failure,
yaml_variables: yaml_variables(seed_attributes[:yaml_variables])
allow_failure: allow_failure
}.compact
end
def pass?
self.when != 'never'
end
private
def yaml_variables(seed_variables)
return unless variables && seed_variables
indexed_seed_variables = seed_variables.deep_dup.index_by { |var| var[:key] }
variables.each_with_object(indexed_seed_variables) do |var, hash|
hash[var[0].to_s] = { key: var[0].to_s, value: var[1], public: true }
end.values
end
end
def initialize(rule_hashes, default_when:)

View file

@ -159,7 +159,11 @@ module Gitlab
next {} unless @using_rules
if ::Gitlab::Ci::Features.rules_variables_enabled?(@pipeline.project)
rules_result.build_attributes(@seed_attributes)
rules_variables_result = ::Gitlab::Ci::Variables::Helpers.merge_variables(
@seed_attributes[:yaml_variables], rules_result.variables
)
rules_result.build_attributes.merge(yaml_variables: rules_variables_result)
else
rules_result.build_attributes
end

View file

@ -0,0 +1,32 @@
# frozen_string_literal: true
module Gitlab
module Ci
module Variables
module Helpers
class << self
def merge_variables(current_vars, new_vars)
current_vars = transform_from_yaml_variables(current_vars)
new_vars = transform_from_yaml_variables(new_vars)
transform_to_yaml_variables(
current_vars.merge(new_vars)
)
end
def transform_to_yaml_variables(vars)
vars.to_h.map do |key, value|
{ key: key.to_s, value: value, public: true }
end
end
def transform_from_yaml_variables(vars)
return vars.stringify_keys if vars.is_a?(Hash)
vars.to_a.map { |var| [var[:key].to_s, var[:value]] }.to_h
end
end
end
end
end
end

View file

@ -123,9 +123,7 @@ module Gitlab
end
def transform_to_yaml_variables(variables)
variables.to_h.map do |key, value|
{ key: key.to_s, value: value, public: true }
end
::Gitlab::Ci::Variables::Helpers.transform_to_yaml_variables(variables)
end
end
end

View file

@ -3,6 +3,10 @@
module Gitlab
module Diff
class FileCollectionSorter
B_FOLLOWS_A = 1
A_FOLLOWS_B = -1
EQUIVALENT = 0
attr_reader :diffs
def initialize(diffs)
@ -29,14 +33,16 @@ module Gitlab
a_part = a_parts.shift
b_part = b_parts.shift
return 1 if a_parts.size < b_parts.size && a_parts.empty?
return -1 if a_parts.size > b_parts.size && b_parts.empty?
return B_FOLLOWS_A if a_parts.size < b_parts.size && a_parts.empty?
return A_FOLLOWS_B if a_parts.size > b_parts.size && b_parts.empty?
comparison = a_part <=> b_part
return comparison unless comparison == 0
return comparison unless comparison == EQUIVALENT
return compare_path_parts(a_parts, b_parts) if a_parts.any? && b_parts.any?
compare_path_parts(a_parts, b_parts)
# If A and B have the same name (e.g. symlink change), they are identical so return 0
EQUIVALENT
end
end
end

View file

@ -4457,6 +4457,12 @@ msgstr ""
msgid "BillingPlans|Congratulations, your free trial is activated."
msgstr ""
msgid "BillingPlans|Current Plan"
msgstr ""
msgid "BillingPlans|Free upgrade!"
msgstr ""
msgid "BillingPlans|If you would like to downgrade your plan please contact %{support_link_start}Customer Support%{support_link_end}."
msgstr ""
@ -4490,6 +4496,9 @@ msgstr ""
msgid "BillingPlans|billed annually at %{price_per_year}"
msgstr ""
msgid "BillingPlans|for the remainder of your subscription"
msgstr ""
msgid "BillingPlans|frequently asked questions"
msgstr ""
@ -4505,6 +4514,9 @@ msgstr ""
msgid "BillingPlan|Upgrade"
msgstr ""
msgid "BillingPlan|Upgrade for free"
msgstr ""
msgid "Billing|An email address is only visible for users with public emails."
msgstr ""
@ -8510,9 +8522,6 @@ msgstr ""
msgid "Current Branch"
msgstr ""
msgid "Current Plan"
msgstr ""
msgid "Current Project"
msgstr ""
@ -28304,6 +28313,9 @@ msgstr ""
msgid "The maximum file size allowed is %{size}."
msgstr ""
msgid "The maximum file size is %{size}."
msgstr ""
msgid "The merge conflicts for this merge request cannot be resolved through GitLab. Please try to resolve them locally."
msgstr ""
@ -30635,6 +30647,9 @@ msgstr ""
msgid "Updating"
msgstr ""
msgid "Upgrade offers available!"
msgstr ""
msgid "Upgrade your plan"
msgstr ""

View file

@ -201,40 +201,13 @@ RSpec.describe Gitlab::Ci::Build::Rules do
end
describe '#build_attributes' do
let(:seed_attributes) { {} }
subject(:build_attributes) do
result.build_attributes(seed_attributes)
result.build_attributes
end
it 'compacts nil values' do
is_expected.to eq(options: {}, when: 'on_success')
end
context 'when there are variables in rules' do
let(:variables) { { VAR1: 'new var 1', VAR3: 'var 3' } }
context 'when there are seed variables' do
let(:seed_attributes) do
{ yaml_variables: [{ key: 'VAR1', value: 'var 1', public: true },
{ key: 'VAR2', value: 'var 2', public: true }] }
end
it 'returns yaml_variables with override' do
is_expected.to include(
yaml_variables: [{ key: 'VAR1', value: 'new var 1', public: true },
{ key: 'VAR2', value: 'var 2', public: true },
{ key: 'VAR3', value: 'var 3', public: true }]
)
end
end
context 'when there is not seed variables' do
it 'does not return yaml_variables' do
is_expected.not_to have_key(:yaml_variables)
end
end
end
end
describe '#pass?' do

View file

@ -0,0 +1,103 @@
# frozen_string_literal: true
require 'fast_spec_helper'
RSpec.describe Gitlab::Ci::Variables::Helpers do
describe '.merge_variables' do
let(:current_variables) do
[{ key: 'key1', value: 'value1' },
{ key: 'key2', value: 'value2' }]
end
let(:new_variables) do
[{ key: 'key2', value: 'value22' },
{ key: 'key3', value: 'value3' }]
end
let(:result) do
[{ key: 'key1', value: 'value1', public: true },
{ key: 'key2', value: 'value22', public: true },
{ key: 'key3', value: 'value3', public: true }]
end
subject { described_class.merge_variables(current_variables, new_variables) }
it { is_expected.to eq(result) }
context 'when new variables is a hash' do
let(:new_variables) do
{ 'key2' => 'value22', 'key3' => 'value3' }
end
it { is_expected.to eq(result) }
end
context 'when new variables is a hash with symbol keys' do
let(:new_variables) do
{ key2: 'value22', key3: 'value3' }
end
it { is_expected.to eq(result) }
end
context 'when new variables is nil' do
let(:new_variables) {}
let(:result) do
[{ key: 'key1', value: 'value1', public: true },
{ key: 'key2', value: 'value2', public: true }]
end
it { is_expected.to eq(result) }
end
end
describe '.transform_to_yaml_variables' do
let(:variables) do
{ 'key1' => 'value1', 'key2' => 'value2' }
end
let(:result) do
[{ key: 'key1', value: 'value1', public: true },
{ key: 'key2', value: 'value2', public: true }]
end
subject { described_class.transform_to_yaml_variables(variables) }
it { is_expected.to eq(result) }
context 'when variables is nil' do
let(:variables) {}
it { is_expected.to eq([]) }
end
end
describe '.transform_from_yaml_variables' do
let(:variables) do
[{ key: 'key1', value: 'value1', public: true },
{ key: 'key2', value: 'value2', public: true }]
end
let(:result) do
{ 'key1' => 'value1', 'key2' => 'value2' }
end
subject { described_class.transform_from_yaml_variables(variables) }
it { is_expected.to eq(result) }
context 'when variables is nil' do
let(:variables) {}
it { is_expected.to eq({}) }
end
context 'when variables is a hash' do
let(:variables) do
{ key1: 'value1', 'key2' => 'value2' }
end
it { is_expected.to eq(result) }
end
end
end

View file

@ -5,11 +5,14 @@ require 'spec_helper'
RSpec.describe Gitlab::Diff::FileCollectionSorter do
let(:diffs) do
[
double(new_path: 'README', old_path: 'README'),
double(new_path: '.dir/test', old_path: '.dir/test'),
double(new_path: '', old_path: '.file'),
double(new_path: '1-folder/A-file.ext', old_path: '1-folder/A-file.ext'),
double(new_path: '1-folder/README', old_path: '1-folder/README'),
double(new_path: nil, old_path: '1-folder/M-file.ext'),
double(new_path: '1-folder/Z-file.ext', old_path: '1-folder/Z-file.ext'),
double(new_path: '1-folder/README', old_path: '1-folder/README'),
double(new_path: '', old_path: '1-folder/nested/A-file.ext'),
double(new_path: '1-folder/nested/M-file.ext', old_path: '1-folder/nested/M-file.ext'),
double(new_path: nil, old_path: '1-folder/nested/Z-file.ext'),
@ -19,7 +22,8 @@ RSpec.describe Gitlab::Diff::FileCollectionSorter do
double(new_path: nil, old_path: '2-folder/nested/A-file.ext'),
double(new_path: 'A-file.ext', old_path: 'A-file.ext'),
double(new_path: '', old_path: 'M-file.ext'),
double(new_path: 'Z-file.ext', old_path: 'Z-file.ext')
double(new_path: 'Z-file.ext', old_path: 'Z-file.ext'),
double(new_path: 'README', old_path: 'README')
]
end
@ -36,6 +40,8 @@ RSpec.describe Gitlab::Diff::FileCollectionSorter do
'1-folder/nested/Z-file.ext',
'1-folder/A-file.ext',
'1-folder/M-file.ext',
'1-folder/README',
'1-folder/README',
'1-folder/Z-file.ext',
'2-folder/nested/A-file.ext',
'2-folder/A-file.ext',
@ -44,6 +50,8 @@ RSpec.describe Gitlab::Diff::FileCollectionSorter do
'.file',
'A-file.ext',
'M-file.ext',
'README',
'README',
'Z-file.ext'
])
end

View file

@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe PipelineEntity do
RSpec.describe Ci::PipelineEntity do
include Gitlab::Routing
let_it_be(:project) { create(:project) }

View file

@ -10,8 +10,8 @@ RSpec.describe PipelineDetailsEntity do
described_class.represent(pipeline, request: request)
end
it 'inherrits from PipelineEntity' do
expect(described_class).to be < PipelineEntity
it 'inherits from PipelineEntity' do
expect(described_class).to be < Ci::PipelineEntity
end
before do