Sim*_*mon 16 .net c# libgit2sharp
在libgit2sharp中https://github.com/libgit2/libgit2sharp/如何检查待处理/未提交的更改?
use*_*302 16
以下适用于我:
public bool HasUncommittedChanges
{
get
{
using (var repo = new Repository(repositoryRoot))
{
RepositoryStatus status = repo.RetrieveStatus();
return status.IsDirty;
}
}
}
Run Code Online (Sandbox Code Playgroud)
您可以使用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)
Run Code Online (Sandbox Code Playgroud)
完全不经过任何路径都应该进行所有更改。
小智 5
以下代码行将提供文件名和该文件的状态。
foreach (var item in repo1.RetrieveStatus())
{
Console.WriteLine(item.FilePath);
Console.WriteLine(item.State);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3625 次 |
| 最近记录: |