Skip to content

Offsetted (relatively to sources) patches apply to wrong lines #21

Description

@KOLANICH

patch -p 1 < patchFile.patch (GNU patch) works fine.

def applyPatch(fileText: str, patchFile: Path):
	with patchFile.open("rb") as psf:
		ps = patch.PatchSet(psf)
		ps.parse(psf)

	p = ps.items[0]


	with BytesIO(fileText.encode("utf-8")) as sF:
		return b"".join(ps.patch_stream(sF, p.hunks)).decode("utf-8")

produces the wrong results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for responseRequires feedback from the user who created the issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions