2020-09-08 05:08:31 -04:00
|
|
|
# frozen_string_literal: true
|
2020-10-07 05:09:13 -04:00
|
|
|
# rubocop:disable Style/SignalException
|
2020-09-08 05:08:31 -04:00
|
|
|
|
|
|
|
PATTERNS = %w[
|
2020-10-12 02:08:53 -04:00
|
|
|
%a.btn.btn-
|
|
|
|
%button.btn.btn-
|
|
|
|
.alert
|
|
|
|
.alert-danger
|
|
|
|
.alert-dismissible
|
|
|
|
.alert-info
|
|
|
|
.alert-link
|
|
|
|
.alert-primary
|
|
|
|
.alert-success
|
|
|
|
.alert-warning
|
|
|
|
.nav-tabs
|
|
|
|
.toolbar-button-icon
|
|
|
|
.tooltip
|
|
|
|
.tooltip-inner
|
|
|
|
<button
|
|
|
|
<tabs
|
|
|
|
bs-callout
|
|
|
|
deprecated-modal
|
2020-09-08 05:08:31 -04:00
|
|
|
initDeprecatedJQueryDropdown
|
2020-10-12 02:08:53 -04:00
|
|
|
loading-button
|
|
|
|
v-popover
|
|
|
|
v-tooltip
|
|
|
|
with_tooltip
|
2020-09-08 05:08:31 -04:00
|
|
|
].freeze
|
|
|
|
|
2020-10-07 05:09:13 -04:00
|
|
|
BLOCKING_PATTERNS = %w[
|
2020-10-14 08:08:58 -04:00
|
|
|
pagination-button
|
|
|
|
graphql_pagination
|
2020-10-07 05:09:13 -04:00
|
|
|
].freeze
|
|
|
|
|
2020-09-08 05:08:31 -04:00
|
|
|
def get_added_lines(files)
|
|
|
|
lines = []
|
|
|
|
files.each do |file|
|
|
|
|
lines += helper.changed_lines(file).select { |line| %r{^[+]}.match?(line) }
|
|
|
|
end
|
|
|
|
lines
|
|
|
|
end
|
|
|
|
|
|
|
|
changed_vue_haml_files = helper.changed_files(/.vue$|.haml$/)
|
|
|
|
|
|
|
|
return if changed_vue_haml_files.empty?
|
|
|
|
|
|
|
|
changed_lines_in_mr = get_added_lines(changed_vue_haml_files)
|
2020-10-07 05:09:13 -04:00
|
|
|
deprecated_components_in_mr = PATTERNS.select { |pattern| changed_lines_in_mr.any? { |line| line[pattern] } }
|
|
|
|
blocking_components_in_mr = BLOCKING_PATTERNS.select { |pattern| changed_lines_in_mr.any? { |line| line[pattern] } }
|
2020-09-08 05:08:31 -04:00
|
|
|
|
2020-10-07 05:09:13 -04:00
|
|
|
return if (deprecated_components_in_mr + blocking_components_in_mr).empty?
|
2020-09-08 05:08:31 -04:00
|
|
|
|
|
|
|
markdown(<<~MARKDOWN)
|
|
|
|
## Deprecated components
|
|
|
|
|
2020-10-07 05:09:13 -04:00
|
|
|
MARKDOWN
|
2020-09-08 05:08:31 -04:00
|
|
|
|
2020-10-07 05:09:13 -04:00
|
|
|
if blocking_components_in_mr.any?
|
|
|
|
markdown(<<~MARKDOWN)
|
2021-09-20 02:09:32 -04:00
|
|
|
These deprecated components have already been migrated and can no longer be used. Please use [Pajamas components](https://design.gitlab.com/components/overview) instead.
|
2020-09-08 05:08:31 -04:00
|
|
|
|
2020-10-07 05:09:13 -04:00
|
|
|
* #{blocking_components_in_mr.join("\n* ")}
|
|
|
|
|
|
|
|
MARKDOWN
|
|
|
|
|
|
|
|
fail "This merge request contains deprecated components that have been migrated and can no longer be used. Please use Pajamas components instead."
|
|
|
|
end
|
|
|
|
|
|
|
|
if deprecated_components_in_mr.any?
|
|
|
|
markdown(<<~MARKDOWN)
|
2021-09-20 02:09:32 -04:00
|
|
|
These deprecated components are in the process of being migrated. Please consider using [Pajamas components](https://design.gitlab.com/components/overview) instead.
|
2020-10-07 05:09:13 -04:00
|
|
|
|
|
|
|
* #{deprecated_components_in_mr.join("\n* ")}
|
|
|
|
|
|
|
|
MARKDOWN
|
|
|
|
|
|
|
|
warn "This merge request contains deprecated components. Please consider using Pajamas components instead."
|
|
|
|
end
|