matches method

bool matches(
  1. String relativePath, {
  2. required bool isDirectory,
})

Checks if this pattern matches the given path.

relativePath is the path relative to the gitignore location. isDirectory indicates if the path is a directory.

Implementation

bool matches(String relativePath, {required bool isDirectory}) {
  // Directory-only patterns should not match files
  if (isDirectoryOnly && !isDirectory) {
    return false;
  }

  if (hasPathSeparator) {
    // Pattern has path separator - match against full relative path
    return _glob.matches(relativePath);
  } else {
    // Pattern has no path separator - match against basename only
    return _glob.matches(basename(relativePath));
  }
}