Skip to content

Instantly share code, notes, and snippets.

@ckorn
Created May 5, 2022 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckorn/6e9acc6001d3fb09fbd5ed20d1e826a5 to your computer and use it in GitHub Desktop.
Save ckorn/6e9acc6001d3fb09fbd5ed20d1e826a5 to your computer and use it in GitHub Desktop.
Git commit changes
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
LibGit2Sharp.Repository.Init(@"C:\Viveport\tmp");
while (true)
{
using (LibGit2Sharp.Repository repository = new(@"C:\Viveport\tmp"))
{
foreach (var diff in repository.RetrieveStatus(new LibGit2Sharp.StatusOptions()))
{
Console.WriteLine($"{diff.State}: {diff.FilePath}");
switch (diff.State)
{
case LibGit2Sharp.FileStatus.NewInWorkdir:
case LibGit2Sharp.FileStatus.ModifiedInWorkdir:
repository.Index.Add(diff.FilePath);
break;
case LibGit2Sharp.FileStatus.DeletedFromWorkdir:
repository.Index.Remove(diff.FilePath);
break;
default:
throw new InvalidOperationException($"{diff.State}: {diff.FilePath}");
}
}
repository.Index.Write();
//LibGit2Sharp.Commands.Stage(repository, "*");
repository.Commit("AutoCommit", new LibGit2Sharp.Signature("sdfsdf", "sdfsdf@foo.bar", DateTimeOffset.Now),
new LibGit2Sharp.Signature("sdfsdf", "sdfsdf@foo.bar", DateTimeOffset.Now), new LibGit2Sharp.CommitOptions());
Console.ReadLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment