Skip to content

Commit

Permalink
simplify grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Oct 11, 2020
1 parent 8b5a7d2 commit 0374f06
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 19 deletions.
5 changes: 5 additions & 0 deletions docs/mdsource/tray.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Run `diffenginetray` in a console to start the app.
<img src="..\src\DiffEngineTray.Tests\MenuBuilderTest.Full.verified.png">


### Grouping

Moves and deletes will be grouped by the containing solution. In the above, the files exist in DiffEngine, so the they are grouped under it.


### Moves

"Pending Moves" will accept the changes to file3 and file4.
Expand Down
5 changes: 5 additions & 0 deletions docs/tray.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ Run `diffenginetray` in a console to start the app.
<img src="..\src\DiffEngineTray.Tests\MenuBuilderTest.Full.verified.png">


### Grouping

Moves and deletes will be grouped by the containing solution. In the above, the files exist in DiffEngine, so the they are grouped under it.


### Moves

"Pending Moves" will accept the changes to file3 and file4.
Expand Down
Binary file modified src/DiffEngineTray.Tests/MenuBuilderTest.Full.verified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/DiffEngineTray.Tests/MenuBuilderTest.FullGrouped.verified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/DiffEngineTray.Tests/MenuBuilderTest.OnlyDelete.verified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/DiffEngineTray.Tests/MenuBuilderTest.OnlyMove.verified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions src/DiffEngineTray.Tests/MenuBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,24 @@ public async Task Full()
await Verifier.Verify(menu, settings);
}

[Fact]
public async Task Grouped()
{
await using var tracker = new RecordingTracker();
tracker.AddDelete("file2.txt");
tracker.AddMove(file4, "file4.txt", "theExe", "theArguments", true, null);
var menu = MenuBuilder.Build(() => { }, () => { }, tracker);
await Verifier.Verify(menu, settings);
}

[Fact]
public async Task FullGrouped()
{
await using var tracker = new RecordingTracker();
tracker.AddDelete(file1);
tracker.AddDelete("bar.txt");
tracker.AddDelete("file2.txt");
tracker.AddMove(file3, file3, "theExe", "theArguments", true, null);
tracker.AddMove(file4, "foo.txt", "theExe", "theArguments", true, null);
tracker.AddMove(file4, "file4.txt", "theExe", "theArguments", true, null);
var menu = MenuBuilder.Build(() => { }, () => { }, tracker);
await Verifier.Verify(menu, settings);
}
Expand Down
22 changes: 6 additions & 16 deletions src/DiffEngineTray/MenuBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,17 @@ static IEnumerable<ToolStripItem> BuildTrackingMenuItems(Tracker tracker)
.Distinct()
.ToList();

if (groups.Count == 1)
foreach (var group in groups)
{
foreach (var toolStripItem in BuildMovesAndDeletes(null, tracker, deletes, moves))
foreach (var toolStripItem in BuildMovesAndDeletes(
group,
tracker,
deletes.Where(x => x.Group == group).ToList(),
moves.Where(x => x.Group == group).ToList()))
{
yield return toolStripItem;
}
}
else
{
foreach (var group in groups)
{
foreach (var toolStripItem in BuildMovesAndDeletes(
group,
tracker,
deletes.Where(x => x.Group == group).ToList(),
moves.Where(x => x.Group == group).ToList()))
{
yield return toolStripItem;
}
}
}

yield return new MenuButton($"Clear ({count})", tracker.Clear, Images.Clear);
yield return new MenuButton($"Accept all ({count})", tracker.AcceptAll, Images.AcceptAll);
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649</NoWarn>
<Version>6.1.0</Version>
<Version>6.1.1</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>Testing, Snapshot, Diff, Compare</PackageTags>
<Description>Launches diff tools based on file extensions. Designed to be consumed by snapshot testing libraries.</Description>
Expand Down

0 comments on commit 0374f06

Please sign in to comment.