Allow Danger commit_messages rule to work locally

parent bdded17d
Pipeline #82323124 passed with stages
in 92 minutes and 42 seconds
......@@ -37,6 +37,10 @@ class EmojiChecker
end
end
def gitlab_danger
@gitlab_danger ||= GitlabDanger.new(helper.gitlab_helper)
end
def fail_commit(commit, message)
fail("#{commit.sha}: #{message}")
end
......@@ -56,6 +60,8 @@ def subject_starts_with_capital?(subject)
end
def ce_upstream?
return unless gitlab_danger.ci?
gitlab.mr_labels.any? { |label| label == 'CE upstream' }
end
......@@ -88,8 +94,8 @@ def lint_commit(commit) # rubocop:disable Metrics/AbcSize
# We ignore revert commits as they are well structured by Git already
return false if commit.message.start_with?('Revert "')
is_squash = gitlab.mr_json['squash']
is_wip = gitlab.mr_json['work_in_progress']
is_squash = gitlab_danger.ci? ? gitlab.mr_json['squash'] : false
is_wip = gitlab_danger.ci? ? gitlab.mr_json['work_in_progress'] : false
is_fixup = commit.message.start_with?('fixup!', 'squash!')
if is_fixup
......
......@@ -10,13 +10,13 @@ class GitlabDanger
prettier
eslint
database
commit_messages
].freeze
CI_ONLY_RULES ||= %w[
metadata
changelog
specs
commit_messages
roulette
single_codebase
gitlab_ui_wg
......
......@@ -9,7 +9,7 @@ describe GitlabDanger do
describe '.local_warning_message' do
it 'returns an informational message with rules that can run' do
expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, gemfile, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, database')
expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, gemfile, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, database, commit_messages')
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment