Created
May 5, 2022 21:13
-
-
Save ckorn/6e9acc6001d3fb09fbd5ed20d1e826a5 to your computer and use it in GitHub Desktop.
Git commit changes
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
// 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", "[email protected]", DateTimeOffset.Now), | |
new LibGit2Sharp.Signature("sdfsdf", "[email protected]", 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