botrun-mcli 0.1.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/src/git/github.mjs +5 -1
- package/src/git/provider.mjs +2 -2
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;
|
package/src/git/github.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export function buildCloneUrl(repo, token) {
|
|
2
|
-
|
|
2
|
+
// Normalize: strip https://, trailing .git
|
|
3
|
+
const cleaned = repo
|
|
4
|
+
.replace(/^https?:\/\//, '')
|
|
5
|
+
.replace(/\.git$/, '');
|
|
6
|
+
return `https://x-access-token:${token}@${cleaned}.git`;
|
|
3
7
|
}
|
package/src/git/provider.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import * as gitlab from './gitlab.mjs';
|
|
|
4
4
|
const providers = { github, gitlab };
|
|
5
5
|
|
|
6
6
|
export function detectProvider(repoUrl) {
|
|
7
|
-
if (repoUrl.
|
|
8
|
-
if (repoUrl.
|
|
7
|
+
if (repoUrl.includes('github.com')) return 'github';
|
|
8
|
+
if (repoUrl.includes('gitlab.com')) return 'gitlab';
|
|
9
9
|
throw new Error(`Unknown git provider for URL: ${repoUrl}`);
|
|
10
10
|
}
|
|
11
11
|
|