Skip to content

Commit 672672e

Browse files
committed
Merge pull request #26 from barthez/skip-capital-letter-check-for-fixups-and-squashes
Skip capital letter check for autosquash commits
2 parents 782b377 + 6c18108 commit 672672e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/fit_commit/validators/capitalize_subject.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
module FitCommit
44
module Validators
55
class CapitalizeSubject < Base
6+
AUTOSQUASH = /\A(fixup|squash)! /
7+
68
def validate_line(lineno, text)
7-
if lineno == 1 && text[0] =~ /[[:lower:]]/
9+
if lineno == 1 && text[0] =~ /[[:lower:]]/ && text !~ AUTOSQUASH
810
add_error(lineno, "Begin all subject lines with a capital letter.")
911
end
1012
end

test/unit/validators/capitalize_subject_test.rb

+16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@
1717
assert_empty validator.warnings
1818
end
1919
end
20+
describe "subject is fixup commit" do
21+
let(:commit_msg) { "fixup! foo bar" }
22+
it "does not have errors/warnings" do
23+
validator.validate(commit_lines)
24+
assert_empty validator.errors
25+
assert_empty validator.warnings
26+
end
27+
end
28+
describe "subject is squash commit" do
29+
let(:commit_msg) { "squash! foo bar" }
30+
it "does not have errors/warnings" do
31+
validator.validate(commit_lines)
32+
assert_empty validator.errors
33+
assert_empty validator.warnings
34+
end
35+
end
2036
describe "subject is capitalized" do
2137
let(:commit_msg) { "Foo bar" }
2238
it "does not have errors/warnings" do

0 commit comments

Comments
 (0)