findRootDir static method

String? findRootDir(
  1. String path, {
  2. FileSystem? fs,
})

Implementation

static String? findRootDir(String path, {FileSystem? fs}) {
  fs ??= const LocalFileSystemWithChecks();

  while (true) {
    var gitDir = p.join(path, '.git');
    if (fs.isDirectorySync(gitDir)) {
      return path;
    }

    if (path == p.separator) {
      break;
    }

    path = p.dirname(path);
  }
  return null;
}