@@ -7,6 +7,51 @@ import (
77 "github.com/conventionalcommit/commitlint/rule"
88)
99
10+ const (
11+ DefaultTypeCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
12+ DefaultScopeCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/,"
13+ )
14+
15+ // DefaultIgnorePatterns returns the default list of ignore patterns
16+ // These patterns match commit messages auto-generated by git commands
17+ // like merge, revert, fixup, squash, etc.
18+ func DefaultIgnorePatterns () []string {
19+ return []string {
20+ // GitHub / GitLab merge
21+ `^Merge pull request #\d+` ,
22+ `^Merge .+ into .+` ,
23+ `^Merge branch '.+'` ,
24+ `^Merge tag '.+'` ,
25+ `^Merge remote-tracking branch '.+'` ,
26+
27+ // Azure DevOps / Bitbucket merge
28+ `^Merged .+ (in|into) .+` ,
29+ `^Merged PR #?\d+` ,
30+
31+ // Revert and Reapply
32+ `^(R|r)evert ` ,
33+ `^(R|r)eapply ` ,
34+
35+ // Fixup, Amend, Squash (git commit --fixup/--squash)
36+ `^(amend|fixup|squash)! ` ,
37+
38+ // Automatic merges
39+ `^Automatic merge` ,
40+ `^Auto-merged .+ into .+` ,
41+
42+ // Initial commit
43+ `^Initial commit$` ,
44+ }
45+ }
46+
47+ // DefaultTypeEnums returns the default list of type enums
48+ func DefaultTypeEnums () []interface {} {
49+ return []interface {}{
50+ "feat" , "fix" , "docs" , "style" , "refactor" , "perf" ,
51+ "test" , "build" , "ci" , "chore" , "revert" ,
52+ }
53+ }
54+
1055// NewDefault returns default config
1156func NewDefault () * lint.Config {
1257 // Enabled Rules
@@ -47,10 +92,7 @@ func NewDefault() *lint.Config {
4792
4893 // Types Enum Rule
4994 (& rule.TypeEnumRule {}).Name (): {
50- Argument : []interface {}{
51- "feat" , "fix" , "docs" , "style" , "refactor" , "perf" ,
52- "test" , "build" , "ci" , "chore" , "revert" ,
53- },
95+ Argument : DefaultTypeEnums (),
5496 },
5597
5698 // Scope Enum Rule
@@ -113,12 +155,12 @@ func NewDefault() *lint.Config {
113155
114156 // Type Charset Rule
115157 (& rule.TypeCharsetRule {}).Name (): {
116- Argument : "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ,
158+ Argument : DefaultTypeCharset ,
117159 },
118160
119161 // Scope Charset Rule
120162 (& rule.ScopeCharsetRule {}).Name (): {
121- Argument : "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/," ,
163+ Argument : DefaultScopeCharset ,
122164 },
123165
124166 // Footer Enum Rule
@@ -128,16 +170,17 @@ func NewDefault() *lint.Config {
128170
129171 // Footer Type Enum Rule
130172 (& rule.FooterTypeEnumRule {}).Name (): {
131- Argument : []map [ interface {}] interface {}{},
173+ Argument : []interface {}{},
132174 },
133175 }
134176
135177 def := & lint.Config {
136- MinVersion : internal .Version (),
137- Formatter : (& formatter.DefaultFormatter {}).Name (),
138- Rules : rules ,
139- Severity : severity ,
140- Settings : settings ,
178+ MinVersion : internal .Version (),
179+ Formatter : (& formatter.DefaultFormatter {}).Name (),
180+ Rules : rules ,
181+ Severity : severity ,
182+ Settings : settings ,
183+ DefaultIgnorePatterns : DefaultIgnorePatterns (),
141184 }
142185 return def
143186}
0 commit comments