fix tryGitCommand (#2789)
diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart
index 4e49504..823d70f 100644
--- a/lib/src/exceptions.dart
+++ b/lib/src/exceptions.dart
@@ -26,6 +26,12 @@
String toString() => message;
}
+/// A subclass of [ApplicationException] that occurs when running a subprocess
+/// has failed.
+class RunProcessException extends ApplicationException {
+ RunProcessException(String message) : super(message);
+}
+
/// An exception class for exceptions that are intended to be seen by the user
/// and are associated with a problem in a file at some path.
class FileException implements ApplicationException {
diff --git a/lib/src/git.dart b/lib/src/git.dart
index 6117c63..2928a65 100644
--- a/lib/src/git.dart
+++ b/lib/src/git.dart
@@ -4,9 +4,6 @@
/// Helper functionality for invoking Git.
import 'dart:async';
-import 'dart:io';
-
-import 'package:stack_trace/stack_trace.dart';
import 'exceptions.dart';
import 'io.dart';
@@ -113,10 +110,9 @@
var result = runProcessSync(command, ['--version']);
var regexp = RegExp('^git version');
return result.stdout.length == 1 && regexp.hasMatch(result.stdout.single);
- } on ProcessException catch (error, stackTrace) {
- var chain = Chain.forTrace(stackTrace);
+ } on RunProcessException catch (err) {
// If the process failed, they probably don't have it.
- log.error('Git command is not "$command": $error\n$chain');
+ log.error('Git command is not "$command": $err');
return false;
}
}
diff --git a/lib/src/io.dart b/lib/src/io.dart
index 2c25244..933c640 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -561,7 +561,7 @@
environment: environment,
runInShell: runInShell);
} on IOException catch (e) {
- throw ApplicationException(
+ throw RunProcessException(
'Pub failed to run subprocess `$executable`: $e');
}
@@ -591,7 +591,7 @@
environment: environment,
runInShell: runInShell);
} on IOException catch (e) {
- throw ApplicationException(
+ throw RunProcessException(
'Pub failed to run subprocess `$executable`: $e');
}
@@ -614,8 +614,7 @@
environment: environment,
runInShell: runInShell);
} on IOException catch (e) {
- throw ApplicationException(
- 'Pub failed to run subprocess `$executable`: $e');
+ throw RunProcessException('Pub failed to run subprocess `$executable`: $e');
}
var pubResult =
PubProcessResult(result.stdout, result.stderr, result.exitCode);
diff --git a/test/get/git/git_not_installed.dart b/test/get/git/git_not_installed_test.dart
similarity index 100%
rename from test/get/git/git_not_installed.dart
rename to test/get/git/git_not_installed_test.dart