@@ -83,7 +83,7 @@ var oneChunkPatch Patch = testPatch{
83
83
content : "A\n " ,
84
84
op : Delete ,
85
85
}, {
86
- content : "B\n C\n D\n E\n F\n G" ,
86
+ content : "B\n C\n D\n E\n F\n G\n " ,
87
87
op : Equal ,
88
88
}, {
89
89
content : "H\n " ,
@@ -125,7 +125,7 @@ var oneChunkPatchInverted Patch = testPatch{
125
125
content : "A\n " ,
126
126
op : Add ,
127
127
}, {
128
- content : "B\n C\n D\n E\n F\n G" ,
128
+ content : "B\n C\n D\n E\n F\n G\n " ,
129
129
op : Equal ,
130
130
}, {
131
131
content : "H\n " ,
@@ -164,13 +164,13 @@ var fixtures []*fixture = []*fixture{{
164
164
seed : "hello\n bug\n " ,
165
165
},
166
166
chunks : []testChunk {{
167
- content : "hello" ,
167
+ content : "hello\n " ,
168
168
op : Equal ,
169
169
}, {
170
- content : "world" ,
170
+ content : "world\n " ,
171
171
op : Delete ,
172
172
}, {
173
- content : "bug" ,
173
+ content : "bug\n " ,
174
174
op : Add ,
175
175
}},
176
176
}},
@@ -239,18 +239,18 @@ rename to test1.txt
239
239
from : & testFile {
240
240
mode : filemode .Regular ,
241
241
path : "test.txt" ,
242
- seed : "test" ,
242
+ seed : "test\n " ,
243
243
},
244
244
to : & testFile {
245
245
mode : filemode .Regular ,
246
246
path : "test1.txt" ,
247
- seed : "test1" ,
247
+ seed : "test1\n " ,
248
248
},
249
249
chunks : []testChunk {{
250
- content : "test" ,
250
+ content : "test\n " ,
251
251
op : Delete ,
252
252
}, {
253
- content : "test1" ,
253
+ content : "test1\n " ,
254
254
op : Add ,
255
255
}},
256
256
}},
@@ -260,7 +260,7 @@ rename to test1.txt
260
260
diff : `diff --git a/test.txt b/test1.txt
261
261
rename from test.txt
262
262
rename to test1.txt
263
- index 30d74d258442c7c65512eafab474568dd706c430..f079749c42ffdcc5f52ed2d3a6f15b09307e975e 100644
263
+ index 9daeafb9864cf43055ae93beb0afd6c7d144bfa4..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 100644
264
264
--- a/test.txt
265
265
+++ b/test1.txt
266
266
@@ -1 +1 @@
@@ -299,19 +299,19 @@ rename to test1.txt
299
299
from : & testFile {
300
300
mode : filemode .Regular ,
301
301
path : "test.txt" ,
302
- seed : "test" ,
302
+ seed : "test\n " ,
303
303
},
304
304
to : & testFile {
305
305
mode : filemode .Regular ,
306
306
path : "test.txt" ,
307
- seed : "test2" ,
307
+ seed : "test2\n " ,
308
308
},
309
309
310
310
chunks : []testChunk {{
311
- content : "test" ,
311
+ content : "test\n " ,
312
312
op : Delete ,
313
313
}, {
314
- content : "test2" ,
314
+ content : "test2\n " ,
315
315
op : Add ,
316
316
}},
317
317
}},
@@ -320,7 +320,7 @@ rename to test1.txt
320
320
desc : "one line change" ,
321
321
context : 1 ,
322
322
diff : `diff --git a/test.txt b/test.txt
323
- index 30d74d258442c7c65512eafab474568dd706c430..d606037cb232bfda7788a8322492312d55b2ae9d 100644
323
+ index 9daeafb9864cf43055ae93beb0afd6c7d144bfa4..180cf8328022becee9aaa2577a8f84ea2b9f3827 100644
324
324
--- a/test.txt
325
325
+++ b/test.txt
326
326
@@ -1 +1 @@
@@ -334,19 +334,19 @@ index 30d74d258442c7c65512eafab474568dd706c430..d606037cb232bfda7788a8322492312d
334
334
from : & testFile {
335
335
mode : filemode .Regular ,
336
336
path : "test.txt" ,
337
- seed : "test" ,
337
+ seed : "test\n " ,
338
338
},
339
339
to : & testFile {
340
340
mode : filemode .Regular ,
341
341
path : "test.txt" ,
342
- seed : "test2" ,
342
+ seed : "test2\n " ,
343
343
},
344
344
345
345
chunks : []testChunk {{
346
- content : "test" ,
346
+ content : "test\n " ,
347
347
op : Delete ,
348
348
}, {
349
- content : "test2" ,
349
+ content : "test2\n " ,
350
350
op : Add ,
351
351
}},
352
352
}},
@@ -356,7 +356,7 @@ index 30d74d258442c7c65512eafab474568dd706c430..d606037cb232bfda7788a8322492312d
356
356
context : 1 ,
357
357
diff : `this is the message
358
358
diff --git a/test.txt b/test.txt
359
- index 30d74d258442c7c65512eafab474568dd706c430..d606037cb232bfda7788a8322492312d55b2ae9d 100644
359
+ index 9daeafb9864cf43055ae93beb0afd6c7d144bfa4..180cf8328022becee9aaa2577a8f84ea2b9f3827 100644
360
360
--- a/test.txt
361
361
+++ b/test.txt
362
362
@@ -1 +1 @@
@@ -397,7 +397,9 @@ index 30d74d258442c7c65512eafab474568dd706c430..d606037cb232bfda7788a8322492312d
397
397
+++ b/test.txt
398
398
@@ -1 +1 @@
399
399
-test
400
+ \ No newline at end of file
400
401
+test2
402
+ \ No newline at end of file
401
403
` ,
402
404
}, {
403
405
patch : testPatch {
@@ -407,7 +409,7 @@ index 30d74d258442c7c65512eafab474568dd706c430..d606037cb232bfda7788a8322492312d
407
409
to : & testFile {
408
410
mode : filemode .Regular ,
409
411
path : "new.txt" ,
410
- seed : "test\n test2\t est3 " ,
412
+ seed : "test\n test2\n test3 " ,
411
413
},
412
414
413
415
chunks : []testChunk {{
@@ -421,13 +423,14 @@ index 30d74d258442c7c65512eafab474568dd706c430..d606037cb232bfda7788a8322492312d
421
423
context : 1 ,
422
424
diff : `diff --git a/new.txt b/new.txt
423
425
new file mode 100644
424
- index 0000000000000000000000000000000000000000..65c8dd02a42273038658a22b1cb29c8d9457ca12
426
+ index 0000000000000000000000000000000000000000..3ceaab5442b64a0c2b33dd25fae67ccdb4fd1ea8
425
427
--- /dev/null
426
428
+++ b/new.txt
427
429
@@ -0,0 +1,3 @@
428
430
+test
429
431
+test2
430
432
+test3
433
+ \ No newline at end of file
431
434
` ,
432
435
}, {
433
436
patch : testPatch {
@@ -456,6 +459,7 @@ index 30d74d258442c7c65512eafab474568dd706c430..00000000000000000000000000000000
456
459
+++ /dev/null
457
460
@@ -1 +0,0 @@
458
461
-test
462
+ \ No newline at end of file
459
463
` ,
460
464
}, {
461
465
patch : oneChunkPatch ,
@@ -548,6 +552,7 @@ index ab5eed5d4a2c33aeef67e0188ee79bed666bde6f..0adddcde4fd38042c354518351820eb0
548
552
X
549
553
Y
550
554
Z
555
+ \ No newline at end of file
551
556
` ,
552
557
}, {
553
558
patch : oneChunkPatch ,
@@ -813,6 +818,47 @@ index 0adddcde4fd38042c354518351820eb06c417c82..553ae669c7a9303cf848fcc749a25692
813
818
+++ b/onechunk.txt
814
819
@@ -23 +22,0 @@ Y
815
820
-Z
821
+ \ No newline at end of file
822
+ ` ,
823
+ }, {
824
+ patch : testPatch {
825
+ message : "" ,
826
+ filePatches : []testFilePatch {{
827
+ from : & testFile {
828
+ mode : filemode .Regular ,
829
+ path : "onechunk.txt" ,
830
+ seed : "B\n C\n D\n E\n F\n G\n I\n J\n K\n L\n M\n N\n O\n P\n Q\n R\n S\n T\n V\n W\n X\n Y\n Z" ,
831
+ },
832
+ to : & testFile {
833
+ mode : filemode .Regular ,
834
+ path : "onechunk.txt" ,
835
+ seed : "B\n C\n D\n E\n F\n G\n I\n J\n K\n L\n M\n N\n O\n P\n Q\n R\n S\n T\n V\n W\n X\n Y" ,
836
+ },
837
+
838
+ chunks : []testChunk {{
839
+ content : "B\n C\n D\n E\n F\n G\n I\n J\n K\n L\n M\n N\n O\n P\n Q\n R\n S\n T\n V\n W\n X\n " ,
840
+ op : Equal ,
841
+ }, {
842
+ content : "Y\n Z" ,
843
+ op : Delete ,
844
+ }, {
845
+ content : "Y" ,
846
+ op : Add ,
847
+ }},
848
+ }},
849
+ },
850
+ desc : "remove last letter and no newline at end of file" ,
851
+ context : 0 ,
852
+ diff : `diff --git a/onechunk.txt b/onechunk.txt
853
+ index 0adddcde4fd38042c354518351820eb06c417c82..d39ae38aad7ba9447b5e7998b2e4714f26c9218d 100644
854
+ --- a/onechunk.txt
855
+ +++ b/onechunk.txt
856
+ @@ -22,2 +21 @@ X
857
+ -Y
858
+ -Z
859
+ \ No newline at end of file
860
+ +Y
861
+ \ No newline at end of file
816
862
` ,
817
863
}}
818
864
0 commit comments