rbtools.diffs.tools.backends.gnu¶
A diff tool interfacing with GNU Diff.
New in version 4.0.
Classes
A diff tool interfacing with GNU Diff. |
- class rbtools.diffs.tools.backends.gnu.GNUDiffTool[source]¶
Bases:
BaseDiffTool
A diff tool interfacing with GNU Diff.
New in version 4.0.
- classmethod get_install_instructions() str [source]¶
Return instructions for installing this tool.
This will provide different instructions for Windows and Linux, helping users install GNU Diff.
macOS will always ship GNU Diff or Apple Diff, so we don’t bother providing instructions here.
- Returns:
The installation instructions, or an empty string, depending on the platform.
- Return type:
- check_available() bool [source]¶
Check whether GNU Diff is available for use.
This will check if GNU Diff is present in the system path.
If available, this will set
exe_path
andversion_info
.- Returns:
True
if GNU Diff is available.False
if it’s not.- Return type:
- make_run_diff_file_cmdline(*, orig_path: str, modified_path: str, show_hunk_context: bool = False, treat_missing_as_empty: bool = True) List[str] [source]¶
Return the command line for running the diff tool.
This should generally be used by
run_diff_file()
, and can be useful to unit tests that need to check for the process being run.- Parameters:
orig_path (
str
) – The path to the original file.modified_path (
str
) – The path to the modified file.show_hunk_context (
bool
, optional) – Whether to show context on hunk lines, if supported by the diff tool.treat_missing_as_empty (
bool
, optional) –Whether to treat a missing
orig_path
ormodified_path
as an empty file, instead of failing to diff.This must be supported by subclasses.
- Returns:
The command line to run for the given flags.
- Return type:
- run_diff_file(*, orig_path: str, modified_path: str, show_hunk_context: bool = False, treat_missing_as_empty: bool = True) DiffFileResult [source]¶
Return the result of a diff between two files.
This will call GNU Diff with the appropriate parameters, returning a Unified Diff of the results.
- Parameters:
orig_path (
str
) – The path to the original file.modified_path (
str
) – The path to the modified file.show_hunk_context (
bool
, optional) – Whether to show context on hunk lines, if supported by the diff tool.treat_missing_as_empty (
bool
, optional) – Whether to treat a missingorig_path
ormodified_path
as an empty file, instead of failing to diff.
- Returns:
The result of the diff operation.
- Return type:
- Raises:
rbtools.utils.process.RunProcessError – There was an error invoking the diff tool. Details are in the exception.