refactor: remove body and footers in convention
parent
8dc573f65c
commit
3ab8e17719
|
@ -18,10 +18,9 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Commit struct {
|
type Commit struct {
|
||||||
Type string
|
Type string
|
||||||
Scope string
|
Scope string
|
||||||
Description string
|
Description string
|
||||||
BodyAndFooters string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommit(c git.Commit) (result Commit, err error) {
|
func NewCommit(c git.Commit) (result Commit, err error) {
|
||||||
|
@ -37,9 +36,6 @@ func NewCommit(c git.Commit) (result Commit, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyAndFooters := message[len(header):]
|
|
||||||
parseBodyAndFooters(bodyAndFooters, &result)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +56,3 @@ func parseHeader(header string, commit *Commit) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseBodyAndFooters(bodyAndFooters string, commit *Commit) {
|
|
||||||
bodyAndFooters = strings.TrimSpace(bodyAndFooters)
|
|
||||||
|
|
||||||
commit.BodyAndFooters = bodyAndFooters
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package convention
|
package convention
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/haunt98/changeloguru/pkg/comparision"
|
"github.com/haunt98/changeloguru/pkg/comparision"
|
||||||
|
@ -14,40 +11,34 @@ import (
|
||||||
func TestNewCommit(t *testing.T) {
|
func TestNewCommit(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
c git.Commit
|
||||||
wantErr error
|
wantErr error
|
||||||
}{
|
}{
|
||||||
{
|
|
||||||
name: "Commit message with description and breaking change footer",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "Commit message with not character to draw attention to breaking change",
|
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",
|
name: "Commit message with no body",
|
||||||
|
c: git.Commit{
|
||||||
|
Message: "docs: correct spelling of CHANGELOG",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Commit message with scope",
|
name: "Commit message with scope",
|
||||||
},
|
c: git.Commit{
|
||||||
{
|
Message: "feat(lang): add polish language",
|
||||||
name: "Commit message with multi-paragraph body and multiple footers",
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
g := goldie.New(t)
|
g := goldie.New(t)
|
||||||
gName := g.GoldenFileName(t, t.Name())
|
|
||||||
|
|
||||||
inputName := strings.TrimSuffix(gName, ".golden") + ".txt"
|
gotResult, gotErr := NewCommit(tc.c)
|
||||||
fmt.Println("inputName", inputName)
|
|
||||||
bytes, err := ioutil.ReadFile(inputName)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
gotResult, gotErr := NewCommit(git.Commit{
|
|
||||||
Message: string(bytes),
|
|
||||||
})
|
|
||||||
comparision.Diff(t, tc.wantErr, gotErr)
|
comparision.Diff(t, tc.wantErr, gotErr)
|
||||||
if tc.wantErr != nil {
|
if tc.wantErr != nil {
|
||||||
return
|
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",
|
"Type": "docs",
|
||||||
"Scope": "",
|
"Scope": "",
|
||||||
"Description": "correct spelling of CHANGELOG",
|
"Description": "correct spelling of CHANGELOG"
|
||||||
"BodyAndFooters": ""
|
|
||||||
}
|
}
|
|
@ -1 +0,0 @@
|
||||||
docs: correct spelling of CHANGELOG
|
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
"Type": "refactor",
|
"Type": "refactor",
|
||||||
"Scope": "",
|
"Scope": "",
|
||||||
"Description": "drop support for Node 6",
|
"Description": "drop support for Node 6"
|
||||||
"BodyAndFooters": ""
|
|
||||||
}
|
}
|
|
@ -1 +0,0 @@
|
||||||
refactor!: drop support for Node 6
|
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
"Type": "feat",
|
"Type": "feat",
|
||||||
"Scope": "lang",
|
"Scope": "lang",
|
||||||
"Description": "add polish language",
|
"Description": "add polish language"
|
||||||
"BodyAndFooters": ""
|
|
||||||
}
|
}
|
|
@ -1 +0,0 @@
|
||||||
feat(lang): add polish language
|
|
Loading…
Reference in New Issue