From 3992e5f7face0bafff296115c00181a28db83258 Mon Sep 17 00:00:00 2001 From: Roman Belonohy Date: Tue, 1 Nov 2022 09:18:25 +0100 Subject: [PATCH] Added Meld diff application as a diff program --- .../Reporters/DiffPrograms/MeldDiffProgram.cs | 34 +++++++++++++++++++ src/Assent/Reporters/DiffReporter.cs | 6 ++-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/Assent/Reporters/DiffPrograms/MeldDiffProgram.cs diff --git a/src/Assent/Reporters/DiffPrograms/MeldDiffProgram.cs b/src/Assent/Reporters/DiffPrograms/MeldDiffProgram.cs new file mode 100644 index 0000000..eabe251 --- /dev/null +++ b/src/Assent/Reporters/DiffPrograms/MeldDiffProgram.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Assent.Reporters.DiffPrograms; + +public class MeldDiffProgram : DiffProgramBase +{ + static readonly IReadOnlyList DefaultSearchPaths; + + static MeldDiffProgram() + { + var paths = new List(); + if (DiffReporter.IsWindows) + { + paths.AddRange(WindowsProgramFilePaths + .Select(p => $@"{p}\Meld\Meld.exe") + .ToArray()); + } + else + { + paths.Add("/usr/bin/meld"); + paths.Add("/usr/local/bin/meld"); + paths.Add("/snap/bin/meld"); + paths.Add("/opt/homebrew/bin/meld"); + } + DefaultSearchPaths = paths; + } + + public MeldDiffProgram() + : base(DefaultSearchPaths) { } + + protected override string CreateProcessStartArgs(string receivedFile, string approvedFile) => "\"" + receivedFile + "\" \"" + approvedFile + "\""; +} + diff --git a/src/Assent/Reporters/DiffReporter.cs b/src/Assent/Reporters/DiffReporter.cs index f3623ee..f51940e 100644 --- a/src/Assent/Reporters/DiffReporter.cs +++ b/src/Assent/Reporters/DiffReporter.cs @@ -24,13 +24,15 @@ static DiffReporter() new KDiff3DiffProgram(), new XdiffDiffProgram(), new P4MergeDiffProgram(), - new VsCodeDiffProgram() + new VsCodeDiffProgram(), + new MeldDiffProgram() } : new IDiffProgram[] { new EnvironmentVariableDiffProgram(), new BeyondCompareDiffProgram(), - new VsCodeDiffProgram() + new VsCodeDiffProgram(), + new MeldDiffProgram() }; }