MCPcopy Create free account
hub / github.com/GRAnimated/MinecraftLCE / apply_diff

Function apply_diff

tools/setup.py:36–56  ·  view source on GitHub ↗
(original: Path, diff_file: Path)

Source from the content-addressed store, hash-verified

34
35
36def apply_diff(original: Path, diff_file: Path):
37 result = subprocess.run(
38 ["patch", "-N", str(original), str(diff_file)],
39 stdout=subprocess.PIPE,
40 stderr=subprocess.PIPE,
41 text=True
42 )
43
44 if result.returncode == 0:
45 return
46 elif result.returncode == 1:
47 combined_output = (result.stdout + result.stderr).lower()
48 if ("reversed (or previously applied) patch detected" in combined_output or
49 "skip" in combined_output or
50 "ignoring" in combined_output):
51 # its fine
52 return
53 else:
54 raise RuntimeError(f"Patch failed with output:\n{result.stdout}\n{result.stderr}")
55 else:
56 raise RuntimeError(f"Patch command failed with code {result.returncode}:\n{result.stdout}\n{result.stderr}")
57
58
59

Callers 1

patch_clangFunction · 0.85

Calls 1

runMethod · 0.45

Tested by

no test coverage detected