botrun-mcli 0.2.0 → 0.2.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/package.json +1 -1
- package/src/commands/memory/init.mjs +16 -1
package/package.json
CHANGED
|
@@ -13,12 +13,27 @@ async function exists(path) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
async function hasWorkingTree(dir) {
|
|
17
|
+
try {
|
|
18
|
+
const result = await gitExec(['-C', dir, 'rev-parse', '--is-inside-work-tree']);
|
|
19
|
+
return result === 'true';
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
async function cloneOrPull(repo, cloneDir, token, localMode, branch) {
|
|
17
|
-
if (await exists(cloneDir)) {
|
|
26
|
+
if (await exists(cloneDir) && await hasWorkingTree(cloneDir)) {
|
|
18
27
|
await gitExec(['-C', cloneDir, 'pull', '--rebase']);
|
|
19
28
|
return;
|
|
20
29
|
}
|
|
21
30
|
|
|
31
|
+
// If directory exists but broken (no working tree), remove and re-clone
|
|
32
|
+
if (await exists(cloneDir)) {
|
|
33
|
+
const { rm } = await import('node:fs/promises');
|
|
34
|
+
await rm(cloneDir, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
let cloneUrl;
|
|
23
38
|
if (localMode) {
|
|
24
39
|
cloneUrl = repo;
|