public static function stripExceptDirectories()

in src/shipit/filter/ShipItPathFilters.php [132:165]


  public static function stripExceptDirectories(
    ShipItChangeset $changeset,
    keyset<string> $roots,
  ): ShipItChangeset {
    $roots = Keyset\map(
      $roots,
      $root ==> Str\slice($root, -1) === '/' ? $root : $root.'/',
    );
    $diffs = vec[];
    $use_debug = C\count($changeset->getDiffs()) < self::LARGE_CHANGESET;
    foreach ($changeset->getDiffs() as $diff) {
      $path = $diff['path'];
      $match = false;
      foreach ($roots as $root) {
        if (Str\slice($path, 0, Str\length($root)) === $root) {
          $match = true;
          break;
        }
      }
      if ($match) {
        $diffs[] = $diff;
        continue;
      }

      if ($use_debug) {
        $changeset = $changeset->withDebugMessage(
          'STRIP FILE: "%s" is not in a listed root (%s)',
          $path,
          Str\join($roots, ', '),
        );
      }
    }
    return $changeset->withDiffs($diffs);
  }