


























@@ -737,11 +737,11 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
737737 steps,
738738durationMs: Date.now() - startedAt,
739739});
740-const runGitCheckoutOrFail = async (name: string, argv: string[]) => {
741-const checkoutStep = await runStep(step(name, argv, gitRoot));
742-steps.push(checkoutStep);
743-if (checkoutStep.exitCode !== 0) {
744-return buildGitErrorResult("checkout-failed");
740+const runRequiredGitStep = async (name: string, argv: string[], reason: string) => {
741+const gitStep = await runStep(step(name, argv, gitRoot));
742+steps.push(gitStep);
743+if (gitStep.exitCode !== 0) {
744+return buildGitErrorResult(reason);
745745}
746746return null;
747747};
@@ -770,22 +770,24 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
770770771771if (channel === "dev") {
772772if (needsCheckoutMain) {
773-const failure = await runGitCheckoutOrFail(`git checkout ${DEV_BRANCH}`, [
774-"git",
775-"-C",
776-gitRoot,
777-"checkout",
778-DEV_BRANCH,
779-]);
773+const failure = await runRequiredGitStep(
774+`git checkout ${DEV_BRANCH}`,
775+["git", "-C", gitRoot, "checkout", DEV_BRANCH],
776+"checkout-failed",
777+);
780778if (failure) {
781779return failure;
782780}
783781}
784782785-const fetchStep = await runStep(
786-step("git fetch", ["git", "-C", gitRoot, "fetch", "--all", "--prune", "--tags"], gitRoot),
783+const fetchFailure = await runRequiredGitStep(
784+"git fetch",
785+["git", "-C", gitRoot, "fetch", "--all", "--prune", "--tags"],
786+"fetch-failed",
787787);
788-steps.push(fetchStep);
788+if (fetchFailure) {
789+return fetchFailure;
790+}
789791let preflightBaseSha: string | null = null;
790792let candidates: string[] = [];
791793if (devTargetRef) {
@@ -1091,14 +1093,11 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
10911093}
1092109410931095if (devTargetRef) {
1094-const failure = await runGitCheckoutOrFail(`git checkout ${selectedSha}`, [
1095-"git",
1096-"-C",
1097-gitRoot,
1098-"checkout",
1099-"--detach",
1100-selectedSha,
1101-]);
1096+const failure = await runRequiredGitStep(
1097+`git checkout ${selectedSha}`,
1098+["git", "-C", gitRoot, "checkout", "--detach", selectedSha],
1099+"checkout-failed",
1100+);
11021101if (failure) {
11031102return failure;
11041103}
@@ -1133,20 +1132,13 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
11331132}
11341133}
11351134} else {
1136-const fetchStep = await runStep(
1137-step("git fetch", ["git", "-C", gitRoot, "fetch", "--all", "--prune", "--tags"], gitRoot),
1135+const fetchFailure = await runRequiredGitStep(
1136+"git fetch",
1137+["git", "-C", gitRoot, "fetch", "--all", "--prune", "--tags"],
1138+"fetch-failed",
11381139);
1139-steps.push(fetchStep);
1140-if (fetchStep.exitCode !== 0) {
1141-return {
1142-status: "error",
1143-mode: "git",
1144-root: gitRoot,
1145-reason: "fetch-failed",
1146-before: { sha: beforeSha, version: beforeVersion },
1147- steps,
1148-durationMs: Date.now() - startedAt,
1149-};
1140+if (fetchFailure) {
1141+return fetchFailure;
11501142}
1151114311521144const tag = await resolveChannelTag(runCommand, gitRoot, timeoutMs, channel);
@@ -1162,14 +1154,11 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
11621154};
11631155}
116411561165-const failure = await runGitCheckoutOrFail(`git checkout ${tag}`, [
1166-"git",
1167-"-C",
1168-gitRoot,
1169-"checkout",
1170-"--detach",
1171-tag,
1172-]);
1157+const failure = await runRequiredGitStep(
1158+`git checkout ${tag}`,
1159+["git", "-C", gitRoot, "checkout", "--detach", tag],
1160+"checkout-failed",
1161+);
11731162if (failure) {
11741163return failure;
11751164}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。