Skip to content

diff

Generating the difference between two directories.

Nabbed from Cruft: https://github.com/cruft/cruft/

display_diff(repo0: Path, repo1: Path) -> None

Displays the diff between two repositories.

get_diff(repo0: Path, repo1: Path) -> str

Compute the raw diff between two repositories.

replace_diff_prefixes(
    diff: str, repo0_path: str, repo1_path: str
) -> str

Replace the changed file prefixes in the diff output.

Our git diff --no-index command will output full paths like so::

--- upstream-template-old/tmp/tmpmp34g21y/remote/.coveragerc
+++ upstream-template-new/tmp/tmpmp34g21y/local/.coveragerc

This isn’t the format we need in order to apply the diff later on. The result of this command will change the paths to::

--- upstream-template-old/.coveragerc
+++ upstream-template-new/.coveragerc

NIX OPs have {prefix}/folder/file WIN OPS have {prefix}/c:/folder/file

More info on git-diff can be found here: http://git-scm.com/docs/git-diff

Parameters:

diff

The diff output to change

TYPE: str

repo0_path

The full string path to the source repo

TYPE: str

repo1_path

The full string path to the destination repo

TYPE: str

Returns:

str

The modified diff string