Repository navigation
Exit non-zero from sync when a push or pull request fails [patch] - #338
matt-edmondson wants to merge 1 commit into
Conversation
SyncService.RunAsync returned 0 once it reached the push phase, whatever happened there. PushToRemoteAsync only reported the repos it pushed, and the pull request opener only printed its failures, so `ktools sync --auto-push` exited 0 after a rejected push left the synced commits local. PushToRemoteAsync now returns the repos it failed to push alongside the ones it pushed, SyncPullRequestOpener.OpenAsync returns how many pull requests it could not open, and RunAsync lists the failures and exits 1 when there are any. Repos skipped for having no GitHub remote or no base branch still do not count as failures. Fixes #333 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW6DQQw6JpYVSCPgTzR
|
The The same three checks are red on I don't know of a fix I could bring into this PR. Dependabot's bump to 3.2.0 in #270 is also red, because 3.2.0 needs a Six Labors license in CI (the same problem as ktsu-dev/IconHelper#155). Deciding between a license, a pin with the advisory suppressed, or replacing ImageSharp is a maintainer call. Locally, with Generated by Claude Code |
Fixes #333
What was wrong
SyncService.RunAsyncalways returned 0 once it reached the push phase.PushToRemoteAsyncreturned only the repos it had pushed, andPushDirectoryAsyncandSyncPullRequestOpeneronly printed their failures. Soktools sync --auto-pushexited 0 after a failedgit pull, a rejected push, or a rejected pull request, and the synced commits stayed local without anyone noticing.The fix
PushToRemoteAsyncnow returns aPushResult(Pushed, Failed)record.Failedlists the repos whose pull or push failed.SyncPullRequestOpener.OpenAsync, andSyncService.OpenPullRequestsAsyncthrough it, now return the number of repos where opening a pull request failed. That covers agh pr createthat exits non-zero and an API create that returns nothing. As before, these are not counted as failures:ghand no tokenRunAsynclists the repos that failed to push and the number of pull requests that failed, then exits 1. Branches are still restored in thefinallybefore any of this, and one repo's failure still doesn't stop the remaining repos.Tests
RunAsyncExitsNonZeroWhenAnAutoPushFailscovers the issue's acceptance case. The workspace holds a real clone of a bare origin with one unpushed commit authored byKtsuTools, so--auto-pushfinds it pushable. The run uses a process service whosegit pull/git pushfail, and the test asserts exit 1. Withmain'sSyncService.cs, this test fails onAssert.AreEqual(1, exit), becausemainreturns 0.RunAsyncExitsZeroWhenEveryAutoPushSucceedsuses the same workspace with a successful pull and push. It asserts exit 0 and that the commands werepull, thenpush.PushToRemoteAsyncReportsARepoWhosePushFailedchecks that a rejected push lands inFailedand not inPushed.ghcreates return 2, a rejected API create returns 1, and a successful create returns 0.CI note
On
main, restore currently fails withNU1903: SixLabors.ImageSharp 3.1.12 has a known high-severity advisory. That failure is unrelated to this change, and it is the same one #337 and #334 report. To run the build and tests above locally, I passed-p:WarningsNotAsErrors=NU1903. This PR does not touch the ImageSharp reference, so CI will stay red on that step untilmainis fixed.Generated by Claude Code