Don't fail silently on server side git push rejections#6182
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves error reporting for git push operations in Darc’s LibGit2Sharp-based client so that server-side push rejections (e.g., protected branch / hook declined) no longer fail silently, addressing #6181.
Changes:
- Add
PushOptions.OnPushStatusErrorhandling to surface server-side push status errors as exceptions duringPush.
| OnPushStatusError = error => | ||
| { | ||
| throw new LibGit2SharpException($"Failed to push {error.Reference}: {error.Message}"); | ||
| } |
There was a problem hiding this comment.
OnPushStatusError throws LibGit2SharpException, which will be treated as retryable by the _exponentialRetry predicate (ex is LibGit2SharpException). For server-side rejections (e.g., protected branch/hook declined), retrying is unlikely to succeed and may just add delay/log noise. Consider throwing a distinct exception type for push rejections (or narrowing the retry predicate) so only transient transport failures are retried; also consider including the remote URL/refspec in the exception message to aid diagnostics.
There was a problem hiding this comment.
that's fair, will turn it to a DarcException
This makes it so we don't fail silently on server side rejections. Previously we were only getting transport related errors
#6181