@@ -75,9 +75,15 @@ abstract class PluginCommand extends Command<void> {
7575 help: 'Run the command on changed packages/plugins.\n '
7676 'If no packages have changed, or if there have been changes that may\n '
7777 'affect all packages, the command runs on all packages.\n '
78- 'The packages excluded with $_excludeArg is also excluded even if changed.\n '
78+ 'Packages excluded with $_excludeArg are excluded even if changed.\n '
7979 'See $_baseShaArg if a custom base is needed to determine the diff.\n\n '
8080 'Cannot be combined with $_packagesArg .\n ' );
81+ argParser.addFlag (_runOnDirtyPackagesArg,
82+ help:
83+ 'Run the command on packages with changes that have not been committed.\n '
84+ 'Packages excluded with $_excludeArg are excluded even if changed.\n '
85+ 'Cannot be combined with $_packagesArg .\n ' ,
86+ hide: true );
8187 argParser.addFlag (_packagesForBranchArg,
8288 help:
8389 'This runs on all packages (equivalent to no package selection flag)\n '
@@ -103,6 +109,7 @@ abstract class PluginCommand extends Command<void> {
103109 static const String _packagesForBranchArg = 'packages-for-branch' ;
104110 static const String _pluginsArg = 'plugins' ;
105111 static const String _runOnChangedPackagesArg = 'run-on-changed-packages' ;
112+ static const String _runOnDirtyPackagesArg = 'run-on-dirty-packages' ;
106113 static const String _shardCountArg = 'shardCount' ;
107114 static const String _shardIndexArg = 'shardIndex' ;
108115
@@ -289,6 +296,7 @@ abstract class PluginCommand extends Command<void> {
289296 final Set <String > packageSelectionFlags = < String > {
290297 _packagesArg,
291298 _runOnChangedPackagesArg,
299+ _runOnDirtyPackagesArg,
292300 _packagesForBranchArg,
293301 };
294302 if (packageSelectionFlags
@@ -300,7 +308,7 @@ abstract class PluginCommand extends Command<void> {
300308 throw ToolExit (exitInvalidArguments);
301309 }
302310
303- Set <String > plugins = Set <String >.from (getStringListArg (_packagesArg));
311+ Set <String > packages = Set <String >.from (getStringListArg (_packagesArg));
304312
305313 final bool runOnChangedPackages;
306314 if (getBoolArg (_runOnChangedPackagesArg)) {
@@ -331,7 +339,21 @@ abstract class PluginCommand extends Command<void> {
331339 final List <String > changedFiles =
332340 await gitVersionFinder.getChangedFiles ();
333341 if (! _changesRequireFullTest (changedFiles)) {
334- plugins = _getChangedPackages (changedFiles);
342+ packages = _getChangedPackages (changedFiles);
343+ }
344+ } else if (getBoolArg (_runOnDirtyPackagesArg)) {
345+ final GitVersionFinder gitVersionFinder =
346+ GitVersionFinder (await gitDir, 'HEAD' );
347+ print ('Running for all packages that have uncommitted changes\n ' );
348+ // _changesRequireFullTest is deliberately not used here, as this flag is
349+ // intended for use in CI to re-test packages changed by
350+ // 'make-deps-path-based'.
351+ packages = _getChangedPackages (
352+ await gitVersionFinder.getChangedFiles (includeUncommitted: true ));
353+ // For the same reason, empty is not treated as "all packages" as it is
354+ // for other flags.
355+ if (packages.isEmpty) {
356+ return ;
335357 }
336358 }
337359
@@ -347,7 +369,7 @@ abstract class PluginCommand extends Command<void> {
347369 in dir.list (followLinks: false )) {
348370 // A top-level Dart package is a plugin package.
349371 if (_isDartPackage (entity)) {
350- if (plugins .isEmpty || plugins .contains (p.basename (entity.path))) {
372+ if (packages .isEmpty || packages .contains (p.basename (entity.path))) {
351373 yield PackageEnumerationEntry (
352374 RepositoryPackage (entity as Directory ),
353375 excluded: excludedPluginNames.contains (entity.basename));
@@ -364,9 +386,9 @@ abstract class PluginCommand extends Command<void> {
364386 path.relative (subdir.path, from: dir.path);
365387 final String packageName = path.basename (subdir.path);
366388 final String basenamePath = path.basename (entity.path);
367- if (plugins .isEmpty ||
368- plugins .contains (relativePath) ||
369- plugins .contains (basenamePath)) {
389+ if (packages .isEmpty ||
390+ packages .contains (relativePath) ||
391+ packages .contains (basenamePath)) {
370392 yield PackageEnumerationEntry (
371393 RepositoryPackage (subdir as Directory ),
372394 excluded: excludedPluginNames.contains (basenamePath) ||
0 commit comments