gitnexus 1.6.4-rc.45 → 1.6.4-rc.46
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/core/git-staleness.js +5 -4
- package/dist/storage/git.d.ts +7 -0
- package/dist/storage/git.js +29 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { execFileSync } from 'node:child_process';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { readRegistry } from '../storage/repo-manager.js';
|
|
8
|
-
import {
|
|
8
|
+
import { findGitRootByDotGit, getCurrentCommit, getRemoteUrl } from '../storage/git.js';
|
|
9
9
|
/**
|
|
10
10
|
* Check how many commits the index is behind HEAD (synchronous; uses git CLI).
|
|
11
11
|
*/
|
|
@@ -90,9 +90,10 @@ export async function checkCwdMatch(cwd) {
|
|
|
90
90
|
}
|
|
91
91
|
if (bestPath)
|
|
92
92
|
return { match: 'path', entry: bestPath };
|
|
93
|
-
// 2) Sibling-by-remote: locate the cwd's git root
|
|
94
|
-
//
|
|
95
|
-
|
|
93
|
+
// 2) Sibling-by-remote: locate the cwd's git root using only ancestor
|
|
94
|
+
// `.git` checks before shelling out. This keeps MCP startup from
|
|
95
|
+
// running git in an unrelated launch cwd such as $HOME (#1138).
|
|
96
|
+
const cwdGitRoot = findGitRootByDotGit(cwdResolved);
|
|
96
97
|
if (!cwdGitRoot)
|
|
97
98
|
return { match: 'none' };
|
|
98
99
|
const cwdRemote = getRemoteUrl(cwdGitRoot);
|
package/dist/storage/git.d.ts
CHANGED
|
@@ -28,6 +28,13 @@ export declare const getRemoteUrl: (repoPath: string) => string | undefined;
|
|
|
28
28
|
* Find the git repository root from any path inside the repo
|
|
29
29
|
*/
|
|
30
30
|
export declare const getGitRoot: (fromPath: string) => string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Find a git root by checking only `.git` entries on the ancestor chain.
|
|
33
|
+
*
|
|
34
|
+
* Unlike `getGitRoot`, this does not spawn `git`, so MCP can cheaply decide
|
|
35
|
+
* whether a launch cwd is a worktree before running any subprocess there.
|
|
36
|
+
*/
|
|
37
|
+
export declare const findGitRootByDotGit: (fromPath: string) => string | null;
|
|
31
38
|
/**
|
|
32
39
|
* Check whether a directory contains a .git entry (file or folder).
|
|
33
40
|
*
|
package/dist/storage/git.js
CHANGED
|
@@ -91,6 +91,35 @@ export const getGitRoot = (fromPath) => {
|
|
|
91
91
|
return null;
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* Find a git root by checking only `.git` entries on the ancestor chain.
|
|
96
|
+
*
|
|
97
|
+
* Unlike `getGitRoot`, this does not spawn `git`, so MCP can cheaply decide
|
|
98
|
+
* whether a launch cwd is a worktree before running any subprocess there.
|
|
99
|
+
*/
|
|
100
|
+
export const findGitRootByDotGit = (fromPath) => {
|
|
101
|
+
let current = path.resolve(fromPath);
|
|
102
|
+
try {
|
|
103
|
+
if (!statSync(current).isDirectory()) {
|
|
104
|
+
current = path.dirname(current);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
while (true) {
|
|
111
|
+
try {
|
|
112
|
+
statSync(path.join(current, '.git'));
|
|
113
|
+
return current;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
const parent = path.dirname(current);
|
|
117
|
+
if (parent === current)
|
|
118
|
+
return null;
|
|
119
|
+
current = parent;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
94
123
|
/**
|
|
95
124
|
* Check whether a directory contains a .git entry (file or folder).
|
|
96
125
|
*
|
package/package.json
CHANGED