File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 18
18
package cc
19
19
20
20
import (
21
+ "bytes"
21
22
"strings"
22
23
23
24
"github.com/bbuck/go-lexer"
@@ -63,7 +64,7 @@ func (c Commit) BreakingMessage() string {
63
64
64
65
// Parse parses the conventional commit. If it fails, an error is returned.
65
66
func Parse (s string ) (* Commit , error ) {
66
- l := lexer .New (strings .TrimSpace (s ), typeState )
67
+ l := lexer .New (normalizeNewlines ( strings .TrimSpace (s ) ), typeState )
67
68
l .ErrorHandler = func (string ) {}
68
69
69
70
l .Start ()
@@ -118,3 +119,13 @@ func (f Footers) breakingMessage() string {
118
119
119
120
return ""
120
121
}
122
+
123
+ func normalizeNewlines (s string ) string {
124
+ d := []byte (s )
125
+ // replace CR LF \r\n (windows) with LF \n (unix)
126
+ d = bytes .ReplaceAll (d , []byte {13 , 10 }, []byte {10 })
127
+ // replace CF \r (mac) with LF \n (unix)
128
+ d = bytes .ReplaceAll (d , []byte {13 }, []byte {10 })
129
+
130
+ return string (d )
131
+ }
You can’t perform that action at this time.
0 commit comments