debian-mirror-gitlab/danger/pajamas/Dangerfile

86 lines
2.2 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
2021-01-03 14:25:43 +05:30
# rubocop:disable Style/SignalException
2020-11-24 15:15:51 +05:30
PATTERNS = %w[
2021-01-03 14:25:43 +05:30
%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-11-24 15:15:51 +05:30
gl-deprecated-button
gl-deprecated-dropdown
gl-deprecated-dropdown-divider
gl-deprecated-dropdown-header
gl-deprecated-dropdown-item
2021-01-03 14:25:43 +05:30
has-tooltip
has_tooltip
2020-11-24 15:15:51 +05:30
initDeprecatedJQueryDropdown
2021-01-03 14:25:43 +05:30
loading-button
v-popover
v-tooltip
with_tooltip
].freeze
BLOCKING_PATTERNS = %w[
pagination-button
graphql_pagination
2020-11-24 15:15:51 +05:30
].freeze
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)
2021-01-03 14:25:43 +05:30
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-11-24 15:15:51 +05:30
2021-01-03 14:25:43 +05:30
return if (deprecated_components_in_mr + blocking_components_in_mr).empty?
2020-11-24 15:15:51 +05:30
markdown(<<~MARKDOWN)
## Deprecated components
2021-01-03 14:25:43 +05:30
MARKDOWN
2020-11-24 15:15:51 +05:30
2021-01-03 14:25:43 +05:30
if blocking_components_in_mr.any?
markdown(<<~MARKDOWN)
These deprecated components have already been migrated and can no longer be used. Please use [Pajamas components](https://design.gitlab.com/components/status/) instead.
2020-11-24 15:15:51 +05:30
2021-01-03 14:25:43 +05:30
* #{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)
These deprecated components are in the process of being migrated. Please consider using [Pajamas components](https://design.gitlab.com/components/status/) instead.
* #{deprecated_components_in_mr.join("\n* ")}
MARKDOWN
warn "This merge request contains deprecated components. Please consider using Pajamas components instead."
end