Pallavi Sah
Pallavi Sah

Reputation: 1

Not able to get the OnPushError handler triggered with libgit2sharp

We are using the libgit2sharp library to run git commands on a repository and when there is a remote failure on pushing the git commit, the OnPushError handler doesn't get triggered.


using (var repo = new Repository(location))
{
     var branch = repo.Branches["main"];
     LibGit2Sharp.PushOptions options = new LibGit2Sharp.PushOptions();
     options.CredentialsProvider = new UsernamePasswordCredentials();
     options.OnPushStatusError = (pushStatusErrors) =>
     {
         foreach (var error in pushStatusErrors.AsList())
         {
             Console.WriteLine($"Push status error: {error.Reference} - {error.Message}");
         }
     };
     repo.Network.Push(branch, options);
};

Expected the handler to get triggered.

Upvotes: 0

Views: 7

Answers (0)

Related Questions