Skip to content

Instantly share code, notes, and snippets.

@KillerGoldFisch
Last active November 4, 2020 18:05
Show Gist options
  • Save KillerGoldFisch/2f8b15f93d844e3d3cbc5e1f2363d795 to your computer and use it in GitHub Desktop.
Save KillerGoldFisch/2f8b15f93d844e3d3cbc5e1f2363d795 to your computer and use it in GitHub Desktop.
Reverts all file chenges witch only whitespace changes in a repo
#r "nuget:GCore/1.1.2.42"
#r "nuget:LibGit2Sharp/0.26.2"
using System;
using System.IO;
using System.Linq;
using GCore.Extensions.StringShEx;
using LibGit2Sharp;
var repoPath = @"D:\prog\repo";
var repo = new Repository(repoPath);
using (var changes = repo.Diff.Compare<Patch>()){
foreach(var ch in changes.Where( c => c.Status == ChangeKind.Modified && (c.LinesAdded == 0 && c.LinesDeleted == 0) && c.IsBinaryComparison == false)) {
Console.WriteLine(ch.Path);
$"git checkout -- {ch.Path}".Sh(@"D:\prog\tw\LoopAuditioneer");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment