





























@@ -820,6 +820,7 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
820820gitTotalSteps = channel === "dev" ? (needsCheckoutMain ? 11 : 10) : 9;
821821let gitMutationPrepared = false;
822822let createdDevBranchDuringUpdate = false;
823+let localDevBranchExists: boolean | null = null;
823824const prepareGitMutation = async () => {
824825if (gitMutationPrepared) {
825826return;
@@ -1010,8 +1011,19 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
10101011preflightBaseSha = targetSha;
10111012candidatesLocal = [targetSha];
10121013} else {
1013-let remoteBranchRefs: string[] = [];
10141014if (needsCheckoutMain) {
1015+const localMainStep = await runStep(
1016+step(
1017+`git show-ref ${DEV_BRANCH}`,
1018+["git", "-C", gitRoot, "show-ref", "--verify", `refs/heads/${DEV_BRANCH}`],
1019+gitRoot,
1020+),
1021+);
1022+steps.push(localMainStep);
1023+localDevBranchExists = localMainStep.exitCode === 0;
1024+}
1025+let remoteBranchRefs: string[] = [];
1026+if (needsCheckoutMain && localDevBranchExists === false) {
10151027const remoteStep = await runStep(
10161028step("git remote", ["git", "-C", gitRoot, "remote"], gitRoot),
10171029);
@@ -1330,27 +1342,20 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
13301342await prepareGitMutation();
13311343let checkedOutSelectedSha = false;
13321344if (needsCheckoutMain) {
1333-const localMainStep = await runStep(
1334-step(
1335-`git show-ref ${DEV_BRANCH}`,
1336-["git", "-C", gitRoot, "show-ref", "--verify", `refs/heads/${DEV_BRANCH}`],
1337-gitRoot,
1338-),
1339-);
1340-steps.push(localMainStep);
1345+const hasLocalDevBranch = localDevBranchExists !== false;
13411346const failure = await runRequiredGitStep(
1342-localMainStep.exitCode === 0
1347+hasLocalDevBranch
13431348 ? `git checkout ${DEV_BRANCH}`
13441349 : `git checkout -B ${DEV_BRANCH} ${selectedSha}`,
1345-localMainStep.exitCode === 0
1350+hasLocalDevBranch
13461351 ? ["git", "-C", gitRoot, "checkout", DEV_BRANCH]
13471352 : ["git", "-C", gitRoot, "checkout", "-B", DEV_BRANCH, selectedSha],
13481353"checkout-failed",
13491354);
13501355if (failure) {
13511356return failure;
13521357}
1353-checkedOutSelectedSha = localMainStep.exitCode !== 0;
1358+checkedOutSelectedSha = !hasLocalDevBranch;
13541359createdDevBranchDuringUpdate = checkedOutSelectedSha;
13551360if (checkedOutSelectedSha && selectedDevUpstream) {
13561361const upstreamFailure = await runRequiredGitStep(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。