The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import type { VcsRef } from "@t3tools/contracts"; |
| 2 | |
| 3 | /** An empty base is automatic: the project's default branch, else `main` or `master`. */ |
| 4 | export function scheduledTaskWorktreeBaseRef( |
| 5 | baseRef: string, |
| 6 | refs: ReadonlyArray<Pick<VcsRef, "name" | "isDefault">>, |
| 7 | ): string { |
| 8 | const picked = baseRef.trim(); |
| 9 | if (picked) return picked; |
| 10 | const defaultRef = refs.find((ref) => ref.isDefault); |
| 11 | if (defaultRef) return defaultRef.name; |
| 12 | for (const name of ["main", "master"]) { |
| 13 | const match = refs.find((ref) => ref.name === name || ref.name === `origin/${name}`); |
| 14 | if (match) return match.name; |
| 15 | } |
| 16 | return "main"; |
| 17 | } |