add more edge case for git commit message trailer

This commit is contained in:
wxiaoguang
2026-06-15 15:38:03 +08:00
parent c8e0ebe74d
commit c7474fdb73
3 changed files with 4 additions and 8 deletions

View File

@@ -70,7 +70,7 @@ func (c *CommitMessage) MessageTrailer() CommitMessageTrailerValues {
var commitMessageTrailerSplit = sync.OnceValue(func() *regexp.Regexp {
// the sep is either something like "\n---\n" or "\n\n" in the body, or at the start of the body like "---\n"
return regexp.MustCompile(`(?s)^(?P<content>.*?)(?P<sep>^|^\n|^-{3,}\n|\n-{3,}\n|\n\n)(?P<trailer>(?:[A-Za-z0-9][-A-Za-z0-9]*:[^\n]*\n?)*)$`)
return regexp.MustCompile(`(?s)^(?P<content>.*?)(?P<sep>^|^\n|^-{3,}\n|\n-{3,}\n|\n\n)(?P<trailer>(?:[A-Za-z0-9][-A-Za-z0-9]*:[^\n]*\n?)*\n*)$`)
})
func CommitMessageSplitTrailer(s string) (content, sep, trailer string) {