Add more debug output to snippet git failures (#83806)

This commit is contained in:
Greg Spencer 2021-06-02 15:34:28 -07:00 committed by GitHub
parent 8f866ab5f4
commit bb40270069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,9 +23,12 @@ const String _kShowDartPad = 'dartpad';
String getChannelName() {
final RegExp gitBranchRegexp = RegExp(r'^## (?<branch>.*)');
final ProcessResult gitResult = Process.runSync('git', <String>['status', '-b', '--porcelain']);
final ProcessResult gitResult = Process.runSync('git', <String>['status', '-b', '--porcelain'], environment: <String, String>{
'GIT_TRACE': '2',
'GIT_TRACE_SETUP': '2',
}, includeParentEnvironment: true);
if (gitResult.exitCode != 0)
throw 'git status exit with non-zero exit code: ${gitResult.exitCode}';
throw 'git status exit with non-zero exit code: ${gitResult.exitCode}: ${gitResult.stderr}';
final RegExpMatch? gitBranchMatch = gitBranchRegexp.firstMatch(
(gitResult.stdout as String).trim().split('\n').first);
return gitBranchMatch == null ? '<unknown>' : gitBranchMatch.namedGroup('branch')!.split('...').first;