Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit 7ba9fe6

Browse files
oktalzMo3m3n
authored andcommitted
MINOR: add limit to maximal size of subject
to long subject messages are equally bad as very short ones. Limit of 100 characters and 15 words seems good, anything beyond that should go in commit body
1 parent bf9f485 commit 7ba9fe6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

check-commit/check.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ func checkSubject(subject string) error {
7878
if len(subject) < 15 || len(strings.Split(subject, " ")) < 3 {
7979
return fmt.Errorf("Too short or meaningless commit subject '%s'", subject)
8080
}
81+
if len(subject) > 100 || len(strings.Split(subject, " ")) > 15 {
82+
return fmt.Errorf("Too long commit subject '%s'", subject)
83+
}
8184
return nil
8285
}
8386

@@ -107,7 +110,7 @@ func main() {
107110
log.Println("Handling Merge Request:\n", subject)
108111
parts := strings.Fields(subject)
109112
if len(parts) != 4 {
110-
log.Fatal(fmt.Errorf("Unkown Merge commit format '%s'\n", subject))
113+
log.Fatal(fmt.Errorf("Unknown Merge commit format '%s'\n", subject))
111114
}
112115
out, err = exec.Command("git", "log", parts[3]+".."+parts[1], "--pretty=format:'%s'").Output()
113116
if err != nil {

0 commit comments

Comments
 (0)