Skip to content

Instantly share code, notes, and snippets.

@antonfirsov
Created January 19, 2020 23:07
Show Gist options
  • Save antonfirsov/a699db2d8ce9d9671b5b32c558b71604 to your computer and use it in GitHub Desktop.
Save antonfirsov/a699db2d8ce9d9671b5b32c558b71604 to your computer and use it in GitHub Desktop.
Rewrite SixLabors.Core History
private const string RepoPath = @"[...]\Core\.git\";
private static string FixCommitMessage(string m)
{
return "[SL.Core] " + m.Replace("#", "SixLabors/Core#");
}
static void Main(string[] args)
{
using var repo = new Repository(RepoPath);
Branch branch = repo.Branches.First(b => b.FriendlyName == "af/prepare-migration");
var rewriteOptions = new RewriteHistoryOptions()
{
CommitHeaderRewriter = c => new CommitRewriteInfo()
{
Author = c.Author,
Committer = c.Committer,
Message = FixCommitMessage(c.Message)
}
};
string[] tags = repo.Tags.Select(t => t.CanonicalName).ToArray();
foreach (string t in tags)
{
repo.Tags.Remove(t);
}
repo.Refs.RewriteHistory(rewriteOptions, branch.Commits);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment