[#7] Check empty line after commit's header
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
parent
b8aea16a20
commit
5b73349910
15
main.go
15
main.go
|
@ -19,6 +19,7 @@ var rxHeader = regexp.MustCompile(`^(\[\#[0-9]+\]\s|Release|Revert|Reapply)`)
|
|||
func main() {
|
||||
// Prepare regexp templates.
|
||||
rxSignOff := regexp.MustCompile(`^Signed-off-by:`)
|
||||
rxEmptyLine := regexp.MustCompile(`^$`)
|
||||
|
||||
// Open current git dir.
|
||||
r, err := git.PlainOpen("./")
|
||||
|
@ -69,6 +70,13 @@ func main() {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Do not process commits shorter than 3 lines.
|
||||
if len(lines) < 3 {
|
||||
fail = true
|
||||
fmt.Printf("Error: commit is too short [%s]\n", id)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check commit header.
|
||||
header := lines[0]
|
||||
if !rxHeader.MatchString(header) {
|
||||
|
@ -77,6 +85,13 @@ func main() {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Check empty line after header.
|
||||
if !rxEmptyLine.MatchString(lines[1]) {
|
||||
fail = true
|
||||
fmt.Printf("Error: second line must be empty '%s' [%s]\n", lines[1], id)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check commit sign-off.
|
||||
if !rxSignOff.MatchString(lines[len(lines)-1]) {
|
||||
fail = true
|
||||
|
|
Loading…
Reference in New Issue