fix: clean up failed dev branch fallback · openclaw/openclaw@0599609
shakkernerd
·
2026-06-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -685,12 +685,16 @@ describe("runGatewayUpdate", () => {
|
685 | 685 | expect(calls).toContain(`git -C ${tempDir} reset --hard`); |
686 | 686 | expect(calls).toContain(`git -C ${tempDir} checkout --force feature`); |
687 | 687 | expect(calls).toContain(`git -C ${tempDir} reset --hard abc123`); |
| 688 | +expect(calls).toContain(`git -C ${tempDir} branch -D main`); |
688 | 689 | expect(calls.indexOf("beforeGitMutation")).toBeLessThan( |
689 | 690 | calls.indexOf(`git -C ${tempDir} checkout -B main ${selectedSha}`), |
690 | 691 | ); |
691 | 692 | expect( |
692 | 693 | calls.indexOf(`git -C ${tempDir} branch --set-upstream-to origin/main main`), |
693 | 694 | ).toBeLessThan(calls.indexOf(`git -C ${tempDir} reset --hard`)); |
| 695 | +expect(calls.indexOf(`git -C ${tempDir} reset --hard abc123`)).toBeLessThan( |
| 696 | +calls.indexOf(`git -C ${tempDir} branch -D main`), |
| 697 | +); |
694 | 698 | }); |
695 | 699 | |
696 | 700 | it("fetches only the requested tag for explicit dev tag target refs", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -819,6 +819,7 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
|
819 | 819 | const needsCheckoutMain = channel === "dev" && !devTargetRef && branch !== DEV_BRANCH; |
820 | 820 | gitTotalSteps = channel === "dev" ? (needsCheckoutMain ? 11 : 10) : 9; |
821 | 821 | let gitMutationPrepared = false; |
| 822 | +let createdDevBranchDuringUpdate = false; |
822 | 823 | const prepareGitMutation = async () => { |
823 | 824 | if (gitMutationPrepared) { |
824 | 825 | return; |
@@ -881,6 +882,16 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
|
881 | 882 | "--hard", |
882 | 883 | beforeSha, |
883 | 884 | ]); |
| 885 | +if (createdDevBranchDuringUpdate) { |
| 886 | +await appendRecoveryStep(`git rollback delete ${DEV_BRANCH}`, [ |
| 887 | +"git", |
| 888 | +"-C", |
| 889 | +gitRoot, |
| 890 | +"branch", |
| 891 | +"-D", |
| 892 | +DEV_BRANCH, |
| 893 | +]); |
| 894 | +} |
884 | 895 | } |
885 | 896 | return; |
886 | 897 | } |
@@ -892,6 +903,16 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
|
892 | 903 | "--detach", |
893 | 904 | beforeSha, |
894 | 905 | ]); |
| 906 | +if (createdDevBranchDuringUpdate) { |
| 907 | +await appendRecoveryStep(`git rollback delete ${DEV_BRANCH}`, [ |
| 908 | +"git", |
| 909 | +"-C", |
| 910 | +gitRoot, |
| 911 | +"branch", |
| 912 | +"-D", |
| 913 | +DEV_BRANCH, |
| 914 | +]); |
| 915 | +} |
895 | 916 | }; |
896 | 917 | const buildGitErrorResultWithRollback = async (reason: string): Promise<UpdateRunResult> => { |
897 | 918 | await rollbackGitCheckout(); |
@@ -1330,6 +1351,7 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
|
1330 | 1351 | return failure; |
1331 | 1352 | } |
1332 | 1353 | checkedOutSelectedSha = localMainStep.exitCode !== 0; |
| 1354 | +createdDevBranchDuringUpdate = checkedOutSelectedSha; |
1333 | 1355 | if (checkedOutSelectedSha && selectedDevUpstream) { |
1334 | 1356 | const upstreamFailure = await runRequiredGitStep( |
1335 | 1357 | `git branch --set-upstream-to ${selectedDevUpstream} ${DEV_BRANCH}`, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。