Подтвердить что ты не робот

Как обнаружить ожидающие изменения в libgit2sharp?

В libgit2sharp https://github.com/libgit2/libgit2sharp/ как вы можете проверить отложенные/незафиксированные изменения?

4b9b3361

Ответ 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);
}