I am new to libgit sharp library. I have a line of code that works with v0.15 of libgit sharp. I have updated the package to the latest version 0.22. Repository.Network.FetchHeads.FirstOrDefault()
FetchHeads is deprecated in v0.17 (https://github.com/libgit2/libgit2sharp/blob/master/CHANGES.md).
Here is the snippet that I want to rewrite
var latestRemoteHead = repo.Network.FetchHeads.FirstOrDefault();
if (latestRemoteHead != null){
var latestRemoteHeadCommit = (Commit)latestRemoteHead.Target;
repo.Reset(ResetMode.Hard, latestRemoteHeadCommit);
}
FetchHead
was indeed deprecated in commit c7e11bbff588c0f2b84b3f9dbdfaf2e5ef00cf91, as part of the Expand Merge API PR #643:Network.Fetchheads
,Repository.MergeHeads
as these should be internal only.Commit 35ea14d in April 2014 for libgit2sharp 0.18 set the FetchHead class as internal.
You would need to list all the remote branches and check their HEAD commits in order to get back what you had from FetchHeads.
As a first clue, see
LibGit2Sharp.Tests/TestHelpers/ExpectedFetchState.cs
to list thebranch.Tip.Id