discover static method

RepoSet? discover(
  1. String start, {
  2. String? manifestPath,
  3. String? host,
})

The set for a run started in start: from the repos.yaml at or above it, or from manifestPath (a file; relative to start). Null when there is neither. Throws ReposManifestException for an invalid manifest. host defaults to reposHostId of the root.

Implementation

static RepoSet? discover(String start, {String? manifestPath, String? host}) {
  final from = p.normalize(p.absolute(start));
  String root;
  String file;
  if (manifestPath != null) {
    file = p.normalize(p.absolute(from, manifestPath));
    final dir = p.dirname(file);
    root = from == dir || p.isWithin(dir, from)
        ? dir
        : (findReposRoot(from) ?? from);
  } else {
    final found = findReposRoot(from);
    if (found == null) return null;
    root = found;
    file = p.join(root, kReposManifestFile);
  }
  final manifest = ReposManifest.parse(File(file).readAsStringSync());
  if (!_covers(root, manifest, from)) return null;
  return load(root: root, manifestPath: file, host: host);
}