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
  1ea3c907_ef99_80b1_3a67_c18aff6c6391["findGitignoreFiles()"]
  b00e0b6e_8e66_44d2_f709_c8c6bbb476c9["zip-repository.ts"]
  1ea3c907_ef99_80b1_3a67_c18aff6c6391 -->|defined in| b00e0b6e_8e66_44d2_f709_c8c6bbb476c9
  44ecfbe1_2321_f70c_1614_c983eebf0cf5["buildIgnoreFilter()"]
  44ecfbe1_2321_f70c_1614_c983eebf0cf5 -->|calls| 1ea3c907_ef99_80b1_3a67_c18aff6c6391
  f7302a04_558c_423c_2b1f_3cfced56f273["warn()"]
  1ea3c907_ef99_80b1_3a67_c18aff6c6391 -->|calls| f7302a04_558c_423c_2b1f_3cfced56f273
  style 1ea3c907_ef99_80b1_3a67_c18aff6c6391 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;
}

Subdomains

Calls

Frequently Asked Questions

What does findGitignoreFiles() do?
findGitignoreFiles() is a function in the mcp codebase, defined in src/utils/zip-repository.ts.
Where is findGitignoreFiles() defined?
findGitignoreFiles() is defined in src/utils/zip-repository.ts at line 520.
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