feat: return error when commit is empty
parent
4298794c82
commit
31b2d1f446
|
@ -60,6 +60,10 @@ func TestNewCommit(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Empty commit",
|
||||||
|
wantErr: ErrEmptyCommit,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
|
|
|
@ -20,12 +20,13 @@ type OptionFn func(*Commit) error
|
||||||
|
|
||||||
func GetRawHeader(gitCommit git.Commit) OptionFn {
|
func GetRawHeader(gitCommit git.Commit) OptionFn {
|
||||||
return func(c *Commit) error {
|
return func(c *Commit) error {
|
||||||
message := strings.TrimSpace(gitCommit.Message)
|
if gitCommit.Message == "" {
|
||||||
messages := strings.Split(message, "\n")
|
|
||||||
if len(messages) == 0 {
|
|
||||||
return ErrEmptyCommit
|
return ErrEmptyCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message := strings.TrimSpace(gitCommit.Message)
|
||||||
|
messages := strings.Split(message, "\n")
|
||||||
|
|
||||||
c.RawHeader = messages[0]
|
c.RawHeader = messages[0]
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue