| 48 | func (r *FooterLeadingBlankRule) Name() string { return "footer-leading-blank" } |
| 49 | func (r *FooterLeadingBlankRule) Apply(_ lint.RuleSetting) error { return nil } |
| 50 | func (r *FooterLeadingBlankRule) Validate(msg lint.Commit) (*lint.Issue, bool) { |
| 51 | footer := msg.Footer() |
| 52 | if footer == "" { |
| 53 | return nil, true |
| 54 | } |
| 55 | raw := msg.Message() |
| 56 | // Footer should be preceded by "\n\n" |
| 57 | footerIdx := strings.LastIndex(raw, footer) |
| 58 | if footerIdx < 2 { |
| 59 | return lint.NewIssue("footer must have a leading blank line"), false |
| 60 | } |
| 61 | if raw[footerIdx-2:footerIdx] == "\n\n" { |
| 62 | return nil, true |
| 63 | } |
| 64 | return lint.NewIssue("footer must have a leading blank line"), false |
| 65 | } |