wip: start of commit package

This commit is contained in:
2020-10-31 15:34:40 +00:00
parent 69056295b9
commit 5b086530ee
3 changed files with 154 additions and 0 deletions

21
pkg/commit/parser.go Normal file
View File

@@ -0,0 +1,21 @@
package commit
import "bytes"
const (
cr = 13
lf = 10
)
func paragraphs(input []byte) [][]byte {
cln := bytes.ReplaceAll(input, []byte{cr, lf}, []byte{lf})
cln = bytes.ReplaceAll(cln, []byte{cr}, []byte{lf})
ps := bytes.Split(cln, []byte{lf, lf})
for i, p := range ps {
ps[i] = bytes.Trim(p, "\r\n")
}
return ps
}