Added commit functionality to the git library

This commit is contained in:
2024-11-15 15:50:29 +00:00
parent 7c4909b485
commit da1028388a
2 changed files with 59 additions and 5 deletions
+18 -2
View File
@@ -50,8 +50,6 @@ namespace OmegaLeo.HelperLib.Git
allChanges.AddRange(changes.Deleted);
var uniqueFolderPaths = allChanges.Select(x => Path.GetDirectoryName(x.Path)).Distinct();
foreach (var path in uniqueFolderPaths)
{
@@ -97,5 +95,23 @@ namespace OmegaLeo.HelperLib.Git
return folder;
}
public void Commit(string message, Signature author)
{
if (HasChanges())
{
var changes = _repo.Diff.Compare<TreeChanges>();
var allChanges = new List<TreeEntryChanges>();
allChanges.AddRange(changes.Added);
allChanges.AddRange(changes.Modified);
allChanges.AddRange(changes.Deleted);
var filePaths = allChanges.Select(x => x.Path).Where(x => x.IsNotNullOrEmpty());
Commands.Stage(_repo, filePaths);
}
_repo.Commit(message, author, author);
}
}
}