shouldIgnorePath function

bool shouldIgnorePath(
  1. String path,
  2. List<String> ignoredPatterns
)

path starts with Platform.pathSeparator as a relative path from the Repository parent dir

Implementation

bool shouldIgnorePath(String path, List<String> ignoredPatterns) {
  debugPrintToConsole(message: "Checking if should ignore $path", newLine: true);

  for (String ignorePattern in ignoredPatterns) {
    IgnorePatternRules rule = IgnorePatternRules.detectRule(ignorePattern);

    final bool matched = switch (rule) {
      IgnorePatternRules.pathFromRoot => rule.patternMatches(
        testPattern: ignorePattern,
        inputPattern: path,
      ),
      IgnorePatternRules.suffix => rule.patternMatches(
        testPattern: ignorePattern,
        inputPattern: path,
      ),
      IgnorePatternRules.single => rule.patternMatches(
        testPattern: ignorePattern,
        inputPattern: stripBeginningPathSeparatorPath(path),
      ),
      IgnorePatternRules.contains => rule.patternMatches(
        testPattern: ignorePattern,
        inputPattern: path,
      ),
      IgnorePatternRules.exactMatch => rule.patternMatches(
        testPattern: ignorePattern,
        inputPattern: stripBeginningPathSeparatorPath(path),
      ),
    };

    if (matched) {
      debugPrintToConsole(message: "$path will be ignored due to match by $rule on $ignorePattern");
      return true;
    }
  }

  debugPrintToConsole(message: "$path will not be ignored");
  return false;
}