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

Fix commit linter to check that the first actual letter is capitalized

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 2665e40c
......@@ -200,7 +200,9 @@ module Gitlab
end
def subject_starts_with_lowercase?
first_char = subject[0]
first_char = subject.sub(/\A\[.+\]\s/, '')[0]
first_char_downcased = first_char.downcase
return true unless ('a'..'z').cover?(first_char_downcased)
first_char.downcase == first_char
end
......
......@@ -195,6 +195,39 @@ describe Gitlab::Danger::CommitLinter do
end
end
[
'[ci skip] A commit message',
'[Ci skip] A commit message',
'[API] A commit message'
].each do |message|
context "when subject is '#{message}'" do
let(:commit_message) { message }
it 'does not add a problem' do
expect(commit_linter).not_to receive(:add_problem)
commit_linter.lint
end
end
end
[
'[ci skip]A commit message',
'[Ci skip] A commit message',
'[ci skip] a commit message',
'! A commit message'
].each do |message|
context "when subject is '#{message}'" do
let(:commit_message) { message }
it 'adds a problem' do
expect(commit_linter).to receive(:add_problem).with(:subject_starts_with_lowercase, described_class::DEFAULT_SUBJECT_DESCRIPTION)
commit_linter.lint
end
end
end
context 'when subject ends with a period' do
let(:commit_message) { 'A B C.' }
......
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