function

diff.parsePatch

function parsePatch(
patch: string
): FilePatch[];

Parse a unified diff, as written by diff -u, git diff, git format-patch, svn diff or hg diff.

@returns

One entry for each file

Referenced types

interface FilePatch

What a patch changes in one file. A property is absent when the patch does not say.

  • index?: string

    The name in an Index: or diff -r line.

  • isBinary?: boolean

    Git reports a change to a binary file, which has no hunks.

  • isCopy?: boolean
  • isCreate?: boolean
  • isDelete?: boolean
  • isGit?: boolean

    The section starts with diff --git.

  • isRename?: boolean
  • newFileName?: string
  • newHeader?: string

    The text after the name in the +++ line.

  • newMode?: string

    The file mode after the change, in octal, like "100755". Git only.

  • oldFileName?: string
  • oldHeader?: string

    The text after the name in the --- line.

  • oldMode?: string

    The file mode before the change, in octal, like "100644". Git only.