Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab_danger.rb « tooling - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d20d3499641778eff002a2951262f9db90e16098 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# frozen_string_literal: true

# rubocop:todo Gitlab/NamespacedClass
class GitlabDanger
  LOCAL_RULES ||= %w[
    changes_size
    commit_messages
    database
    documentation
    duplicate_yarn_dependencies
    eslint
    karma
    pajamas
    pipeline
    prettier
    product_intelligence
    utility_css
  ].freeze

  CI_ONLY_RULES ||= %w[
    ce_ee_vue_templates
    changelog
    ci_templates
    metadata
    feature_flag
    roulette
    sidekiq_queues
    specialization_labels
    specs
  ].freeze

  MESSAGE_PREFIX = '==>'.freeze

  attr_reader :gitlab_danger_helper

  def initialize(gitlab_danger_helper)
    @gitlab_danger_helper = gitlab_danger_helper
  end

  def self.local_warning_message
    "#{MESSAGE_PREFIX} Only the following Danger rules can be run locally: #{LOCAL_RULES.join(', ')}"
  end

  def self.success_message
    "#{MESSAGE_PREFIX} No Danger rule violations!"
  end

  def rule_names
    ci? ? LOCAL_RULES | CI_ONLY_RULES : LOCAL_RULES
  end

  def html_link(str)
    self.ci? ? gitlab_danger_helper.html_link(str) : str
  end

  def ci?
    !gitlab_danger_helper.nil?
  end
end