fix: preserve dev branch upstream after fallback · openclaw/openclaw@34f2446
shakkernerd
·
2026-06-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -567,6 +567,9 @@ describe("runGatewayUpdate", () => {
|
567 | 567 | if (key === `git -C ${tempDir} checkout -B main ${selectedSha}`) { |
568 | 568 | return { stdout: "", stderr: "", code: 0 }; |
569 | 569 | } |
| 570 | +if (key === `git -C ${tempDir} branch --set-upstream-to origin/main main`) { |
| 571 | +return { stdout: "", stderr: "", code: 0 }; |
| 572 | +} |
570 | 573 | return { stdout: "", stderr: "", code: 0 }; |
571 | 574 | }; |
572 | 575 | |
@@ -580,6 +583,7 @@ describe("runGatewayUpdate", () => {
|
580 | 583 | expect(calls).toContain(`git -C ${tempDir} rev-parse refs/remotes/origin/main`); |
581 | 584 | expect(calls).toContain(`git -C ${tempDir} show-ref --verify refs/heads/main`); |
582 | 585 | expect(calls).toContain(`git -C ${tempDir} checkout -B main ${selectedSha}`); |
| 586 | +expect(calls).toContain(`git -C ${tempDir} branch --set-upstream-to origin/main main`); |
583 | 587 | expect(calls).not.toContain(`git -C ${tempDir} checkout main`); |
584 | 588 | expect(calls).not.toContain(`git -C ${tempDir} rebase ${upstreamSha}`); |
585 | 589 | const cleanupIndex = calls.findIndex( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -931,6 +931,7 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
|
931 | 931 | } |
932 | 932 | let preflightBaseSha: string | null; |
933 | 933 | let candidatesLocal: string[]; |
| 934 | +let selectedDevUpstream: string | null = null; |
934 | 935 | if (devTargetRef) { |
935 | 936 | let targetSha: string | null = null; |
936 | 937 | for (const targetRefCandidate of buildDevTargetRefResolutionCandidates(devTargetRef)) { |
@@ -1040,6 +1041,8 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
|
1040 | 1041 | const candidateSha = upstreamShaStep.stdoutTail?.trim(); |
1041 | 1042 | if (upstreamShaStep.exitCode === 0 && candidateSha) { |
1042 | 1043 | upstreamSha = candidateSha; |
| 1044 | +const remoteBranchMatch = /^refs\/remotes\/(.+)$/u.exec(upstreamRef); |
| 1045 | +selectedDevUpstream = remoteBranchMatch?.[1] ?? null; |
1043 | 1046 | break; |
1044 | 1047 | } |
1045 | 1048 | if (upstreamShaStep.exitCode === 0) { |
@@ -1327,6 +1330,24 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
|
1327 | 1330 | return failure; |
1328 | 1331 | } |
1329 | 1332 | checkedOutSelectedSha = localMainStep.exitCode !== 0; |
| 1333 | +if (checkedOutSelectedSha && selectedDevUpstream) { |
| 1334 | +const upstreamFailure = await runRequiredGitStep( |
| 1335 | +`git branch --set-upstream-to ${selectedDevUpstream} ${DEV_BRANCH}`, |
| 1336 | +[ |
| 1337 | +"git", |
| 1338 | +"-C", |
| 1339 | +gitRoot, |
| 1340 | +"branch", |
| 1341 | +"--set-upstream-to", |
| 1342 | +selectedDevUpstream, |
| 1343 | +DEV_BRANCH, |
| 1344 | +], |
| 1345 | +"checkout-failed", |
| 1346 | +); |
| 1347 | +if (upstreamFailure) { |
| 1348 | +return upstreamFailure; |
| 1349 | +} |
| 1350 | +} |
1330 | 1351 | } |
1331 | 1352 | if (checkedOutSelectedSha) { |
1332 | 1353 | steps.push({ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。