Repository navigation
fix(push): give every push branch a name nothing has yet - #1759
Conversation
Two `teamai remove` runs within one second fail the second one:
✖ Git push failed: fatal: a branch named 'teamai/push/…' already exists
`generateBranchName` stamps the name to the second, and `pushRepoBranch`
leaves that branch behind on its success path — `checkoutMaster` only
switches away. So the second run's `checkoutLocalBranch` throws.
`unusedBranchName` exists for exactly this, and its comment says so, but
only `push.ts` and `maintenance/promotion-publish.ts` used it. The four
other call sites that create a push branch — `remove`, `manifest-edit`,
the team-config push and `autoPushViaMR` — now use it too.
This is what made `git-exclude-delivered-915.test.ts` fail on CI shard
3/3 of Tencent#1756: that case removes a skill and then a rule.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
No findings in the scoped diff. The changes consistently replace generated branch names with The PR description documents sufficient testing: one representative built-CLI E2E run (54 tests passed), targeted unit tests, type checking, and lint. No additional provider × agent matrix is required. I only read the requested diff; I did not run, build, or install anything. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Approving 1d27f7fc. It fixes #1758. We built this head, the merge-base and current main, and froze the CLI clock so two teamai remove runs fell in the same second. On the merge-base and on main, the second run exits 1 with a branch named 'teamai/push/<user>/<stamp>' already exists. On this head both runs exit 0, on <stamp> and <stamp>-2. Main still has the four call sites that use generateBranchName directly, so main does not already fix this. No other open PR touches these files.
The exit code changes only for a run that used to fail, so we read it as a bug fix, not a breaking change.
Non-blocking:
- [P2 non-blocking] There is no
CHANGELOG.mdline under Bug Fixes. Recent fixes add one, and this one is visible to anyone who runs two removals or role edits back to back. - [P3 nit] The new test comment at
src/__tests__/remove-command.test.ts:286cites #1740, an unrelated benchmark PR. #1756 is probably the one meant.
Only remove was run on the built CLI. The roles/projects edits, the teamai.yaml-only push and the import flows changed the same way and are covered by unit tests.
The CI review (#1759 (comment)) reports no findings. We agree. CI is green at this head.
…sue in its test SaulMoro's review of Tencent#1759 asked for both: the Bug Fixes line recent fixes carry, and the test comment cited Tencent#1740, an unrelated benchmark PR. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Both non-blocking points are in [P2] CHANGELOG — added under Unreleased → 🐛 Bug Fixes, naming the four call sites and the
I put it under Bug Fixes rather than Breaking Changes, matching your reading that the exit code only changes for a run that used to fail. [P3] the comment — right, CI is green again at |
Problem
Two
teamai removeruns within the same second fail the second one:generateBranchName(src/utils/git.ts:1219) stamps a name to the second, andpushRepoBranchleaves that branch behind on its success path —checkoutMasteronly switches away. So the second run'sgit.checkoutLocalBranch(<same name>)throws.The repo already has
unusedBranchNamefor exactly this. Its doc comment says it: "Names are per second: a push that opens two PRs, or follows another within the second, would otherwise reuse one and fail." But onlypush.ts:917andpromotion-publish.tsused it. Four call sites that create a push branch did not.This is what made
git-exclude-delivered-915.test.tsfail on CI shard 3/3 of #1756: that case removes a skill and then a rule, back to back.Change
The four call sites now use
unusedBranchName, which returns the generated name or the first free-2,-3… of it:src/remove.ts—teamai removesrc/manifest-edit.ts—roles/projectsadd, update and removesrc/push.ts(pushTeamConfigOnly) — a push whose only change isteamai.yamlsrc/utils/git.ts(autoPushViaMR) — the import flowsEach already had the repo path in scope, and each is already
async.Test mocks that replace
../utils/git.jsgainedunusedBranchName;manifest-edit.test.tsspreads the real module, so it needed the entry to stop the real one running against a fake path.Tests
New, in
remove-command.test.ts— the removal pushes onto whatever free nameunusedBranchNameanswers, not the second-stamped one:Without the change the case fails — the name comes from
generateBranchNameandunusedBranchNameis never called:unusedBranchName's own behaviour — the free name, the-2/-3suffix, and falling back when git cannot list branches — is already covered ingit.test.ts.Real CLI: the E2E file CI failed on, run whole against the built CLI:
Push, remove, rules, manifest, roles, import, init and git unit tests: 820 passed across 37 files.
tsc --noEmitandnpm run lintpass.Related Issues
Fixes #1758
Limitations
push.tshas always had.generateBranchNamestays exported and unchanged —unusedBranchNamecalls it.🤖 Generated with Claude Code