codex-relay 1.0.1-beta.0 → 1.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src2.js +20 -2
- package/package.json +1 -1
package/dist/src2.js
CHANGED
|
@@ -710,10 +710,15 @@ function createApp(options = {}) {
|
|
|
710
710
|
try {
|
|
711
711
|
const selectedWorkspacePath = await validateThreadWorkspacePath(workspacePath, parsed.data.workspacePath);
|
|
712
712
|
if (!selectedWorkspacePath.success) return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("invalid_workspace_path", selectedWorkspacePath.error), 400);
|
|
713
|
-
const
|
|
713
|
+
const branchExists = await localGitBranchExists(selectedWorkspacePath.path, parsed.data.branch);
|
|
714
|
+
const output = branchExists ? await git(selectedWorkspacePath.path, ["checkout", parsed.data.branch]) : await git(selectedWorkspacePath.path, [
|
|
715
|
+
"checkout",
|
|
716
|
+
"-b",
|
|
717
|
+
parsed.data.branch
|
|
718
|
+
]);
|
|
714
719
|
const response = WorkspaceGitActionResponseSchema.parse({
|
|
715
720
|
branch: await currentGitBranch(selectedWorkspacePath.path),
|
|
716
|
-
message: `Checked out ${parsed.data.branch}.`,
|
|
721
|
+
message: branchExists ? `Checked out ${parsed.data.branch}.` : `Created and checked out ${parsed.data.branch}.`,
|
|
717
722
|
output
|
|
718
723
|
});
|
|
719
724
|
return secureJson(c, options.pairing, secureSessionsByTokenHash, response);
|
|
@@ -2524,6 +2529,19 @@ async function readWorkspaceChanges(workspacePath) {
|
|
|
2524
2529
|
async function currentGitBranch(workspacePath) {
|
|
2525
2530
|
return (await git(workspacePath, ["branch", "--show-current"]).catch(() => "")).trim() || null;
|
|
2526
2531
|
}
|
|
2532
|
+
async function localGitBranchExists(workspacePath, branch) {
|
|
2533
|
+
try {
|
|
2534
|
+
await git(workspacePath, [
|
|
2535
|
+
"show-ref",
|
|
2536
|
+
"--verify",
|
|
2537
|
+
"--quiet",
|
|
2538
|
+
`refs/heads/${branch}`
|
|
2539
|
+
]);
|
|
2540
|
+
return true;
|
|
2541
|
+
} catch {
|
|
2542
|
+
return false;
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2527
2545
|
async function listGitBranches(workspacePath) {
|
|
2528
2546
|
return (await git(workspacePath, [
|
|
2529
2547
|
"branch",
|