fix(tool): the check limited to changes sees uncommitted ones too

Melos' --diff compares commits alone (<commit>...HEAD), so a check with
--changed-since before committing tested nothing and passed. The check
now works out the packages touched itself, from git diff against the
commit and the files new to git, each file counted in its innermost
package, and hands them to Melos as --scope with --include-dependents;
a changed root pubspec, lock or lint rule means every package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-19 21:32:14 +02:00
commit bf20134819
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -46,11 +46,54 @@ void main() {
);
});
test("Melos' filters take only what changed since a commit, and what depends "
'on it, when asked', () {
group('what changed since a commit', () {
const packages = {
'halkyon_app': 'packages/halkyon_app',
'halkyon_ui': 'packages/halkyon_ui',
'halkyon_ui_example': 'packages/halkyon_ui/example',
'halkyon_learn_flutter': 'apps/learn/halkyon_learn_flutter',
};
test('touches the packages its files are in, the innermost one', () {
expect(
packagesTouched([
'packages/halkyon_app/lib/src/app/app_frame.dart',
'packages/halkyon_app/test/app/instance_gate_test.dart',
'packages/halkyon_ui/example/lib/main.dart',
], packages),
['halkyon_app', 'halkyon_ui_example'],
);
});
test("files of no package (docs, tools, deploy) touch none: the tools' "
'own tests run anyway', () {
expect(
packagesTouched([
'docs/adr/0015-one-repository.md',
'tool/check.dart',
'deploy/compose.yaml',
], packages),
isEmpty,
);
});
test("the root's pubspec, lock or lint rules touch every package", () {
for (final path in [
'pubspec.yaml',
'pubspec.lock',
'analysis_options.yaml',
]) {
expect(packagesTouched([path], packages), isNull, reason: path);
}
});
});
test("Melos' filters take every package, or those touched and what "
'depends on them', () {
expect(melosFilters(), isEmpty);
expect(melosFilters(changedSince: 'origin/main'), [
'--diff=origin/main',
expect(melosFilters(touched: ['halkyon_app', 'halkyon_ui']), [
'--scope=halkyon_app',
'--scope=halkyon_ui',
'--include-dependents',
]);
});