refactor: remove body and footers in convention
parent
8dc573f65c
commit
3ab8e17719
|
@ -18,10 +18,9 @@ var (
|
|||
)
|
||||
|
||||
type Commit struct {
|
||||
Type string
|
||||
Scope string
|
||||
Description string
|
||||
BodyAndFooters string
|
||||
Type string
|
||||
Scope string
|
||||
Description string
|
||||
}
|
||||
|
||||
func NewCommit(c git.Commit) (result Commit, err error) {
|
||||
|
@ -37,9 +36,6 @@ func NewCommit(c git.Commit) (result Commit, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
bodyAndFooters := message[len(header):]
|
||||
parseBodyAndFooters(bodyAndFooters, &result)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -60,9 +56,3 @@ func parseHeader(header string, commit *Commit) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseBodyAndFooters(bodyAndFooters string, commit *Commit) {
|
||||
bodyAndFooters = strings.TrimSpace(bodyAndFooters)
|
||||
|
||||
commit.BodyAndFooters = bodyAndFooters
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package convention
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/haunt98/changeloguru/pkg/comparision"
|
||||
|
@ -14,40 +11,34 @@ import (
|
|||
func TestNewCommit(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
c git.Commit
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
name: "Commit message with description and breaking change footer",
|
||||
},
|
||||
{
|
||||
name: "Commit message with not character to draw attention to breaking change",
|
||||
c: git.Commit{
|
||||
Message: "refactor!: drop support for Node 6",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Commit message with no body",
|
||||
c: git.Commit{
|
||||
Message: "docs: correct spelling of CHANGELOG",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Commit message with scope",
|
||||
},
|
||||
{
|
||||
name: "Commit message with multi-paragraph body and multiple footers",
|
||||
c: git.Commit{
|
||||
Message: "feat(lang): add polish language",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
g := goldie.New(t)
|
||||
gName := g.GoldenFileName(t, t.Name())
|
||||
|
||||
inputName := strings.TrimSuffix(gName, ".golden") + ".txt"
|
||||
fmt.Println("inputName", inputName)
|
||||
bytes, err := ioutil.ReadFile(inputName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
gotResult, gotErr := NewCommit(git.Commit{
|
||||
Message: string(bytes),
|
||||
})
|
||||
gotResult, gotErr := NewCommit(tc.c)
|
||||
comparision.Diff(t, tc.wantErr, gotErr)
|
||||
if tc.wantErr != nil {
|
||||
return
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"Type": "feat",
|
||||
"Scope": "",
|
||||
"Description": "allow provided config object to extend other configs",
|
||||
"BodyAndFooters": "BREAKING CHANGE: `extends` key in config file is now used for extending other config files"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
feat: allow provided config object to extend other configs
|
||||
|
||||
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"Type": "fix",
|
||||
"Scope": "",
|
||||
"Description": "correct minor typos in code",
|
||||
"BodyAndFooters": "see the issue for details\n\non typos fixed.\n\nReviewed-by: Z\nRefs #133"
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
fix: correct minor typos in code
|
||||
|
||||
see the issue for details
|
||||
|
||||
on typos fixed.
|
||||
|
||||
Reviewed-by: Z
|
||||
Refs #133
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"Type": "docs",
|
||||
"Scope": "",
|
||||
"Description": "correct spelling of CHANGELOG",
|
||||
"BodyAndFooters": ""
|
||||
"Description": "correct spelling of CHANGELOG"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
docs: correct spelling of CHANGELOG
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"Type": "refactor",
|
||||
"Scope": "",
|
||||
"Description": "drop support for Node 6",
|
||||
"BodyAndFooters": ""
|
||||
"Description": "drop support for Node 6"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
refactor!: drop support for Node 6
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"Type": "feat",
|
||||
"Scope": "lang",
|
||||
"Description": "add polish language",
|
||||
"BodyAndFooters": ""
|
||||
"Description": "add polish language"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
feat(lang): add polish language
|
Loading…
Reference in New Issue