Skip to content

Commit 5f17833

Browse files
committed
Unify exit code field name: rename ExecuteGitResult.code to .exitCode
Rename the `code` field in `ExecuteGitResult` to `exitCode` to match `VcsProcessOutput.exitCode`, eliminating the naming inconsistency across the same abstraction boundary. Both interfaces now use `exitCode` for the process exit code, preventing future bugs from field name confusion.
1 parent 7d7a18e commit 5f17833

5 files changed

Lines changed: 31 additions & 31 deletions

File tree

apps/server/src/git/GitManager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function runGit(
224224
allowNonZeroExit,
225225
});
226226
return {
227-
code: result.code,
227+
code: result.exitCode,
228228
stdout: result.stdout,
229229
stderr: result.stderr,
230230
};

apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.
88
const processResult = (stdout: string) => ({
99
stdout,
1010
stderr: "",
11-
code: 0,
11+
exitCode: 0,
1212
signal: null,
1313
timedOut: false,
1414
stdoutTruncated: false,

apps/server/src/sourceControl/SourceControlProviderRegistry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const make = Effect.fn("makeSourceControlProviderRegistry")(function* ()
8989
})
9090
.pipe(
9191
Effect.map((result) =>
92-
result.code === 0 ? firstRemoteUrlFromVerboseOutput(result.stdout) : null,
92+
result.exitCode === 0 ? firstRemoteUrlFromVerboseOutput(result.stdout) : null,
9393
),
9494
Effect.mapError((error) => providerDetectionError("detectProvider", cwd, error)),
9595
));

apps/server/src/vcs/GitVcsDriver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface ExecuteGitInput {
3535
}
3636

3737
export interface ExecuteGitResult {
38-
readonly code: number;
38+
readonly exitCode: number;
3939
readonly stdout: string;
4040
readonly stderr: string;
4141
readonly stdoutTruncated: boolean;

apps/server/src/vcs/GitVcsDriverCore.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
693693
}
694694

695695
return {
696-
code: exitCode,
696+
exitCode,
697697
stdout: stdout.text,
698698
stderr: stderr.text,
699699
stdoutTruncated: stdout.truncated,
@@ -761,7 +761,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
761761
...(options.progress ? { progress: options.progress } : {}),
762762
}).pipe(
763763
Effect.flatMap((result) => {
764-
if (options.allowNonZeroExit || result.code === 0) {
764+
if (options.allowNonZeroExit || result.exitCode === 0) {
765765
return Effect.succeed(result);
766766
}
767767
const stderr = result.stderr.trim();
@@ -778,7 +778,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
778778
operation,
779779
cwd,
780780
args,
781-
`${commandLabel(args)} failed: code=${result.code ?? "null"}`,
781+
`${commandLabel(args)} failed: code=${result.exitCode ?? "null"}`,
782782
),
783783
);
784784
}),
@@ -823,7 +823,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
823823
allowNonZeroExit: true,
824824
timeoutMs: 5_000,
825825
},
826-
).pipe(Effect.map((result) => result.code === 0));
826+
).pipe(Effect.map((result) => result.exitCode === 0));
827827

828828
const resolveAvailableBranchName = Effect.fn("resolveAvailableBranchName")(function* (
829829
cwd: string,
@@ -939,7 +939,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
939939
{ allowNonZeroExit: true },
940940
).pipe(
941941
Effect.map((result) => {
942-
if (result.code !== 0) {
942+
if (result.exitCode !== 0) {
943943
return null;
944944
}
945945
return parseDefaultBranchFromRemoteHeadRef(result.stdout, remoteName);
@@ -958,12 +958,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
958958
{
959959
allowNonZeroExit: true,
960960
},
961-
).pipe(Effect.map((result) => result.code === 0));
961+
).pipe(Effect.map((result) => result.exitCode === 0));
962962

963963
const originRemoteExists = (cwd: string): Effect.Effect<boolean, GitCommandError> =>
964964
executeGit("GitVcsDriver.originRemoteExists", cwd, ["remote", "get-url", "origin"], {
965965
allowNonZeroExit: true,
966-
}).pipe(Effect.map((result) => result.code === 0));
966+
}).pipe(Effect.map((result) => result.exitCode === 0));
967967

968968
const listRemoteNames = (cwd: string): Effect.Effect<ReadonlyArray<string>, GitCommandError> =>
969969
runGitStdout("GitVcsDriver.listRemoteNames", cwd, ["remote"]).pipe(
@@ -1115,7 +1115,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
11151115
["rev-list", "--count", `${baseRef}..HEAD`],
11161116
{ allowNonZeroExit: true },
11171117
);
1118-
if (result.code !== 0) {
1118+
if (result.exitCode !== 0) {
11191119
return 0;
11201120
}
11211121

@@ -1140,7 +1140,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
11401140
);
11411141

11421142
const branchLastCommit = new Map<string, number>();
1143-
if (branchRecency.code !== 0) {
1143+
if (branchRecency.exitCode !== 0) {
11441144
return branchLastCommit;
11451145
}
11461146

@@ -1173,7 +1173,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
11731173
return NON_REPOSITORY_STATUS_DETAILS;
11741174
}
11751175

1176-
if (statusResult.code !== 0) {
1176+
if (statusResult.exitCode !== 0) {
11771177
const stderr = statusResult.stderr.trim();
11781178
return yield* createGitCommandError(
11791179
"GitVcsDriver.statusDetails.status",
@@ -1206,7 +1206,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
12061206
);
12071207
const statusStdout = statusResult.stdout;
12081208
const defaultBranch =
1209-
defaultRefResult.code === 0
1209+
defaultRefResult.exitCode === 0
12101210
? defaultRefResult.stdout.trim().replace(/^refs\/remotes\/origin\//, "")
12111211
: null;
12121212

@@ -1614,7 +1614,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
16141614
).pipe(
16151615
Effect.catchIf(isMissingGitCwdError, () =>
16161616
Effect.succeed({
1617-
code: 128,
1617+
exitCode: 128,
16181618
stdout: "",
16191619
stderr: "fatal: not a git repository",
16201620
stdoutTruncated: false,
@@ -1623,7 +1623,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
16231623
),
16241624
);
16251625

1626-
if (localBranchResult.code !== 0) {
1626+
if (localBranchResult.exitCode !== 0) {
16271627
const stderr = localBranchResult.stderr.trim();
16281628
if (stderr.toLowerCase().includes("not a git repository")) {
16291629
return {
@@ -1654,7 +1654,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
16541654
Effect.catch((error) =>
16551655
Effect.logWarning(
16561656
`GitVcsDriver.listRefs: remote refName lookup failed for ${input.cwd}: ${error.message}. Falling back to an empty remote refName list.`,
1657-
).pipe(Effect.as({ code: 1, stdout: "", stderr: "" })),
1657+
).pipe(Effect.as({ exitCode: 1, stdout: "", stderr: "" })),
16581658
),
16591659
);
16601660

@@ -1670,7 +1670,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
16701670
Effect.catch((error) =>
16711671
Effect.logWarning(
16721672
`GitVcsDriver.listRefs: remote name lookup failed for ${input.cwd}: ${error.message}. Falling back to an empty remote name list.`,
1673-
).pipe(Effect.as({ code: 1, stdout: "", stderr: "" })),
1673+
).pipe(Effect.as({ exitCode: 1, stdout: "", stderr: "" })),
16741674
),
16751675
);
16761676

@@ -1703,25 +1703,25 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
17031703
);
17041704

17051705
const remoteNames =
1706-
remoteNamesResult.code === 0 ? parseRemoteNames(remoteNamesResult.stdout) : [];
1707-
if (remoteBranchResult.code !== 0 && remoteBranchResult.stderr.trim().length > 0) {
1706+
remoteNamesResult.exitCode === 0 ? parseRemoteNames(remoteNamesResult.stdout) : [];
1707+
if (remoteBranchResult.exitCode !== 0 && remoteBranchResult.stderr.trim().length > 0) {
17081708
yield* Effect.logWarning(
1709-
`GitVcsDriver.listRefs: remote refName lookup returned code ${remoteBranchResult.code} for ${input.cwd}: ${remoteBranchResult.stderr.trim()}. Falling back to an empty remote refName list.`,
1709+
`GitVcsDriver.listRefs: remote refName lookup returned code ${remoteBranchResult.exitCode} for ${input.cwd}: ${remoteBranchResult.stderr.trim()}. Falling back to an empty remote refName list.`,
17101710
);
17111711
}
1712-
if (remoteNamesResult.code !== 0 && remoteNamesResult.stderr.trim().length > 0) {
1712+
if (remoteNamesResult.exitCode !== 0 && remoteNamesResult.stderr.trim().length > 0) {
17131713
yield* Effect.logWarning(
1714-
`GitVcsDriver.listRefs: remote name lookup returned code ${remoteNamesResult.code} for ${input.cwd}: ${remoteNamesResult.stderr.trim()}. Falling back to an empty remote name list.`,
1714+
`GitVcsDriver.listRefs: remote name lookup returned code ${remoteNamesResult.exitCode} for ${input.cwd}: ${remoteNamesResult.stderr.trim()}. Falling back to an empty remote name list.`,
17151715
);
17161716
}
17171717

17181718
const defaultBranch =
1719-
defaultRef.code === 0
1719+
defaultRef.exitCode === 0
17201720
? defaultRef.stdout.trim().replace(/^refs\/remotes\/origin\//, "")
17211721
: null;
17221722

17231723
const worktreeMap = new Map<string, string>();
1724-
if (worktreeList.code === 0) {
1724+
if (worktreeList.exitCode === 0) {
17251725
let currentPath: string | null = null;
17261726
for (const line of worktreeList.stdout.split("\n")) {
17271727
if (line.startsWith("worktree ")) {
@@ -1762,7 +1762,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
17621762
});
17631763

17641764
const remoteBranches =
1765-
remoteBranchResult.code === 0
1765+
remoteBranchResult.exitCode === 0
17661766
? remoteBranchResult.stdout
17671767
.split("\n")
17681768
.map(parseBranchLine)
@@ -1943,7 +1943,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
19431943
timeoutMs: 5_000,
19441944
allowNonZeroExit: true,
19451945
},
1946-
).pipe(Effect.map((result) => result.code === 0)),
1946+
).pipe(Effect.map((result) => result.exitCode === 0)),
19471947
executeGit(
19481948
"GitVcsDriver.switchRef.remoteExists",
19491949
input.cwd,
@@ -1952,7 +1952,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
19521952
timeoutMs: 5_000,
19531953
allowNonZeroExit: true,
19541954
},
1955-
).pipe(Effect.map((result) => result.code === 0)),
1955+
).pipe(Effect.map((result) => result.exitCode === 0)),
19561956
],
19571957
{ concurrency: "unbounded" },
19581958
);
@@ -1968,7 +1968,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
19681968
},
19691969
).pipe(
19701970
Effect.map((result) =>
1971-
result.code === 0
1971+
result.exitCode === 0
19721972
? parseTrackingBranchByUpstreamRef(result.stdout, input.refName)
19731973
: null,
19741974
),
@@ -1986,7 +1986,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
19861986
timeoutMs: 5_000,
19871987
allowNonZeroExit: true,
19881988
},
1989-
).pipe(Effect.map((result) => result.code === 0))
1989+
).pipe(Effect.map((result) => result.exitCode === 0))
19901990
: false;
19911991

19921992
const checkoutArgs = localInputExists

0 commit comments

Comments
 (0)