MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / writeCommitGraph

Function writeCommitGraph

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

Source from the content-addressed store, hash-verified

494 * @see: https://git-scm.com/docs/commit-graph
495 */
496export const writeCommitGraph = async ({
497 path,
498 forceBackfill,
499 onProgress,
500 signal,
501}: {
502 path: string,
503 forceBackfill?: boolean,
504 onProgress?: onProgressFn,
505 signal?: AbortSignal,
506}): Promise<void> => {
507 const git = createGitClientForPath(path, onProgress, signal);
508
509 try {
510 const args = ['commit-graph', 'write', '--reachable', '--changed-paths'];
511 if (forceBackfill) {
512 // --split=replace consolidates any existing layers into a single new layer,
513 // which forces git to recompute Bloom filters for every commit (not just commits
514 // added since the last write). Used for the one-time migration of repos that have
515 // a Bloom-less commit-graph from before --changed-paths was enabled.
516 // @see: https://git-scm.com/docs/git-commit-graph#Documentation/git-commit-graph.txt-write
517 args.push('--split=replace');
518 }
519 await git.raw(args);
520 } catch (error) {
521 // Don't throw an exception here since this is just a performance optimization.
522 logger.debug(`Failed to write commit-graph for ${path}:`, error);
523 }
524}

Callers 1

indexRepositoryMethod · 0.85

Calls 1

createGitClientForPathFunction · 0.85

Tested by

no test coverage detected