Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174/** Concrete path listings of a private index.
@module */import { runTransactionGit, } from './commit-transaction-git.ts';
/** Strict Git metadata decoder. */const DECODER = new TextDecoder( 'utf-8', { fatal: true, },);
/** Returns unmerged paths from private index. @param gitPath - resolved Git executable @param cwd - repository directory @param indexPath - private index @returns unique unmerged repository paths @example ```ts await listUnmergedIndexPaths({ gitPath: '/usr/bin/git', cwd: '/repo', indexPath: '/tmp/index' }); ``` */export async function listUnmergedIndexPaths({ gitPath, cwd, indexPath,}: Readonly<{ gitPath: string; cwd: string; indexPath: string;}>,): Promise<readonly string[]> { /** NUL-delimited unmerged stage records. */ const output = await runTransactionGit({ gitPath, cwd, indexPath, args: [ 'ls-files', '--unmerged', '-z', ], },); /** Repository paths deduplicated across conflict stages. */ const paths = DECODER.decode(output.stdout,) .split('\0',) .flatMap(function recordPath(record,) { /** Metadata/path separator. */ const tab = record.indexOf('\t',); return tab === (-1) ? [] : [record.slice(tab + 1,),]; },); return [...new Set(paths,),];}
/** Returns concrete paths from private index through Git pathspec semantics. @param gitPath - resolved Git executable @param cwd - effective repository cwd @param indexPath - private index path @param pathspecs - Git pathspec scope @returns ordered concrete repository paths @example ```ts await listPrivateIndexPaths({ gitPath, cwd, indexPath, pathspecs: [':/'] }); ``` */export async function listPrivateIndexPaths({ gitPath, cwd, indexPath, pathspecs,}: Readonly<{ gitPath: string; cwd: string; indexPath: string; pathspecs: readonly string[];}>,): Promise<readonly string[]> { /** NUL-delimited private-index path output. */ const output = await runTransactionGit({ gitPath, cwd, indexPath, args: [ 'ls-files', '-z', '--', ...pathspecs, ], },); return DECODER.decode(output.stdout,) .split('\0',) .filter(function nonempty(path,) { return path.length > 0; },);}
/** Returns staged paths from private index relative to the preparation base. @param gitPath - resolved Git executable @param cwd - repository directory @param indexPath - private index @param baseRevision - recorded base commit, or the empty tree for an unborn base @param objectDirectory - object store holding the private index's blobs, read by rename detection @returns repository paths @example ```ts await listChangedIndexPaths({ gitPath: '/usr/bin/git', cwd: '/repo', indexPath: '/tmp/index', baseRevision }); ``` */export async function listChangedIndexPaths({ gitPath, cwd, indexPath, baseRevision, objectDirectory,}: Readonly<{ gitPath: string; cwd: string; indexPath: string; baseRevision: string; objectDirectory?: string;}>,): Promise<readonly string[]> { /** NUL-delimited changed paths against the recorded base, never live `HEAD`. */ const output = await runTransactionGit({ gitPath, cwd, indexPath, args: [ 'diff', '--cached', '--name-only', '-z', baseRevision, ], ...(objectDirectory === undefined ? {} : { objectDirectory, }), },); return DECODER.decode(output.stdout,) .split('\0',) .filter(function nonempty(path,) { return path.length > 0; },);}