Skip to content

fix(push): remove a carry folder the copy failed before any reset left - #1916

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
Walternater:fix/carry-cleanup
Nov 21, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
Walternater:fix/carry-cleanup

Conversation

@Walternater

Copy link
Copy Markdown
Collaborator

Summary

Fixes the fourth of the five bugs in #1880. carryWorkingTree copies the team clone's uncommitted changes to teamai-push-carry-* and then resets. One catch handled a copy failure as if the reset had run: it kept the folder and warned that those copies were the only source — when nothing had been reset and the originals were still in the working tree. Each failed push left another folder, and the warning pointed at an incomplete copy.

A failure before the reset now removes the folder and says the changes are where they were. A failure from the reset on keeps today's warning and the copies, since the reset may already have discarded the originals.

Type of Change

  • Bug fix (non-breaking change that fixes a bug)

What changed

  • src/utils/git.ts — carryWorkingTree records when the reset starts. Before it: remove the temp folder and throw with the copy error as the cause. From it on: the existing warning and the kept copies.
  • src/__tests__/git-carry-failure-1880.test.ts — a real git repo, with copyRegularTree mocked to fail, asserting both halves of the outcome.

Test plan

  • New test, on main: npx vitest run src/__tests__/git-carry-failure-1880.test.ts → fails; the rejection is the raw Cannot copy a FIFO pipe, with no "nothing was reset" and the temp folder left behind.
  • After the change: passes. It asserts the member's edit is byte-identical (the reset never ran) and that no teamai-push-carry-* folder was added to TMPDIR.
  • git-carry-failure-1880 + git-checkout-credentials + push-team-config + git-env: 24/24. npx tsc --noEmit clean, npm run lint passes.

Real CLI, happy path (20261116T121017-f2a987, build 642a2b18): a pending teamai.yaml edit, then teamai push --branch review/ok → ✔ Pushed branch review/ok. The carry ran to completion and left nothing behind, so the new path does not fire when nothing fails.

What I could not reproduce in a world. The issue's own trigger — a TMPDIR long enough that mkdtemp succeeds and the copy's path exceeds the limit — cannot be built there: with the verifier's own path prefix under it, mkdtemp fails first (ENAMETOOLONG: … mkdtemp '/tmp/xxx…/teamai-push-carry-…'), which is a failure before the function is entered and proves nothing. The FIFO variant blocks git add on the reader side and hangs the run. So the failing path is proved at unit level only, with the copy mocked; the real-CLI record above covers the path that must not change.

Hit every surface

  • Entry points: teamai push --branch is the only caller of prepareExplicitBranch; plain push does not carry.
  • Scopes and team repo modes: the carry runs in the team clone, which every scope and mode shares; http teams are read-only and never push.
  • Reverse states: the change removes a folder that used to be left; nothing new is left in either branch.
  • Runs: the second run is the point — a second failed push used to add a second folder, and no longer does.
  • OS: macOS local, Linux and Windows in CI. No path arithmetic changed.

Notes for reviewers

Disclosure

Implemented with AI assistance (Claude Code); every line reviewed and tested by the author.

`carryWorkingTree` copies the team clone's uncommitted changes to
`teamai-push-carry-*` and then resets. One `catch` handled a copy failure as if
the reset had run: it kept the folder and warned that the copies were the only
source, when the originals were still in the working tree. Every failed push
left another folder, and the warning pointed at an incomplete copy.

A failure before the reset now removes the folder and says nothing was reset. A
failure from the reset on keeps today's warning and the copies, since the reset
may already have discarded the originals.

Co-Authored-By: Claude Code <[email protected]>
@jeff-r2026 jeff-r2026 self-assigned this Nov 18, 2026
@github-actions

Copy link
Copy Markdown

No findings in the specified diff.

The change removes partial copies only before reset starts and preserves the existing recovery behavior once reset may have discarded originals.

The PR description meets the testing requirement: it records a representative real-CLI run, regression tests, type checking, and lint, and explicitly discloses that the copy-failure path was verified only at unit level.

Review was read-only; no PR code was run, built, or installed.

@STiFLeR7 STiFLeR7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified head 642a2b1 on native Windows with Node 24.11.0.

All 24 tests across git-carry-failure-1880, git-checkout-credentials, push-team-config, and git-env passed with retries disabled. Replacing src/utils/git.ts with the parent implementation made the copy-failure regression fail with the raw copy error and a retained carry folder. Restoring the patch returned the regression to passing.

I read the diff and branch-preparation callers. The resetStarted flag distinguishes copies that can be discarded before reset from recovery copies that must be kept after reset starts. No blocking findings from this review.

The failure-path test injects the copy error. I did not reproduce the filesystem failure through the real CLI.

@Walternater

Copy link
Copy Markdown
Collaborator Author

Status check on head 642a2b18: the full check suite is green (19/19 plus the docs-only skip), STiFLeR7's run above found no blocking findings on native Windows with a negative control, and there are no unresolved review threads. Nothing is pending on my side.

Not bumping for urgency — this is ready for a maintainer look whenever it reaches the front of the queue. I am holding further work in this area until it lands so the copies stay independent.

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated PR #1916 at 642a2b1 integrated with main 2a79857: npm ci --ignore-scripts, typecheck, lint, build, focused tests (src/tests/git-carry-failure-1880.test.ts, retry 0), and built CLI --version passed. Existing representative real-CLI records and review comments checked. Approved for squash as requested by jeffyxu.

@jeff-r2026
jeff-r2026 merged commit d861799 into Tencent:main Nov 21, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants