scope method
The repositories a git-mode run started in start works on: those of
the git set (RepoSetMember.inGitSet) on disk at or below start.
With stopAtWorkspaces (the ordinary git commands without -w taking
over), a repository below start whose folder holds a workspace of its
own (<toolBasename>_master.yaml) is a boundary: it and everything
below it are left out and it is named in
RepoSetScope.nestedWorkspaces. A workspace folder that is no
repository of the set (a test fixture inside a repository) is no
boundary, so -w never runs a repository twice.
Implementation
RepoSetScope scope(
String start, {
String toolBasename = 'buildkit',
bool stopAtWorkspaces = true,
}) {
final from = p.normalize(p.absolute(start));
final inScope = members
.where((m) => m.inGitSet && m.onDisk)
.where((m) => m.path == from || p.isWithin(from, m.path))
.toList();
if (!stopAtWorkspaces) {
return (members: inScope, nestedWorkspaces: const []);
}
final boundaries = [
for (final m in inScope)
if (m.path != from &&
File(p.join(m.path, '${toolBasename}_master.yaml')).existsSync())
m.path,
];
final outermost = [
for (final b in boundaries)
if (!boundaries.any((o) => o != b && p.isWithin(o, b))) b,
];
return (
members: [
for (final m in inScope)
if (!outermost.any((b) => m.path == b || p.isWithin(b, m.path))) m,
],
nestedWorkspaces: outermost,
);
}