В libgit2sharp https://github.com/libgit2/libgit2sharp/ как вы можете проверить отложенные/незафиксированные изменения?
Как обнаружить ожидающие изменения в libgit2sharp?
Ответ 1
Для меня работает следующее:
public bool HasUncommittedChanges
{
get
{
using (var repo = new Repository(repositoryRoot))
{
RepositoryStatus status = repo.RetrieveStatus();
return status.IsDirty;
}
}
}
Ответ 2
Вы можете использовать repository.Diff.Compare()
.
/// <summary>
/// Show changes between the working directory and the index.
/// </summary>
/// <param name = "paths">The list of paths (either files or directories) that should be compared.</param>
/// <returns>A <see cref = "TreeChanges"/> containing the changes between the working directory and the index.</returns>
public virtual TreeChanges Compare(IEnumerable<string> paths = null)
Передача каких-либо путей вообще должна давать все изменения.
Ответ 3
Следующие строки кода предоставят имя файла и состояние этого файла.
foreach (var item in repo1.RetrieveStatus())
{
Console.WriteLine(item.FilePath);
Console.WriteLine(item.State);
}