55
55
```
56
56
""" .strip ()
57
57
58
- ORIGINAL = "\n <<<<<<< ORIGINAL\n "
58
+ ORIGINAL = "<<<<<<< ORIGINAL\n "
59
59
DIVIDER = "\n =======\n "
60
- UPDATED = ">>>>>>> UPDATED\n "
60
+ UPDATED = "\n >>>>>>> UPDATED"
61
61
62
62
63
63
def apply (codeblock : str , content : str ) -> str :
@@ -77,9 +77,9 @@ def apply(codeblock: str, content: str) -> str:
77
77
raise ValueError (f"invalid patch, no `{ DIVIDER .strip ()} `" , codeblock )
78
78
original , modified = re .split (DIVIDER , original )
79
79
80
- if UPDATED not in modified : # pragma: no cover
80
+ if UPDATED not in " \n " + modified : # pragma: no cover
81
81
raise ValueError (f"invalid patch, no `{ UPDATED .strip ()} `" , codeblock )
82
- modified = re .split (UPDATED , modified )[0 ]. rstrip ( " \n " )
82
+ modified = re .split (UPDATED , modified )[0 ]
83
83
84
84
# TODO: maybe allow modified chunk to contain "// ..." to refer to chunks in the original,
85
85
# and then replace these with the original chunks?
@@ -93,12 +93,6 @@ def apply(codeblock: str, content: str) -> str:
93
93
94
94
95
95
def apply_file (codeblock , filename ):
96
- codeblock = codeblock .strip ()
97
- _patch , filename = codeblock .splitlines ()[0 ].split ()
98
- if not _patch == "```patch" :
99
- raise ValueError (
100
- "invalid patch, codeblock is missing leading ```patch" , codeblock
101
- )
102
96
if not Path (filename ).exists ():
103
97
raise FileNotFoundError (filename )
104
98
0 commit comments