code-squad-cli 1.2.22 → 2.0.0
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/adapters/GitAdapter.js +18 -4
- package/dist/index.js +97 -661
- package/package.json +1 -1
- package/dist/ui/prompts.d.ts +0 -47
- package/dist/ui/prompts.js +0 -328
|
@@ -14,8 +14,20 @@ export class GitAdapter {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
async getCurrentBranch(workspaceRoot) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
try {
|
|
18
|
+
const { stdout } = await exec(`cd "${workspaceRoot}" && git rev-parse --abbrev-ref HEAD`, execOptions);
|
|
19
|
+
return stdout.trim();
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// No commits yet — fall back to symbolic-ref (e.g. "main" on fresh repos)
|
|
23
|
+
try {
|
|
24
|
+
const { stdout } = await exec(`cd "${workspaceRoot}" && git symbolic-ref --short HEAD`, execOptions);
|
|
25
|
+
return stdout.trim();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
19
31
|
}
|
|
20
32
|
async listWorktrees(workspaceRoot) {
|
|
21
33
|
try {
|
|
@@ -57,10 +69,12 @@ export class GitAdapter {
|
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
71
|
async createWorktree(worktreePath, branch, workspaceRoot) {
|
|
60
|
-
//
|
|
72
|
+
// Prune stale worktree entries (e.g. directory was deleted but still registered)
|
|
73
|
+
await exec(`cd "${workspaceRoot}" && git worktree prune`, execOptions).catch(() => { });
|
|
74
|
+
// Recursively create parent directory
|
|
61
75
|
const parentDir = worktreePath.substring(0, worktreePath.lastIndexOf('/'));
|
|
62
76
|
const mkdirCmd = parentDir ? `mkdir -p "${parentDir}" && ` : '';
|
|
63
|
-
await exec(`cd "${workspaceRoot}" && ${mkdirCmd}git worktree add "${worktreePath}" -b "${branch}"`, execOptions);
|
|
77
|
+
await exec(`cd "${workspaceRoot}" && ${mkdirCmd}git worktree add -f "${worktreePath}" -b "${branch}"`, execOptions);
|
|
64
78
|
}
|
|
65
79
|
async removeWorktree(worktreePath, workspaceRoot, force = false) {
|
|
66
80
|
const forceFlag = force ? ' --force' : '';
|