@ghl-ai/aw 0.1.36-beta.33 → 0.1.36-beta.34
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/git.mjs +7 -2
- package/package.json +1 -1
package/git.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// git.mjs — Git helpers: sparse checkout (temp) + persistent clone operations.
|
|
2
2
|
|
|
3
3
|
import { execSync, exec as execCb } from 'node:child_process';
|
|
4
|
-
import { mkdtempSync, existsSync, lstatSync, rmSync } from 'node:fs';
|
|
4
|
+
import { mkdtempSync, existsSync, lstatSync, rmSync, readFileSync } from 'node:fs';
|
|
5
5
|
import { join, basename, dirname } from 'node:path';
|
|
6
6
|
import { homedir, tmpdir } from 'node:os';
|
|
7
7
|
import { promisify } from 'node:util';
|
|
@@ -496,7 +496,12 @@ export function findNearestWorktree(startDir, stopDir) {
|
|
|
496
496
|
export function isWorktree(dir) {
|
|
497
497
|
const gitPath = join(dir, '.git');
|
|
498
498
|
try {
|
|
499
|
-
|
|
499
|
+
if (!lstatSync(gitPath).isFile()) return false;
|
|
500
|
+
// Verify the gitdir it points to actually exists (guards against stale worktrees)
|
|
501
|
+
const content = readFileSync(gitPath, 'utf8').trim();
|
|
502
|
+
const match = content.match(/^gitdir:\s*(.+)$/);
|
|
503
|
+
if (!match) return false;
|
|
504
|
+
return existsSync(match[1]);
|
|
500
505
|
} catch {
|
|
501
506
|
return false;
|
|
502
507
|
}
|