MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / captureUntrackedFiles

Function captureUntrackedFiles

source code/utils/git.ts:618–715  ·  view source on GitHub ↗

* Capture untracked files (git diff doesn't include them). * Respects size limits and skips binary files.

()

Source from the content-addressed store, hash-verified

616 * Respects size limits and skips binary files.
617 */
618async function captureUntrackedFiles(): Promise<
619 Array<{ path: string; content: string }>
620> {
621 const { stdout, code } = await execFileNoThrow(
622 gitExe(),
623 ['ls-files', '--others', '--exclude-standard'],
624 { preserveOutputOnError: false },
625 )
626
627 const trimmed = stdout.trim()
628 if (code !== 0 || !trimmed) {
629 return []
630 }
631
632 const files = trimmed.split('\n').filter(Boolean)
633 const result: Array<{ path: string; content: string }> = []
634 let totalSize = 0
635
636 for (const filePath of files) {
637 // Check file count limit
638 if (result.length >= MAX_FILE_COUNT) {
639 logForDebugging(
640 `Untracked file capture: reached max file count (${MAX_FILE_COUNT})`,
641 )
642 break
643 }
644
645 // Skip binary files by extension - zero I/O
646 if (hasBinaryExtension(filePath)) {
647 continue
648 }
649
650 try {
651 const stats = await stat(filePath)
652 const fileSize = stats.size
653
654 // Skip files exceeding per-file limit
655 if (fileSize > MAX_FILE_SIZE_BYTES) {
656 logForDebugging(
657 `Untracked file capture: skipping ${filePath} (exceeds ${MAX_FILE_SIZE_BYTES} bytes)`,
658 )
659 continue
660 }
661
662 // Check total size limit
663 if (totalSize + fileSize > MAX_TOTAL_SIZE_BYTES) {
664 logForDebugging(
665 `Untracked file capture: reached total size limit (${MAX_TOTAL_SIZE_BYTES} bytes)`,
666 )
667 break
668 }
669
670 // Empty file - no need to open
671 if (fileSize === 0) {
672 result.push({ path: filePath, content: '' })
673 continue
674 }
675

Callers 1

preserveGitStateForIssueFunction · 0.85

Calls 10

execFileNoThrowFunction · 0.85
logForDebuggingFunction · 0.85
hasBinaryExtensionFunction · 0.85
statFunction · 0.85
openFunction · 0.85
isBinaryContentFunction · 0.85
readFileFunction · 0.85
toStringMethod · 0.65
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected