@@ -523,7 +523,7 @@ packages/plugin1/CHANGELOG
523523 output,
524524 containsAllInOrder (< Matcher > [
525525 contains (
526- 'Running for all packages that have changed relative to "main"' ),
526+ 'Running for all packages that have diffs relative to "main"' ),
527527 ]));
528528
529529 expect (command.plugins, unorderedEquals (< String > [plugin1.path]));
@@ -732,13 +732,17 @@ packages/b_package/lib/src/foo.dart
732732 });
733733
734734 group ('--packages-for-branch' , () {
735- test ('only tests changed packages on a branch' , () async {
735+ test ('only tests changed packages relative to the merge base on a branch' ,
736+ () async {
736737 processRunner.mockProcessesForExecutable['git-diff' ] = < Process > [
737738 MockProcess (stdout: 'packages/plugin1/plugin1.dart' ),
738739 ];
739740 processRunner.mockProcessesForExecutable['git-rev-parse' ] = < Process > [
740741 MockProcess (stdout: 'a-branch' ),
741742 ];
743+ processRunner.mockProcessesForExecutable['git-merge-base' ] = < Process > [
744+ MockProcess (stdout: 'abc123' ),
745+ ];
742746 final RepositoryPackage plugin1 =
743747 createFakePlugin ('plugin1' , packagesDir);
744748 createFakePlugin ('plugin2' , packagesDir);
@@ -750,11 +754,20 @@ packages/b_package/lib/src/foo.dart
750754 expect (
751755 output,
752756 containsAllInOrder (< Matcher > [
753- contains ('--packages-for-branch: running on changed packages' ),
757+ contains (
758+ 'Running for all packages that have diffs relative to "abc123"' ),
754759 ]));
760+ // Ensure that it's diffing against the merge-base.
761+ expect (
762+ processRunner.recordedCalls,
763+ contains (
764+ const ProcessCall (
765+ 'git-diff' , < String > ['--name-only' , 'abc123' , 'HEAD' ], null ),
766+ ));
755767 });
756768
757- test ('tests all packages on main' , () async {
769+ test ('only tests changed packages relative to the previous commit on main' ,
770+ () async {
758771 processRunner.mockProcessesForExecutable['git-diff' ] = < Process > [
759772 MockProcess (stdout: 'packages/plugin1/plugin1.dart' ),
760773 ];
@@ -763,19 +776,27 @@ packages/b_package/lib/src/foo.dart
763776 ];
764777 final RepositoryPackage plugin1 =
765778 createFakePlugin ('plugin1' , packagesDir);
766- final RepositoryPackage plugin2 =
767- createFakePlugin ('plugin2' , packagesDir);
779+ createFakePlugin ('plugin2' , packagesDir);
768780
769781 final List <String > output = await runCapturingPrint (
770782 runner, < String > ['sample' , '--packages-for-branch' ]);
771783
772- expect (command.plugins,
773- unorderedEquals (< String > [plugin1.path, plugin2.path]));
784+ expect (command.plugins, unorderedEquals (< String > [plugin1.path]));
774785 expect (
775786 output,
776787 containsAllInOrder (< Matcher > [
777- contains ('--packages-for-branch: running on all packages' ),
788+ contains ('--packages-for-branch: running on default branch; '
789+ 'using parent commit as the diff base' ),
790+ contains (
791+ 'Running for all packages that have diffs relative to "HEAD~"' ),
778792 ]));
793+ // Ensure that it's diffing against the prior commit.
794+ expect (
795+ processRunner.recordedCalls,
796+ contains (
797+ const ProcessCall (
798+ 'git-diff' , < String > ['--name-only' , 'HEAD~' , 'HEAD' ], null ),
799+ ));
779800 });
780801
781802 test ('tests all packages on master' , () async {
@@ -787,19 +808,27 @@ packages/b_package/lib/src/foo.dart
787808 ];
788809 final RepositoryPackage plugin1 =
789810 createFakePlugin ('plugin1' , packagesDir);
790- final RepositoryPackage plugin2 =
791- createFakePlugin ('plugin2' , packagesDir);
811+ createFakePlugin ('plugin2' , packagesDir);
792812
793813 final List <String > output = await runCapturingPrint (
794814 runner, < String > ['sample' , '--packages-for-branch' ]);
795815
796- expect (command.plugins,
797- unorderedEquals (< String > [plugin1.path, plugin2.path]));
816+ expect (command.plugins, unorderedEquals (< String > [plugin1.path]));
798817 expect (
799818 output,
800819 containsAllInOrder (< Matcher > [
801- contains ('--packages-for-branch: running on all packages' ),
820+ contains ('--packages-for-branch: running on default branch; '
821+ 'using parent commit as the diff base' ),
822+ contains (
823+ 'Running for all packages that have diffs relative to "HEAD~"' ),
802824 ]));
825+ // Ensure that it's diffing against the prior commit.
826+ expect (
827+ processRunner.recordedCalls,
828+ contains (
829+ const ProcessCall (
830+ 'git-diff' , < String > ['--name-only' , 'HEAD~' , 'HEAD' ], null ),
831+ ));
803832 });
804833
805834 test ('throws if getting the branch fails' , () async {
0 commit comments