@@ -380,7 +380,7 @@ abstract class Repository {
380380
381381 /// Determines if one ref is an ancestor for another.
382382 Future <bool > isAncestor (String possibleAncestor, String possibleDescendant) async {
383- final int exitcode = await git.run (
383+ final io. ProcessResult result = await git.run (
384384 < String > [
385385 'merge-base' ,
386386 '--is-ancestor' ,
@@ -391,18 +391,18 @@ abstract class Repository {
391391 allowNonZeroExitCode: true ,
392392 workingDirectory: (await checkoutDirectory).path,
393393 );
394- return exitcode == 0 ;
394+ return result.exitCode == 0 ;
395395 }
396396
397397 /// Determines if a given commit has a tag.
398398 Future <bool > isCommitTagged (String commit) async {
399- final int exitcode = await git.run (
399+ final io. ProcessResult result = await git.run (
400400 < String > ['describe' , '--exact-match' , '--tags' , commit],
401401 'verify $commit is already tagged' ,
402402 allowNonZeroExitCode: true ,
403403 workingDirectory: (await checkoutDirectory).path,
404404 );
405- return exitcode == 0 ;
405+ return result.exitCode == 0 ;
406406 }
407407
408408 /// Resets repository HEAD to [ref] .
@@ -480,16 +480,27 @@ abstract class Repository {
480480 }
481481 authorArg = '--author="$author "' ;
482482 }
483- await git.run (
484- < String > [
485- 'commit' ,
486- '--message' ,
487- message,
488- if (authorArg != null ) authorArg,
489- ],
483+ final List <String > commitCmd = < String > [
484+ 'commit' ,
485+ '--message' ,
486+ message,
487+ if (authorArg != null ) authorArg,
488+ ];
489+ stdio.printTrace ('Executing git $commitCmd ...' );
490+ final io.ProcessResult commitResult = await git.run (
491+ commitCmd,
490492 'commit changes' ,
491493 workingDirectory: (await checkoutDirectory).path,
492494 );
495+ final String stdout = commitResult.stdout as String ;
496+ if (stdout.isNotEmpty) {
497+ stdio.printTrace (stdout);
498+ }
499+ final String stderr = commitResult.stderr as String ;
500+ if (stderr.isNotEmpty) {
501+ stdio.printTrace (stderr);
502+ }
503+
493504 return reverseParse ('HEAD' );
494505 }
495506
@@ -608,31 +619,60 @@ class FrameworkRepository extends Repository {
608619 ]);
609620 }
610621
611- Future <io.ProcessResult > runDart (List <String > args) async {
612- return processManager.run (< String > [
613- fileSystem.path.join ((await checkoutDirectory).path, 'bin' , 'dart' ),
614- ...args,
615- ]);
616- }
617-
618622 Future <io.ProcessResult > runFlutter (List <String > args) async {
619623 await _ensureToolReady ();
620- return processManager.run (< String > [
621- fileSystem.path.join ((await checkoutDirectory).path, 'bin' , 'flutter' ),
622- ...args,
623- ]);
624+ final String workingDirectory = (await checkoutDirectory).path;
625+ return processManager.run (
626+ < String > [
627+ fileSystem.path.join (workingDirectory, 'bin' , 'flutter' ),
628+ ...args,
629+ ],
630+ workingDirectory: workingDirectory,
631+ );
632+ }
633+
634+ Future <void > streamDart (
635+ List <String > args, {
636+ String ? workingDirectory,
637+ }) async {
638+ final String repoWorkingDirectory = (await checkoutDirectory).path;
639+
640+ await _streamProcess (
641+ < String > [
642+ fileSystem.path.join (repoWorkingDirectory, 'bin' , 'dart' ),
643+ ...args,
644+ ],
645+ workingDirectory: workingDirectory ?? repoWorkingDirectory,
646+ );
624647 }
625648
626649 Future <io.Process > streamFlutter (
627650 List <String > args, {
628651 void Function (String )? stdoutCallback,
629652 void Function (String )? stderrCallback,
630653 }) async {
631- await _ensureToolReady ();
632- final io.Process process = await processManager.start (< String > [
633- fileSystem.path.join ((await checkoutDirectory).path, 'bin' , 'flutter' ),
634- ...args,
635- ]);
654+ final String workingDirectory = (await checkoutDirectory).path;
655+
656+ return _streamProcess (
657+ < String > [
658+ fileSystem.path.join (workingDirectory, 'bin' , 'flutter' ),
659+ ...args,
660+ ],
661+ workingDirectory: workingDirectory,
662+ );
663+ }
664+
665+ Future <io.Process > _streamProcess (
666+ List <String > cmd, {
667+ void Function (String )? stdoutCallback,
668+ void Function (String )? stderrCallback,
669+ String ? workingDirectory,
670+ }) async {
671+ stdio.printTrace ('Executing $cmd ...' );
672+ final io.Process process = await processManager.start (
673+ cmd,
674+ workingDirectory: workingDirectory,
675+ );
636676 process
637677 .stdout
638678 .transform (utf8.decoder)
@@ -643,6 +683,15 @@ class FrameworkRepository extends Repository {
643683 .transform (utf8.decoder)
644684 .transform (const LineSplitter ())
645685 .listen (stderrCallback ?? stdio.printError);
686+ final int exitCode = await process.exitCode;
687+ if (exitCode != 0 ) {
688+ throw io.ProcessException (
689+ cmd.first,
690+ cmd.sublist (1 ),
691+ 'Process failed' ,
692+ exitCode,
693+ );
694+ }
646695 return process;
647696 }
648697
0 commit comments