Warning
Deprecated and unmaintained. This package is no longer maintained and receives no further updates.
Use github.com/conventionalcommit/syntax instead (go get github.com/conventionalcommit/syntax), a faster parser with zero dependencies, zero heap allocations for headers and bodies, exact source spans, and diagnostic recovery.
A go parser for Conventional Commits messages
var msg = `feat(scope): description
this is first line in body
this is second line in body
Ref #123
Date: 01-01-2021
By: John Doe`
commit, err := Parse(msg)
if err != nil {
fmt.Printf("Error: %s", err.Error())
}
fmt.Printf("%#v", commit)
/*
commitMsg = &parser.Commit{
message: "feat(scope): description\n\nthis is first line in body\n\nthis is second line in body\n\nRef #123\nDate: 01-01-2021\nBy: John Doe",
header: "feat(scope): description",
body: "this is first line in body\n\nthis is second line in body",
footer: "Ref #123\nDate: 01-01-2021\nBy: John Doe",
commitType: "feat",
scope: "scope",
description: "description",
notes: {
{token:"Ref", value:"123"},
{token:"Date", value:"01-01-2021"},
{token:"By", value:"John Doe"},
},
isBreakingChange: false,
}
*/- More Test Cases
- Benchmark
This parser is inspired and forked from