Skip to content

Commit

Permalink
BUG/MINOR: fix fragment detection
Browse files Browse the repository at this point in the history
  • Loading branch information
oktalz committed Oct 7, 2024
1 parent 711a388 commit 222c0d2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
27 changes: 16 additions & 11 deletions aspell/aspell.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,23 @@ func (a Aspell) checkSingle(data string, allowedWords []string) error {
func (a Aspell) Check(subjects []string, commitsFull []string, content []map[string]string) error {
var commitsFullData []string
for _, c := range commitsFull {
c2 := strings.TrimSpace(c)
if c2 == "" ||
strings.HasPrefix(c2, "Signed-off-by:") ||
strings.HasPrefix(c2, "Reviewed-by:") ||
strings.HasPrefix(c2, "Tested-by:") ||
strings.HasPrefix(c2, "Helped-by:") ||
strings.HasPrefix(c2, "Reported-by:") ||
strings.HasPrefix(c2, "Author:") ||
strings.HasPrefix(c2, "Co-authored-by:") {
continue
commit := []string{}
lines := strings.Split(c, "\n")
for _, l := range lines {
c2 := strings.TrimSpace(l)
if strings.HasPrefix(c2, "Signed-off-by:") ||
strings.HasPrefix(c2, "Reviewed-by:") ||
strings.HasPrefix(c2, "Tested-by:") ||
strings.HasPrefix(c2, "Helped-by:") ||
strings.HasPrefix(c2, "Reported-by:") ||
strings.HasPrefix(c2, "Author:") ||
strings.HasPrefix(c2, "Co-authored-by:") {
continue
}

commit = append(commit, l)
}
commitsFullData = append(commitsFullData, c)
commitsFullData = append(commitsFullData, strings.Join(commit, "\n"))
}

var response string
Expand Down
15 changes: 15 additions & 0 deletions aspell/aspell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ func TestAspell_Check(t *testing.T) {
content: []map[string]string{{"test": "test"}},
},
true,
}, {
"Signed off 2",
fields{
Mode: modeCommit,
MinLength: 3,
IgnoreFiles: []string{"config"},
AllowedWords: []string{"config"},
HelpText: "test",
},
args{
subjects: []string{"BUG/MEDIUM: config: add default location of path to the configuration file"},
commitsFull: []string{"some commit info\n\n Signed-off-by: Author: A locatoin <[email protected]>"},
content: []map[string]string{{"test": "test"}},
},
false,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 222c0d2

Please sign in to comment.