Reputation: 678
This is regarding API of libgit2sharp Remote Fixture.
I know how to Delete a branch from Remote using Push RefSpec. However, I wanna know how to do it using the API. I tried following example,
Repo.Network.Push(Repo.Network.Remotes["origin"], objectish: null, destinationSpec: branchName);
I provided correct branchName
(checked remote). However, I get,
Unhandled exception: System.ArgumentNullException: Value cannot be null. (Parameter 'objectish')
at LibGit2Sharp.Core.Ensure.ArgumentNotNull(Object argumentValue, String argumentName) in D:\git_ws\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 24
at LibGit2Sharp.Network.Push(Remote remote, String objectish, String destinationSpec) in D:\git_ws\libgit2sharp\LibGit2Sharp\Network.cs:line 273
related: https://github.com/libgit2/libgit2sharp/issues/466
How to properly call Repo.Network.Push
to delete a branch from remote.
Out of curiosity I also tried the example from RemoteFixture.cs
like this,
var remoteBranchName = "origin/" + branchName;
Repo.Branches.Remove(remoteBranchName, true);
This doesn't throw any error. However, it does nothing. Branch still exists on remote.
Thank you. :)
Upvotes: 0
Views: 463
Reputation: 1732
Can you use the Push method that just takes push refspecs?
public virtual void Push(
Remote remote,
string pushRefSpec,
PushOptions pushOptions)
The push refspec to delete references is described under the "Deleting references section here:
https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
and would be similar to:
:refs/heads/branch-to-delete
Upvotes: 1