I would like to use libgit2sharp to achieve git pull --tags
.
If I try to do a pull like this:
repo.Network.Pull(new Signature("name", "[email protected]", new DateTimeOffset()), new PullOptions());
then I get the new commits but not the new tags which are pointing to these commits.
I tried to use PullOptions
to modify the behaviour like this:
var sig = new Signature("name", "[email protected]", new DateTimeOffset());
var opts = new PullOptions{ FetchOptions = new FetchOptions {TagFetchMode = TagFetchMode.All} };
repo.Network.Pull(sig, opts);
This throws the following exception:
LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/master' doesn't match the destination
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteSafeHandle remote, Signature signature, String logMessage)
at LibGit2Sharp.Network.DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, Signature signature, String logMessage)
at LibGit2Sharp.Network.Fetch(Remote remote, FetchOptions options, Signature signature, String logMessage)
at LibGit2Sharp.Network.Pull(Signature merger, PullOptions options)
Any ideas?
Stangely, I can't find any --tags
option in the latest official git documentation.
However, in LibGit2Sharp you can perform the equivalent git fetch --all
using the following code (or one of the other .Fetch()
overloads):
repo.Network.Fetch(remote, new FetchOptions { TagFetchMode = TagFetchMode.All });
The current tip of LibGit2Sharp vNext
branch doesn't cringe with this code. However, as seen in the issue you've raised, version v0.20.x does indeed throws.
v0.21 will fix this issue.