Documentation
¶
Overview ¶
Package parser provides a parser for conventional commits
Index ¶
- type Commit
- func (c *Commit) Body() string
- func (c *Commit) Description() string
- func (c *Commit) Footer() string
- func (c *Commit) Header() string
- func (c *Commit) IsBreakingChange() bool
- func (c *Commit) Message() string
- func (c *Commit) Notes() []Note
- func (c *Commit) Scope() string
- func (c *Commit) Type() string
- type Note
- type Parser
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct {
// contains filtered or unexported fields
}
Commit represents a commit that adheres to the conventional commits specification
func (*Commit) Description ¶ added in v0.6.0
Description returns description of the commit
func (*Commit) IsBreakingChange ¶ added in v0.6.0
IsBreakingChange returns true if commit is breaking change
type Note ¶ added in v0.6.0
type Note struct {
// contains filtered or unexported fields
}
Note represents one footer note
type Parser ¶ added in v0.6.0
type Parser struct{}
Parser represent a conventional commits parser
Example ¶
package main
import (
"fmt"
"github.com/conventionalcommit/parser"
)
func main() {
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`
p := parser.New()
commit, err := p.Parse(msg)
if err != nil {
fmt.Printf("Error: %s", err.Error())
}
fmt.Printf("%#v", commit)
}
Output: &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:[]parser.Note{parser.Note{token:"Ref", value:"123"}, parser.Note{token:"Date", value:"01-01-2021"}, parser.Note{token:"By", value:"John Doe"}}, isBreakingChange:false}
Click to show internal directories.
Click to hide internal directories.