Skip to content

Commit 179b33c

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent bbc0606 commit 179b33c

39 files changed

+460
-244
lines changed

.gitlab/ci/frontend.gitlab-ci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,13 @@ bundle-size-review:
335335
stage: test
336336
needs: ["compile-production-assets"]
337337
script:
338+
- source scripts/utils.sh
338339
- mkdir -p bundle-size-review
339340
- cp webpack-report/index.html bundle-size-review/bundle-report.html
340341
- yarn global add https://gitlab.com/gitlab-org/frontend/playground/webpack-memory-metrics.git
341-
- danger --dangerfile=danger/bundle_size/Dangerfile --fail-on-errors=true --verbose --danger_id=bundle-size-review
342+
- |
343+
danger_id=$(echo -n ${DANGER_GITLAB_API_TOKEN} | md5sum | awk '{print $1}' | cut -c5-10)
344+
run_timed_command "danger --dangerfile=danger/Dangerfile-bundle_size --fail-on-errors=true --verbose --danger_id=bundle-size-review-${danger_id}"
342345
artifacts:
343346
when: always
344347
name: bundle-size-review

Dangerfile

+3-11
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,8 @@ project_name = ee? ? 'gitlab' : 'gitlab-foss'
1111

1212
Gitlab::Dangerfiles.for_project(self, project_name) do |gitlab_dangerfiles|
1313
gitlab_dangerfiles.import_plugins
14+
gitlab_dangerfiles.config.ci_only_rules = ProjectHelper::CI_ONLY_RULES
15+
gitlab_dangerfiles.config.files_to_category = ProjectHelper::CATEGORIES
1416

15-
unless helper.release_automation?
16-
danger.import_plugin('danger/plugins/*.rb')
17-
gitlab_dangerfiles.import_dangerfiles(except: %w[simple_roulette])
18-
gitlab_dangerfiles.config.files_to_category = ProjectHelper::CATEGORIES
19-
end
20-
end
21-
22-
return if helper.release_automation?
23-
24-
project_helper.rule_names.each do |rule|
25-
danger.import_dangerfile(path: File.join('danger', rule))
17+
gitlab_dangerfiles.import_dangerfiles(except: %w[simple_roulette])
2618
end

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ group :development, :test do
403403
end
404404

405405
group :development, :test, :danger do
406-
gem 'gitlab-dangerfiles', '~> 2.11.0', require: false
406+
gem 'gitlab-dangerfiles', '~> 3.0', require: false
407407
end
408408

409409
group :development, :test, :coverage do

Gemfile.lock

+4-3
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ GEM
224224
css_parser (1.7.0)
225225
addressable
226226
daemons (1.3.1)
227-
danger (8.4.5)
227+
danger (8.5.0)
228228
claide (~> 1.0)
229229
claide-plugins (>= 0.9.2)
230230
colored2 (~> 3.1)
@@ -463,9 +463,10 @@ GEM
463463
terminal-table (~> 1.5, >= 1.5.1)
464464
gitlab-chronic (0.10.5)
465465
numerizer (~> 0.2)
466-
gitlab-dangerfiles (2.11.0)
466+
gitlab-dangerfiles (3.0.0)
467467
danger (>= 8.4.5)
468468
danger-gitlab (>= 8.0.0)
469+
rake
469470
gitlab-experiment (0.7.0)
470471
activesupport (>= 3.0)
471472
request_store (>= 1.0)
@@ -1494,7 +1495,7 @@ DEPENDENCIES
14941495
gitaly (~> 14.9.0.pre.rc4)
14951496
github-markup (~> 1.7.0)
14961497
gitlab-chronic (~> 0.10.5)
1497-
gitlab-dangerfiles (~> 2.11.0)
1498+
gitlab-dangerfiles (~> 3.0)
14981499
gitlab-experiment (~> 0.7.0)
14991500
gitlab-fog-azure-rm (~> 1.2.0)
15001501
gitlab-labkit (~> 0.22.0)

Rakefile

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ require File.expand_path('config/initializers/01_active_record_database_tasks_co
1616
Gitlab::Application.load_tasks
1717

1818
Knapsack.load_tasks if defined?(Knapsack)
19+
20+
require 'gitlab-dangerfiles'
21+
Gitlab::Dangerfiles.load_tasks

app/controllers/oauth/authorizations_controller.rb

-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ def pre_auth_params
3737

3838
# limit scopes when signing in with GitLab
3939
def downgrade_scopes!
40-
return unless Feature.enabled?(:omniauth_login_minimal_scopes, current_user,
41-
default_enabled: :yaml)
42-
4340
auth_type = params.delete('gl_auth_type')
4441
return unless auth_type == 'login'
4542

app/helpers/webpack_helper.rb

+2-10
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,8 @@ def webpack_entrypoint_paths(source, extension: nil, exclude_duplicates: true)
8383
end
8484

8585
def webpack_public_host
86-
# We do not proxy the webpack output in the 'test' environment,
87-
# so we must reference the webpack dev server directly.
88-
if Rails.env.test? && Gitlab.config.webpack.dev_server.enabled
89-
host = Gitlab.config.webpack.dev_server.host
90-
port = Gitlab.config.webpack.dev_server.port
91-
protocol = Gitlab.config.webpack.dev_server.https ? 'https' : 'http'
92-
"#{protocol}://#{host}:#{port}"
93-
else
94-
ActionController::Base.asset_host.try(:chomp, '/')
95-
end
86+
# We proxy webpack output in 'test' and 'dev' environment, so we can just use asset_host
87+
ActionController::Base.asset_host.try(:chomp, '/')
9688
end
9789

9890
def webpack_public_path

app/models/suggestion.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ def diff_file
1616
note.latest_diff_file
1717
end
1818

19-
def project
19+
def source_project
2020
noteable.source_project
2121
end
2222

23+
def target_project
24+
noteable.target_project
25+
end
26+
2327
def branch
2428
noteable.source_branch
2529
end

app/policies/suggestion_policy.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# frozen_string_literal: true
22

33
class SuggestionPolicy < BasePolicy
4-
delegate { @subject.project }
4+
delegate { @subject.source_project }
55

66
condition(:can_push_to_branch) do
7-
Gitlab::UserAccess.new(@user, container: @subject.project).can_push_to_branch?(@subject.branch)
7+
Gitlab::UserAccess.new(@user, container: @subject.source_project).can_push_to_branch?(@subject.branch)
88
end
99

1010
rule { can_push_to_branch }.enable :apply_suggestion

app/services/suggestions/apply_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def multi_service
5454
author_email: author&.email
5555
}
5656

57-
::Files::MultiService.new(suggestion_set.project, current_user, params)
57+
::Files::MultiService.new(suggestion_set.source_project, current_user, params)
5858
end
5959

6060
def commit_message

config/feature_flags/development/omniauth_login_minimal_scopes.yml

-8
This file was deleted.

config/initializers/static_files.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
# If webpack-dev-server is configured, proxy webpack's public directory
2323
# instead of looking for static assets
24-
if Gitlab.config.webpack.dev_server.enabled && Rails.env.development?
24+
if Gitlab.config.webpack.dev_server.enabled && Gitlab.dev_or_test_env?
2525
app.config.middleware.insert_before(
2626
Gitlab::Middleware::Static,
2727
Gitlab::Webpack::DevServerMiddleware,

danger/bundle_size/Dangerfile danger/Dangerfile-bundle_size

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
# This file isn't named "Dangerfile" so that it's not imported by default since it's only meant to be run in the `bundle-size-review` job.
23

34
analysis_result = "./bundle-size-review/analysis.json"
45
markdown_result = "./bundle-size-review/comparison.md"

danger/ci_templates/Dangerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ return unless helper.ci?
1919

2020
template_paths_to_review = helper.changes_by_category[:ci_template]
2121

22-
if gitlab.mr_labels.include?('ci::templates') || template_paths_to_review.any?
22+
if helper.mr_labels.include?('ci::templates') || template_paths_to_review.any?
2323
message 'This merge request adds or changes files that require a ' \
2424
'review from the CI/CD Templates maintainers.'
2525

danger/database/Dangerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ if geo_migration_created && !geo_db_schema_updated
4949
end
5050

5151
return unless helper.ci?
52-
return if gitlab.mr_labels.include?(DATABASE_APPROVED_LABEL)
52+
return if helper.mr_labels.include?(DATABASE_APPROVED_LABEL)
5353

5454
db_paths_to_review = helper.changes_by_category[:database]
5555

56-
if gitlab.mr_labels.include?('database') || db_paths_to_review.any?
56+
if helper.mr_labels.include?('database') || db_paths_to_review.any?
5757
message 'This merge request adds or changes files that require a ' \
5858
'review from the [Database team](https://gitlab.com/groups/gl-database/-/group_members).'
5959

danger/feature_flag/Dangerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ def check_feature_flag_yaml(feature_flag)
2222
end
2323
rescue Psych::Exception
2424
# YAML could not be parsed, fail the build.
25-
fail "#{gitlab.html_link(feature_flag.path)} isn't valid YAML! #{SEE_DOC}"
25+
fail "#{helper.html_link(feature_flag.path)} isn't valid YAML! #{SEE_DOC}"
2626
rescue StandardError => e
2727
warn "There was a problem trying to check the Feature Flag file. Exception: #{e.class.name} - #{e.message}"
2828
end
2929

3030
def message_for_feature_flag_missing_group!(feature_flag:, mr_group_label:)
3131
if mr_group_label.nil?
32-
warn "Consider setting `group` in #{gitlab.html_link(feature_flag.path)}. #{SEE_DOC}"
32+
warn "Consider setting `group` in #{helper.html_link(feature_flag.path)}. #{SEE_DOC}"
3333
else
3434
mr_line = feature_flag.raw.lines.find_index("group:\n")
3535

3636
if mr_line
3737
markdown(format(SUGGEST_MR_COMMENT, group: mr_group_label), file: feature_flag.path, line: mr_line.succ)
3838
else
39-
warn %(Consider setting `group: "#{mr_group_label}"` in #{gitlab.html_link(feature_flag.path)}. #{SEE_DOC})
39+
warn %(Consider setting `group: "#{mr_group_label}"` in #{helper.html_link(feature_flag.path)}. #{SEE_DOC})
4040
end
4141
end
4242
end
@@ -60,7 +60,7 @@ def message_for_feature_flag_with_group!(feature_flag:, mr_group_label:)
6060
if mr_group_label.nil?
6161
helper.labels_to_add << feature_flag.group
6262
else
63-
fail %(`group` is set to ~"#{feature_flag.group}" in #{gitlab.html_link(feature_flag.path)}, which does not match ~"#{mr_group_label}" set on the MR!)
63+
fail %(`group` is set to ~"#{feature_flag.group}" in #{helper.html_link(feature_flag.path)}, which does not match ~"#{mr_group_label}" set on the MR!)
6464
end
6565
end
6666

danger/specialization_labels/Dangerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ SPECIALIZATIONS = {
1616
labels_to_add = helper.changes_by_category.each_with_object([]) do |(category, _changes), memo|
1717
label = SPECIALIZATIONS[category]
1818
next unless label
19-
next if gitlab.mr_labels.include?(label)
19+
next if helper.mr_labels.include?(label)
2020

2121
# Don't override already-set scoped labels.
2222
label_scope = label.split('::')[0...-1].join('::')
23-
next if !label_scope.empty? && gitlab.mr_labels.any? { |mr_label| mr_label.start_with?(label_scope) }
23+
next if !label_scope.empty? && helper.has_scoped_label_with_scope?(label_scope)
2424

2525
memo << label
2626
end

danger/specs/Dangerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ has_ee_app_changes = all_changed_files.grep(%r{\Aee/(app|lib|db/(geo/)?(post_)?m
3737
spec_changes = specs.changed_specs_files(ee: :exclude)
3838
has_spec_changes = spec_changes.any?
3939
has_ee_spec_changes = specs.changed_specs_files(ee: :only).any?
40-
new_specs_needed = (gitlab.mr_labels & NO_SPECS_LABELS).empty?
40+
new_specs_needed = (helper.mr_labels & NO_SPECS_LABELS).empty?
4141

4242
if (has_app_changes || has_ee_app_changes) && !(has_spec_changes || has_ee_spec_changes) && new_specs_needed
4343
warn format(NO_NEW_SPEC_MESSAGE, labels: helper.labels_list(NO_SPECS_LABELS)), sticky: false

danger/z_metadata/Dangerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ end
1414

1515
has_milestone = !gitlab.mr_json["milestone"].nil?
1616

17-
unless has_milestone || (helper.security_mr? && gitlab.branch_for_base == DEFAULT_BRANCH)
17+
unless has_milestone || (helper.security_mr? && helper.mr_target_branch == DEFAULT_BRANCH)
1818
warn "This merge request does not refer to an existing milestone.", sticky: false
1919
end
2020

21-
has_pick_into_stable_label = gitlab.mr_labels.find { |label| label.start_with?('Pick into') }
21+
has_pick_into_stable_label = helper.mr_labels.find { |label| label.start_with?('Pick into') }
2222

23-
if gitlab.branch_for_base != DEFAULT_BRANCH && !has_pick_into_stable_label && !helper.security_mr?
23+
if helper.mr_target_branch != DEFAULT_BRANCH && !has_pick_into_stable_label && !helper.security_mr?
2424
warn "Most of the time, merge requests should target `#{DEFAULT_BRANCH}`. Otherwise, please set the relevant `Pick into X.Y` label."
2525
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
class AddTmpIndexToSupportLeakyRegexCleanup < Gitlab::Database::Migration[1.0]
4+
INDEX_NAME = "tmp_index_merge_requests_draft_and_status_leaky_regex"
5+
LEAKY_REGEXP_STR = "^\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP"
6+
CORRECTED_REGEXP_STR = "^(\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP)"
7+
8+
disable_ddl_transaction!
9+
10+
def up
11+
add_concurrent_index :merge_requests, :id,
12+
where: "draft = true AND state_id = 1 AND ((title)::text ~* '#{LEAKY_REGEXP_STR}'::text) AND ((title)::text !~* '#{CORRECTED_REGEXP_STR}'::text)",
13+
name: INDEX_NAME
14+
end
15+
16+
def down
17+
remove_concurrent_index_by_name :merge_requests, INDEX_NAME
18+
end
19+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# frozen_string_literal: true
2+
3+
class CleanupDraftDataFromFaultyRegex < Gitlab::Database::Migration[1.0]
4+
MIGRATION = 'CleanupDraftDataFromFaultyRegex'
5+
DELAY_INTERVAL = 5.minutes
6+
BATCH_SIZE = 20
7+
8+
disable_ddl_transaction!
9+
10+
class MergeRequest < ActiveRecord::Base
11+
LEAKY_REGEXP_STR = "^\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP"
12+
CORRECTED_REGEXP_STR = "^(\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP)"
13+
14+
self.table_name = 'merge_requests'
15+
16+
include ::EachBatch
17+
18+
def self.eligible
19+
where(state_id: 1)
20+
.where(draft: true)
21+
.where("title ~* ?", LEAKY_REGEXP_STR)
22+
.where("title !~* ?", CORRECTED_REGEXP_STR)
23+
end
24+
end
25+
26+
def up
27+
return unless Gitlab.com?
28+
29+
queue_background_migration_jobs_by_range_at_intervals(
30+
MergeRequest.eligible,
31+
MIGRATION,
32+
DELAY_INTERVAL,
33+
batch_size: BATCH_SIZE,
34+
track_jobs: true
35+
)
36+
end
37+
38+
def down
39+
# noop
40+
#
41+
end
42+
end

db/schema_migrations/20220315171027

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4c329622299c76ca753381f1ccc0686714d07eeee8acfc834e576d5a5addaafc

db/schema_migrations/20220315171129

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7ca832e710026c0721ecdcd50b477073aeaf7cb795c50acd604897f85707b163

db/structure.sql

+2
Original file line numberDiff line numberDiff line change
@@ -29617,6 +29617,8 @@ CREATE INDEX tmp_index_issues_on_issue_type_and_id ON issues USING btree (issue_
2961729617

2961829618
CREATE INDEX tmp_index_members_on_state ON members USING btree (state) WHERE (state = 2);
2961929619

29620+
CREATE INDEX tmp_index_merge_requests_draft_and_status_leaky_regex ON merge_requests USING btree (id) WHERE ((draft = true) AND (state_id = 1) AND ((title)::text ~* '^\[draft\]|\(draft\)|draft:|draft|\[WIP\]|WIP:|WIP'::text) AND ((title)::text !~* '^(\[draft\]|\(draft\)|draft:|draft|\[WIP\]|WIP:|WIP)'::text));
29621+
2962029622
CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_child_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NOT NULL) AND (traversal_ids = '{}'::integer[]));
2962129623

2962229624
CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_root_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NULL) AND (traversal_ids = '{}'::integer[]));

doc/api/graphql/reference/index.md

+4
Original file line numberDiff line numberDiff line change
@@ -3236,6 +3236,10 @@ Input type: `iterationCreateInput`
32363236

32373237
### `Mutation.iterationDelete`
32383238

3239+
WARNING:
3240+
**Deprecated** in 14.10.
3241+
Manual iteration management is deprecated. Only automatic iteration cadences will be supported in the future.
3242+
32393243
Input type: `IterationDeleteInput`
32403244

32413245
#### Arguments

0 commit comments

Comments
 (0)