mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-01 15:32:11 +08:00
Merge pull request #9326 from Kilo-Org/session/agent_2c82a4a6-c1b2-4601-bf4f-c24ff7ff753f
fix(cli): reduce publish race window by deferring git push and adding retry
This commit is contained in:
+25
-5
@@ -90,13 +90,33 @@ await $`bun install`
|
||||
await import(`../packages/sdk/js/script/build.ts`)
|
||||
|
||||
if (Script.release) {
|
||||
// kilocode_change start - commit and tag both release and rc version bumps
|
||||
// kilocode_change start - commit, tag, and push with rebase + retry to handle
|
||||
// concurrent merges to main. Rebase (instead of cherry-pick) handles
|
||||
// overlapping file changes cleanly, and the retry loop covers the narrow
|
||||
// window between fetch and push where another commit could land.
|
||||
await $`git commit -am "release: v${Script.version}"`
|
||||
await $`git tag v${Script.version}`
|
||||
await $`git fetch origin`
|
||||
await $`git cherry-pick HEAD..origin/main`.nothrow()
|
||||
await $`git push origin HEAD --tags --no-verify --force-with-lease`
|
||||
await new Promise((resolve) => setTimeout(resolve, 5_000))
|
||||
const retries = 3
|
||||
for (let i = 1; i <= retries; i++) {
|
||||
await $`git fetch origin main`
|
||||
const rebase = await $`git rebase origin/main`.nothrow()
|
||||
if (rebase.exitCode !== 0) {
|
||||
console.error(`rebase failed (attempt ${i}/${retries}), aborting rebase`)
|
||||
await $`git rebase --abort`.nothrow()
|
||||
if (i === retries)
|
||||
throw new Error("failed to rebase release commit onto origin/main after " + retries + " attempts")
|
||||
await new Promise((r) => setTimeout(r, 3_000))
|
||||
continue
|
||||
}
|
||||
const push = await $`git push origin HEAD:main --tags --no-verify --force-with-lease`.nothrow()
|
||||
if (push.exitCode === 0) {
|
||||
console.log("release commit pushed successfully")
|
||||
break
|
||||
}
|
||||
console.warn(`push rejected (attempt ${i}/${retries}), retrying...`)
|
||||
if (i === retries) throw new Error("failed to push release commit after " + retries + " attempts")
|
||||
await new Promise((r) => setTimeout(r, 3_000))
|
||||
}
|
||||
// kilocode_change end
|
||||
|
||||
// kilocode_change start
|
||||
|
||||
Reference in New Issue
Block a user