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() }; }