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

Function createGitClientForPath

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

Source from the content-addressed store, hash-verified

35 * set to the given path.
36 */
37const createGitClientForPath = (path: string, onProgress?: onProgressFn, signal?: AbortSignal) => {
38 if (!existsSync(path)) {
39 throw new Error(`Path ${path} does not exist`);
40 }
41
42 const parentPath = resolve(dirname(path));
43
44 const git = simpleGit({
45 progress: onProgress,
46 abort: signal,
47 unsafe,
48 })
49 .env({
50 ...process.env,
51 /**
52 * @note on some inside-baseball on why this is necessary: The specific
53 * issue we saw was that a `git clone` would fail without throwing, and
54 * then a subsequent `git config` command would run, but since the clone
55 * failed, it wouldn't be running in a git directory. Git would then walk
56 * up the directory tree until it either found a git directory (in the case
57 * of the development env) or it would hit a GIT_DISCOVERY_ACROSS_FILESYSTEM
58 * error when trying to cross a filesystem boundary (in the prod case).
59 * GIT_CEILING_DIRECTORIES ensures that this walk will be limited to the
60 * parent directory.
61 */
62 GIT_CEILING_DIRECTORIES: parentPath,
63 /**
64 * Disable git credential prompts. This ensures that git operations will fail
65 * immediately if credentials are not available, rather than prompting for input.
66 */
67 GIT_TERMINAL_PROMPT: '0',
68 })
69 .cwd({
70 path,
71 });
72
73 return git;
74}
75
76export const cloneRepository = async (
77 {

Callers 13

cloneRepositoryFunction · 0.85
fetchRepositoryFunction · 0.85
upsertGitConfigFunction · 0.85
unsetGitConfigFunction · 0.85
isPathAValidGitRepoRootFunction · 0.85
getOriginUrlFunction · 0.85
getSortedRefsFunction · 0.85
getCommitHashForRefNameFunction · 0.85
getRemoteDefaultBranchFunction · 0.85
getLocalDefaultBranchFunction · 0.85
getLatestCommitTimestampFunction · 0.85
isRepoEmptyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected