Home / Function/ findGitignoreFiles() — mcp Function Reference

findGitignoreFiles() — mcp Function Reference

Architecture documentation for the findGitignoreFiles() function in zip-repository.ts from the mcp codebase.

Entity Profile

Dependency Diagram

graph TD
  8d4cd429_ec54_0fed_e163_4affcc57c61d["findGitignoreFiles()"]
  d9b9a00b_7ed2_f6c8_1ca7_1e298c76a167["buildIgnoreFilter()"]
  d9b9a00b_7ed2_f6c8_1ca7_1e298c76a167 -->|calls| 8d4cd429_ec54_0fed_e163_4affcc57c61d
  e5352615_c5fb_64a2_cc5c_a248578cbc8a["warn()"]
  8d4cd429_ec54_0fed_e163_4affcc57c61d -->|calls| e5352615_c5fb_64a2_cc5c_a248578cbc8a
  style 8d4cd429_ec54_0fed_e163_4affcc57c61d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/utils/zip-repository.ts lines 520–573

async function findGitignoreFiles(rootDir: string): Promise<string[]> {
  const gitignoreFiles: string[] = [];

  async function searchDirectory(dir: string): Promise<void> {
    let entries: string[];

    try {
      entries = await fs.readdir(dir);
    } catch (error: any) {
      if (error.code === 'EACCES') {
        logger.warn('Permission denied:', dir);
        return;
      }
      return;
    }

    for (const entry of entries) {
      // Skip .git directory and other version control directories
      if (entry === '.git' || entry === '.svn' || entry === '.hg') {
        continue;
      }

      const fullPath = join(dir, entry);

      // If this is a .gitignore file, add it to the list
      if (entry === '.gitignore') {
        gitignoreFiles.push(fullPath);
        continue;
      }

      // If it's a directory, recurse into it
      try {
        const stats = await fs.lstat(fullPath);
        if (stats.isDirectory() && !stats.isSymbolicLink()) {
          await searchDirectory(fullPath);
        }
      } catch (error: any) {
        // Skip files we can't access
        continue;
      }
    }
  }

  await searchDirectory(rootDir);

  // Sort so root .gitignore is processed first
  gitignoreFiles.sort((a, b) => {
    const aDepth = a.split(sep).length;
    const bDepth = b.split(sep).length;
    return aDepth - bDepth;
  });

  return gitignoreFiles;
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does findGitignoreFiles() do?
findGitignoreFiles() is a function in the mcp codebase.
What does findGitignoreFiles() call?
findGitignoreFiles() calls 1 function(s): warn.
What calls findGitignoreFiles()?
findGitignoreFiles() is called by 1 function(s): buildIgnoreFilter.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free