Skip to content

Commit

Permalink
Merge pull request #409 from TaffarelJr/master
Browse files Browse the repository at this point in the history
Register new diff tools: Devart Code Compare and Perforce P4Merge
  • Loading branch information
JakeGinnivan committed Oct 15, 2016
2 parents 12f0f7d + f3e2969 commit d9f4e7d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,11 @@ public class KnownDiffTools
[JetBrains.Annotations.UsedImplicitlyAttribute()]
public readonly Shouldly.Configuration.DiffTool BeyondCompare4;
[JetBrains.Annotations.UsedImplicitlyAttribute()]
public readonly Shouldly.Configuration.DiffTool CodeCompare;
[JetBrains.Annotations.UsedImplicitlyAttribute()]
public readonly Shouldly.Configuration.DiffTool KDiff3;
[JetBrains.Annotations.UsedImplicitlyAttribute()]
public readonly Shouldly.Configuration.DiffTool P4Merge;
public KnownDiffTools() { }
public static Shouldly.Configuration.KnownDiffTools Instance { get; }
}
Expand Down
18 changes: 18 additions & 0 deletions src/Shouldly/Configuration/KnownDiffTools.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if ShouldMatchApproved
using System.IO;
using JetBrains.Annotations;

namespace Shouldly.Configuration
Expand All @@ -11,6 +12,10 @@ public class KnownDiffTools
public readonly DiffTool BeyondCompare3 = new DiffTool("Beyond Compare 3", @"Beyond Compare 3\BCompare.exe", BeyondCompareArgs);
[UsedImplicitly]
public readonly DiffTool BeyondCompare4 = new DiffTool("Beyond Compare 4", @"Beyond Compare 4\BCompare.exe", BeyondCompareArgs);
[UsedImplicitly]
public readonly DiffTool CodeCompare = new DiffTool("Code Compare", @"Devart\Code Compare\CodeMerge.exe", CodeCompareArgs);
[UsedImplicitly]
public readonly DiffTool P4Merge = new DiffTool("P4Merge", @"Perforce\p4merge.exe", P4MergeArgs);

public static KnownDiffTools Instance { get; } = new KnownDiffTools();

Expand All @@ -27,6 +32,19 @@ static string KDiffArgs(string received, string approved, bool approvedExists)
? $"\"{received}\" \"{approved}\" -o \"{approved}\""
: $"\"{received}\" -o \"{approved}\"";
}

static string CodeCompareArgs(string received, string approved, bool approvedExists)
{
return $"/BF=\"{approved}\" /TF=\"{approved}\" /MF=\"{received}\" /RF=\"{approved}\"";
}

static string P4MergeArgs(string received, string approved, bool approvedExists)
{
if (!approvedExists)
File.AppendAllText(approved, string.Empty);

return $"\"{approved}\" \"{approved}\" \"{received}\" \"{approved}\"";
}
}
}
#endif
7 changes: 5 additions & 2 deletions src/TestDiffTools/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ public static void Main(string[] args)
ShouldlyConfiguration.DiffTools.RegisterDiffTool(selectedDiffTool.DiffTool);
var stacktrace = new StackTrace(true);

var approved = Path.Combine(Path.GetDirectoryName(stacktrace.GetFrame(0).GetFileName()),
"Main.approved.txt");
var currentFrame = stacktrace.GetFrame(0);
var approved = Path.Combine(
Path.GetDirectoryName(currentFrame.GetFileName()),
$"{Path.GetFileNameWithoutExtension(currentFrame.GetFileName())}.{currentFrame.GetMethod().Name}.approved.txt");

switch (selectedOption)
{
case 1:
Expand Down

0 comments on commit d9f4e7d

Please sign in to comment.