Commit d488980b authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'danger-dont-look-at-wip' into 'master'

Lint the MR title without WIP

See merge request gitlab-org/gitlab!25543
parents fe412eaf 75e92750
......@@ -14,6 +14,7 @@ module Gitlab
MAX_CHANGED_LINES_IN_COMMIT = 30
SHORT_REFERENCE_REGEX = %r{([\w\-\/]+)?(#|!|&|%)\d+\b}.freeze
DEFAULT_SUBJECT_DESCRIPTION = 'commit subject'
WIP_PREFIX = 'WIP: '
PROBLEMS = {
subject_too_short: "The %s must contain at least #{MIN_SUBJECT_WORDS_COUNT} words",
subject_too_long: "The %s may not be longer than #{MAX_LINE_LENGTH} characters",
......@@ -164,7 +165,7 @@ module Gitlab
end
def subject
message_parts[0]
message_parts[0].delete_prefix(WIP_PREFIX)
end
def separator
......
......@@ -152,6 +152,18 @@ describe Gitlab::Danger::CommitLinter do
end
end
context 'when subject is a WIP' do
let(:final_message) { 'A B C' }
# commit message with prefix will be over max length. commit message without prefix will be of maximum size
let(:commit_message) { described_class::WIP_PREFIX + final_message + 'D' * (described_class::WARN_SUBJECT_LENGTH - final_message.size) }
it 'does not have any problems' do
commit_linter.lint
expect(commit_linter.problems).to be_empty
end
end
context 'when subject is too short and too long' do
let(:commit_message) { 'A ' + 'B' * described_class::MAX_LINE_LENGTH }
......@@ -183,7 +195,7 @@ describe Gitlab::Danger::CommitLinter do
end
end
context 'when subject ands with a period' do
context 'when subject ends with a period' do
let(:commit_message) { 'A B C.' }
it 'adds a problem' do
......
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