Skip to content

Commit ae19339

Browse files
Generate temporary worktree branches with Effect random UUIDs
1 parent c95bed1 commit ae19339

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎packages/shared/src/git.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type {
66
GitStatusResult,
77
GitStatusStreamEvent,
88
} from "@t3tools/contracts";
9+
import * as Effect from "effect/Effect";
10+
import * as Random from "effect/Random";
911

1012
export const WORKTREE_BRANCH_PREFIX = "t3code";
1113
const TEMP_WORKTREE_BRANCH_PATTERN = new RegExp(`^${WORKTREE_BRANCH_PREFIX}\\/[0-9a-f]{8}$`);
@@ -84,7 +86,7 @@ export function deriveLocalBranchNameFromRemoteRef(branchName: string): string {
8486
}
8587

8688
export function buildTemporaryWorktreeBranchName(): string {
87-
const token = crypto.randomUUID().slice(0, 8).toLowerCase();
89+
const token = Effect.runSync(Random.nextUUIDv4).replace(/-/g, "").slice(0, 8).toLowerCase();
8890
return `${WORKTREE_BRANCH_PREFIX}/${token}`;
8991
}
9092

0 commit comments

Comments
 (0)