Skip to content

Commit 9527636

Browse files
authored
Ignore git error on repository root detection. (#1413)
1 parent 7be4153 commit 9527636

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 0.22.14
22

3+
- Fixes issue with local analysis without git repository root.
34
- Accept `logger` in `PackageAnalyzer.inspectDir` method.
45

56
## 0.22.13

lib/src/package_analyzer.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,14 @@ class PackageAnalyzer {
242242
}
243243

244244
Future<String?> _detectGitRoot(String packageDir) async {
245-
final pr = await runGitIsolated(
246-
['rev-parse', '--show-toplevel'],
247-
workingDirectory: packageDir,
248-
);
249-
if (pr.exitCode == 0) {
245+
try {
246+
final pr = await runGitIsolated(
247+
['rev-parse', '--show-toplevel'],
248+
workingDirectory: packageDir,
249+
);
250250
return pr.stdout.asString.trim();
251+
} on GitToolException catch (_) {
252+
// not in a git directory (or git is broken) - ignore exception
251253
}
252254
return null;
253255
}

0 commit comments

Comments
 (0)