describeMismatches function
A report naming each drifted package, why the fixture's lock governs, and
the repair — pub upgrade in whichever side is behind.
Never pub get (sce250). get is lock-preserving: a stale lock still
satisfies its constraints, so get leaves it exactly where it is, and a
reader who ran it arrives back at the identical failure. That is SCC45's
mechanism one directory down, and the message says so because "I ran the
repair and it failed again" is the state a reader is in when they read it.
Implementation
String describeMismatches(List<ResolutionMismatch> mismatches) {
if (mismatches.isEmpty) return '';
final buffer = StringBuffer()
..writeln(
'${mismatches.length} package(s) resolve differently in the '
'fixture than in the package it exercises.',
)
..writeln(
'The fixture reaches that package by `path:`, which supplies its '
'SOURCE but not its RESOLUTION — so the fixture compiles the '
"host's current lib/ against these versions rather than its own, and "
'the error surfaces inside a directory the fixture does not own.',
);
for (final mismatch in mismatches) {
buffer.writeln(' - $mismatch');
}
// Group the packages by the project that is behind, in first-seen order.
final behind = <String, List<String>>{};
for (final m in mismatches) {
final project = m.hostIsBehind && m.hostPath != null
? m.hostPath!
: m.fixturePath;
(behind[project] ??= []).add(m.package);
}
buffer.writeln('Repair — pub UPGRADE in the side that is behind:');
behind.forEach((project, packages) {
buffer.writeln(
' cd $project && ${_pubTool(project)} pub upgrade '
'${packages.join(' ')}',
);
});
buffer.write(
'`pub get` will NOT fix this, and running it returns this same failure: '
'it is lock-preserving, and the stale lock still satisfies its '
'constraints, so it stays where it is (SCC45). If `pub upgrade` does not '
'move the version either, a constraint is holding it — raise it.',
);
return buffer.toString();
}