File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 11// Jest Snapshot v1, https://goo.gl/fbAQLP
22
3+ exports [` the patch parser can handle files with CRLF line breaks 1` ] = `
4+ Array [
5+ Object {
6+ " lines" : Array [
7+ " this is a new file
8+ " ,
9+ ],
10+ " mode" : 420 ,
11+ " noNewlineAtEndOfFile" : false ,
12+ " path" : " banana.ts" ,
13+ " type" : " file creation" ,
14+ } ,
15+ ]
16+ ` ;
17+
318exports [` the patch parser works for a simple case 1` ] = `
419Array [
520 Object {
Original file line number Diff line number Diff line change @@ -91,6 +91,15 @@ index 2de83dd..842652c 100644
9191 file
9292`
9393
94+ const crlfLineBreaks = `diff --git a/banana.ts b/banana.ts
95+ new file mode 100644
96+ index 0000000..3e1267f
97+ --- /dev/null
98+ +++ b/banana.ts
99+ @@ -0,0 +1 @@
100+ +this is a new file
101+ ` . replace ( / \n / g, "\r\n" )
102+
94103describe ( "the patch parser" , ( ) => {
95104 it ( "works for a simple case" , ( ) => {
96105 expect ( parsePatch ( patch ) ) . toMatchSnapshot ( )
@@ -105,4 +114,7 @@ describe("the patch parser", () => {
105114 it ( "is OK when blank lines are accidentally created" , ( ) => {
106115 expect ( parsePatch ( accidentalBlankLine ) ) . toEqual ( parsePatch ( patch ) )
107116 } )
117+ it ( `can handle files with CRLF line breaks` , ( ) => {
118+ expect ( parsePatch ( crlfLineBreaks ) ) . toMatchSnapshot ( )
119+ } )
108120} )
Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ class PatchParser {
266266 }
267267
268268 private parseFileModification ( ) {
269- const startPath = this . currentLine . slice ( "--- " . length )
269+ const startPath = this . currentLine . trim ( ) . slice ( "--- " . length )
270270 this . nextLine ( )
271271 const endPath = this . currentLine . trim ( ) . slice ( "--- " . length )
272272 this . nextLine ( )
You can’t perform that action at this time.
0 commit comments