LibGit2Sharp get repository changes after pull

2019-08-12 07:55发布

How can i get the following information after a git-pull with libgit2sharp:

  1. Which files has been moved
  2. Which files has been created
  3. Which files has been deleted

The git-pull request it self works perfectly:

var result = repo.Network.Pull(new LibGit2Sharp.Signature("admin", "mail@......net", new DateTimeOffset(DateTime.Now)), options);

I already looked at the result of the Pull-Method, but this seems not to contain the needed information.

Thank you very much!

1条回答
仙女界的扛把子
2楼-- · 2019-08-12 08:46

The MergeResult type exposes a Commit property which is not null when the merge was successful.

In order to find out what files have changed, one just have to leverage the repo.Diff.Compare() method to compare this Commit with its first parent.

查看更多
登录 后发表回答