File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 7
7
class Patch :
8
8
"""Handle patches in unified diff format for making changes to the local file system."""
9
9
10
+ # Compile the regular expression used in parse_line method
11
+ CHUNK_HEADER_REGEX = re .compile (r"@@ -(\d+),(\d+) \+(\d+),(\d+) @@" )
12
+
10
13
@staticmethod
11
14
def apply_patch (patch_string , is_rebuilt = False ):
12
15
"""Applies a patch to the local file system using git apply."""
@@ -48,7 +51,7 @@ def parse_line(line): # noqa: PLR0911
48
51
elif line .startswith ("+++" ):
49
52
return SimpleNamespace (line = line , type = "destination_file" , parsed = line [6 :])
50
53
elif line .startswith ("@@" ):
51
- chunk_header_match = re . match (r"@@ -(\d+),(\d+) \+(\d+),(\d+) @@" , line )
54
+ chunk_header_match = Patch . CHUNK_HEADER_REGEX . match (line )
52
55
if not chunk_header_match :
53
56
raise ValueError (f"Invalid chunk header: { line } " )
54
57
You can’t perform that action at this time.
0 commit comments