Created
January 19, 2020 23:07
-
-
Save antonfirsov/a699db2d8ce9d9671b5b32c558b71604 to your computer and use it in GitHub Desktop.
Rewrite SixLabors.Core History
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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