From 9725842dfb2931970438b4eddbe0578386526f6f Mon Sep 17 00:00:00 2001 From: Istvan Soos Date: Mon, 21 Oct 2024 17:39:49 +0200 Subject: [PATCH 1/3] Ignore git error on repository root detection. --- CHANGELOG.md | 1 + lib/src/package_analyzer.dart | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 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..1feff84a6 100644 --- a/lib/src/package_analyzer.dart +++ b/lib/src/package_analyzer.dart @@ -242,12 +242,16 @@ class PackageAnalyzer { } Future _detectGitRoot(String packageDir) async { - final pr = await runGitIsolated( - ['rev-parse', '--show-toplevel'], - workingDirectory: packageDir, - ); - if (pr.exitCode == 0) { - return pr.stdout.asString.trim(); + try { + final pr = await runGitIsolated( + ['rev-parse', '--show-toplevel'], + workingDirectory: packageDir, + ); + if (pr.exitCode == 0) { + return pr.stdout.asString.trim(); + } + } on GitToolException catch (_) { + // ignore exception } return null; } From 6e09fb4b2618ef54b57675b2c533c270ade91f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Thu, 24 Oct 2024 15:29:59 +0200 Subject: [PATCH 2/3] Update lib/src/package_analyzer.dart Co-authored-by: Sigurd Meldgaard --- lib/src/package_analyzer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/package_analyzer.dart b/lib/src/package_analyzer.dart index 1feff84a6..45c2fd563 100644 --- a/lib/src/package_analyzer.dart +++ b/lib/src/package_analyzer.dart @@ -251,7 +251,7 @@ Future _detectGitRoot(String packageDir) async { return pr.stdout.asString.trim(); } } on GitToolException catch (_) { - // ignore exception + // not in a git directory (or git is broken) - ignore exception } return null; } From 2f8f3c28f2ee2cb7806fbba54e21bd260629c502 Mon Sep 17 00:00:00 2001 From: Istvan Soos Date: Thu, 24 Oct 2024 15:55:26 +0200 Subject: [PATCH 3/3] remove == 0 check --- lib/src/package_analyzer.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/src/package_analyzer.dart b/lib/src/package_analyzer.dart index 45c2fd563..f89b92d0c 100644 --- a/lib/src/package_analyzer.dart +++ b/lib/src/package_analyzer.dart @@ -247,9 +247,7 @@ Future _detectGitRoot(String packageDir) async { ['rev-parse', '--show-toplevel'], workingDirectory: packageDir, ); - if (pr.exitCode == 0) { - return pr.stdout.asString.trim(); - } + return pr.stdout.asString.trim(); } on GitToolException catch (_) { // not in a git directory (or git is broken) - ignore exception }