MCPcopy
hub / github.com/openai/gpt-oss / text_to_patch

Function text_to_patch

gpt_oss/tools/apply_patch.py:416–427  ·  view source on GitHub ↗
(text: str, orig: Dict[str, str])

Source from the content-addressed store, hash-verified

414# User-facing helpers
415# --------------------------------------------------------------------------- #
416def text_to_patch(text: str, orig: Dict[str, str]) -> Tuple[Patch, int]:
417 lines = text.splitlines() # preserves blank lines, no strip()
418 if (
419 len(lines) < 2
420 or not Parser._norm(lines[0]).startswith("*** Begin Patch")
421 or Parser._norm(lines[-1]) != "*** End Patch"
422 ):
423 raise DiffError("Invalid patch text - missing sentinels")
424
425 parser = Parser(current_files=orig, lines=lines, index=1)
426 parser.parse()
427 return parser.patch, parser.fuzz
428
429
430def identify_files_needed(text: str) -> List[str]:

Callers 1

apply_patchFunction · 0.85

Calls 5

parseMethod · 0.95
DiffErrorClass · 0.85
ParserClass · 0.85
startswithMethod · 0.80
_normMethod · 0.80

Tested by

no test coverage detected