Skip to content

Commit 222c0d2

Browse files
committed
BUG/MINOR: fix fragment detection
1 parent 711a388 commit 222c0d2

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

aspell/aspell.go

+16-11
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,23 @@ func (a Aspell) checkSingle(data string, allowedWords []string) error {
115115
func (a Aspell) Check(subjects []string, commitsFull []string, content []map[string]string) error {
116116
var commitsFullData []string
117117
for _, c := range commitsFull {
118-
c2 := strings.TrimSpace(c)
119-
if c2 == "" ||
120-
strings.HasPrefix(c2, "Signed-off-by:") ||
121-
strings.HasPrefix(c2, "Reviewed-by:") ||
122-
strings.HasPrefix(c2, "Tested-by:") ||
123-
strings.HasPrefix(c2, "Helped-by:") ||
124-
strings.HasPrefix(c2, "Reported-by:") ||
125-
strings.HasPrefix(c2, "Author:") ||
126-
strings.HasPrefix(c2, "Co-authored-by:") {
127-
continue
118+
commit := []string{}
119+
lines := strings.Split(c, "\n")
120+
for _, l := range lines {
121+
c2 := strings.TrimSpace(l)
122+
if strings.HasPrefix(c2, "Signed-off-by:") ||
123+
strings.HasPrefix(c2, "Reviewed-by:") ||
124+
strings.HasPrefix(c2, "Tested-by:") ||
125+
strings.HasPrefix(c2, "Helped-by:") ||
126+
strings.HasPrefix(c2, "Reported-by:") ||
127+
strings.HasPrefix(c2, "Author:") ||
128+
strings.HasPrefix(c2, "Co-authored-by:") {
129+
continue
130+
}
131+
132+
commit = append(commit, l)
128133
}
129-
commitsFullData = append(commitsFullData, c)
134+
commitsFullData = append(commitsFullData, strings.Join(commit, "\n"))
130135
}
131136

132137
var response string

aspell/aspell_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ func TestAspell_Check(t *testing.T) {
8282
content: []map[string]string{{"test": "test"}},
8383
},
8484
true,
85+
}, {
86+
"Signed off 2",
87+
fields{
88+
Mode: modeCommit,
89+
MinLength: 3,
90+
IgnoreFiles: []string{"config"},
91+
AllowedWords: []string{"config"},
92+
HelpText: "test",
93+
},
94+
args{
95+
subjects: []string{"BUG/MEDIUM: config: add default location of path to the configuration file"},
96+
commitsFull: []string{"some commit info\n\n Signed-off-by: Author: A locatoin <[email protected]>"},
97+
content: []map[string]string{{"test": "test"}},
98+
},
99+
false,
85100
}}
86101
for _, tt := range tests {
87102
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)