MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / isPathAValidGitRepoRoot

Function isPathAValidGitRepoRoot

packages/backend/src/git.ts:249–273  ·  view source on GitHub ↗
({
    path,
    onProgress,
    signal,
}: {
    path: string,
    onProgress?: onProgressFn,
    signal?: AbortSignal
})

Source from the content-addressed store, hash-verified

247 * Returns true if `path` is the _root_ of a git repository.
248 */
249export const isPathAValidGitRepoRoot = async ({
250 path,
251 onProgress,
252 signal,
253}: {
254 path: string,
255 onProgress?: onProgressFn,
256 signal?: AbortSignal
257}) => {
258 if (!existsSync(path)) {
259 return false;
260 }
261
262 const git = createGitClientForPath(path, onProgress, signal);
263
264 try {
265 return git.checkIsRepo(CheckRepoActions.IS_REPO_ROOT);
266 } catch (error: unknown) {
267 if (error instanceof Error) {
268 throw new Error(`isPathAGitRepoRoot failed: ${error.message}`);
269 } else {
270 throw new Error(`isPathAGitRepoRoot failed: ${error}`);
271 }
272 }
273}
274
275export const isUrlAValidGitRepo = async (url: string) => {
276 const git = simpleGit();

Callers 2

indexRepositoryMethod · 0.85

Calls 1

createGitClientForPathFunction · 0.85

Tested by

no test coverage detected