From 95276368378ef5bbfb16481598dca146c2d5a950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Thu, 24 Oct 2024 15:44:07 +0200 Subject: [PATCH] Ignore git error on repository root detection. (#1413) --- CHANGELOG.md | 1 + lib/src/package_analyzer.dart | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f474b1c4f..5c8092c0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 0.22.14 +- Fixes issue with local analysis without git repository root. - Accept `logger` in `PackageAnalyzer.inspectDir` method. ## 0.22.13 diff --git a/lib/src/package_analyzer.dart b/lib/src/package_analyzer.dart index 71dd93430..f89b92d0c 100644 --- a/lib/src/package_analyzer.dart +++ b/lib/src/package_analyzer.dart @@ -242,12 +242,14 @@ class PackageAnalyzer { } Future _detectGitRoot(String packageDir) async { - final pr = await runGitIsolated( - ['rev-parse', '--show-toplevel'], - workingDirectory: packageDir, - ); - if (pr.exitCode == 0) { + try { + final pr = await runGitIsolated( + ['rev-parse', '--show-toplevel'], + workingDirectory: packageDir, + ); return pr.stdout.asString.trim(); + } on GitToolException catch (_) { + // not in a git directory (or git is broken) - ignore exception } return null; }