Repository navigation
fix(import): fail when the push to the team repo fails instead of reporting a publish - #1541
Conversation
…orting a publish autoPushTeamRepo swallowed every push error as a warning, so import --dir printed 'Pushed to team knowledge repo' and exited 0 after a rejected push, and the unpushed commit was later dropped by the next teamai push/pull. It now throws a message with the next step; import's top-level handler prints it and exits 1. The claude-rules path reports completion only after the push. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…t line Satisfies preserve-caught-error and reports git's error:/fatal: line instead of the remote URL line git prints first. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
No findings in the specified PR diff. The PR description satisfies the testing requirement: it records a representative real-CLI run after Reviewed only the diff against the trusted base review rules; did not run, build, or install PR code. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@pcbeingused333 Thanks for taking #1539. With the built CLI at 63c6d852 against main (2fa1ab2f): when another member has pushed main first, main prints Pushed to team knowledge repo, exits 0 and leaves the docs off the remote. This branch exits 1, and after teamai pull, rerunning the import exits 0 and publishes the docs. The success path is unchanged. DetachedTeamRepoError still passes through unchanged (team-ref.test.ts:268). tsc, lint and your three unit files pass, and the new auto-push-team-repo.test.ts fails on main. One thing blocks approval:
-
[P1 blocking] The message drops the reason the push failed, and its advice is wrong when
mainis protected.autoPushTeamRepokeeps the firsterror:/fatal:line. For a rejected push that is always git's genericerror: failed to push some refs to '<url>'. The line that says why comes before it and is lost:! refs/heads/main:refs/heads/main [rejected] (fetch first), or[remote rejected] (pre-receive hook declined)plus the hook'sremote:lines. Main's warning showed them. With a pre-receive hook that refusesmain(one of the cases #1539 names):teamai import --dir ./svcprints✖ Push to the team repo failed: error: failed to push some refs to '<url>'. Run teamai pull, then rerun this command.and exits 1.teamai pullexits 0 and changes nothing.- Rerunning the import fails with the same message. The clone is now two commits ahead, and nothing is published.
The member is told to retry, with no cause shown, in a loop that can't succeed. Keep the
!line and anyremote:lines in the message, or print git's whole message as #1538 does for deep-enrich. Give theRun teamai pulladvice only forfetch first/ non-fast-forward rejections.
Non-blocking:
- [P3 nit] The new
import-dir.test.tscase also passes on main, becauseimportCmdalready exits 1 whenautoPushTeamReporejects. Onlyauto-push-team-repo.test.ts, against a real bare remote, separates main from this branch.
The iWiki import and --from-claude paths share autoPushTeamRepo. We read them (both now exit 1 on a failed push) but didn't run them. The gitlab/github providers, the other agents and Windows are left to CI. This merges cleanly with #1538, #1534, #1518, #1450 and #1379.
The CI review reported no findings. We agree the test record is enough, but it ran no code, so it couldn't see the protected-branch case.
… a pull only when main moved Signed-off-by: Alex Castillo <[email protected]>
|
Thanks for the careful read and for running it. Pushed a follow-up commit for the P1:
On the P3: agreed, the Disclosure: this change was prepared with an AI coding agent (Claude). |
|
No findings in the specified PR diff. The earlier review also reported no findings, so none require a resolution update. The PR description satisfies the testing requirement: it records a representative real-CLI run after Reviewed only the specified diff against the trusted base review rules. Did not run, build, or install PR code. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@pcbeingused333 Thanks, approving 203e1dce.
- The P1 is fixed. With the built CLI at this head and the same fixtures as before:
- When another member pushed
mainfirst, the import exits 1 with✖ Push to the team repo failed: ! refs/heads/main:refs/heads/main [rejected] (fetch first), git'serror:line andRun `teamai pull`, then rerun this command.. Following that,teamai pullrealigns the clone and the rerun publishes the docs (14 svc files on the remote). - With a pre-receive hook refusing
main, it exits 1 with[remote rejected] (pre-receive hook declined)andremote: main is protected, and gives no pull advice. - The success path is unchanged.
- When another member pushed
- Tests. The bare-remote test now covers both cases, and the hook case fails on the previous commit.
- Against current main.
203e1dcemerges cleanly with main atf7e11fe4.
The record in the body is from the earlier commit and doesn't show the hook case. The run above covers it. In the protected-main case the unpushed import commit stays in the clone, which is the branch-publishing question #1539 leaves to the maintainers. The CI review found nothing, and we agree.
#1543 fixes the same issue. With this one merged, we'll close it with thanks.
…orting a publish (Tencent#1541) teamai import --dir printed 'Pushed to team knowledge repo' and exited 0 when the push to the team repo was rejected, and the next push or pull dropped the unpushed import. autoPushTeamRepo now throws: the message keeps git's reason (the rejected ref line and the hook's remote: lines), and advises `teamai pull` only when main moved (fetch first or non-fast-forward). Import commands exit 1. Closes Tencent#1539.
Summary
teamai import --dirprintedPushed to team knowledge repoand exited 0 when the push to the team repo had been rejected (for example because another member pushed tomainfirst). The unpushed import commit was then dropped by the nextteamai push/teamai pull.autoPushTeamReponow throwsPush to the team repo failed: <git error line>. Run \teamai pull`, then rerun this command.;importCmd`'s existing handler prints it and exits 1.Type of Change
Test Plan
npx tsc --noEmitpassesnpm run lintpassesnpx vitest run src/__tests__/auto-push-team-repo.test.ts src/__tests__/import-dir.test.ts src/__tests__/team-ref.test.tspasses (56 tests); the full suite was not runauto-push-team-repo.test.ts(new, real bare remote and a second clone that pushesmainfirst; fails onmain) and a case inimport-dir.test.ts(noPushed.../import completeline, exit 1)Real-CLI run after
npm run build(isolatedHOME, team on a local bare repo reached throughurl.<local>.insteadOf,teamai init ... --provider git, then a second clone pushes to the teammain):Only the
gitprovider and the Claude agent were exercised;github/gitlaband the other agents are left to CI.Related Issues
Fixes #1539
Notes for Reviewers
autoPushTeamRepo(@deprecated) is also used by the iWiki import and the--from-claudepath, so they now also fail with exit 1 on a rejected push instead of carrying on; the--from-claudepath logsImport completeafter the push instead of before it.import --from-repodoes, changes how a team reviews the result and is left to the maintainers.This change was made with Claude Code (Claude Sonnet 5.5).