diff --git a/lib/App/Multigit.pm b/lib/App/Multigit.pm index d22a916..a33b79e 100644 --- a/lib/App/Multigit.pm +++ b/lib/App/Multigit.pm @@ -83,6 +83,7 @@ our %BEHAVIOUR = ( report_on_no_output => $ENV{MG_REPORT_ON_NO_OUTPUT} // 1, ignore_stdout => !!$ENV{MG_IGNORE_STDOUT}, ignore_stderr => !!$ENV{MG_IGNORE_STDERR}, + list_repos => $ENV{MG_LIST_REPOS}, concurrent => $ENV{MG_CONCURRENT_PROCESSES} // 20, skip_readonly => !!$ENV{MG_SKIP_READONLY}, ); diff --git a/lib/App/Multigit/Repo.pm b/lib/App/Multigit/Repo.pm index 1c793c9..2d0c191 100644 --- a/lib/App/Multigit/Repo.pm +++ b/lib/App/Multigit/Repo.pm @@ -252,6 +252,8 @@ sub report { return Future->done unless $App::Multigit::BEHAVIOUR{report_on_no_output} or $output =~ s/\s//gr; + $output = '' if $App::Multigit::BEHAVIOUR{list_repos}; + return Future->done( $dir => $output ); diff --git a/script/mg b/script/mg index 174d5a9..7ea29fc 100755 --- a/script/mg +++ b/script/mg @@ -25,6 +25,7 @@ sub usage; 'verbose|v' => sub { $qs--; }, + 'list|l' => \$ENV{MG_LIST_REPOS}, 'concurrent|c=i' => \$ENV{MG_CONCURRENT_PROCESSES}, 'skip-readonly' => \$ENV{MG_SKIP_READONLY}, ); @@ -108,4 +109,23 @@ might use this. Skip readonly repositories. Repositories marked readonly = 1 in the .mgconfig will be ignored by whatever command you run. +=item -l + +=item --list + +List repositories that would produce output. This is useful for piping the list +of repositories to another mg each. + +For example, + + mg -l st -uno | mg each git push + +Note that mg grep does a very similar thing and may be more appropriate. + + mg grep git not-master + +Is roughly equivalent to, + + mg -lq each git not-master + =back