Skip to content

Commit 9409905

Browse files
committed
Address kevmoo's review comments:
- Use .isNotEmpty instead of .length > 0 - Make some methods async
1 parent aad3a12 commit 9409905

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/src/source/git.dart

+11-11
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class GitSource extends CachedSource {
7676
} on FormatException {}
7777
}
7878

79-
if (validVersions.length > 0) {
79+
if (validVersions.isNotEmpty) {
8080
return validVersions;
8181
}
8282

@@ -302,7 +302,7 @@ class GitSource extends CachedSource {
302302
/// by [id] on the effective ref of [id].
303303
///
304304
/// This assumes that the canonical clone already exists.
305-
Future<String> _getRev(PackageId id) {
305+
Future<String> _getRev(PackageId id) async {
306306
var ref = _getEffectiveRef(id);
307307
return git
308308
.run(["rev-list", "--max-count=1", ref], workingDir: _repoCachePath(id))
@@ -344,7 +344,7 @@ class GitSource extends CachedSource {
344344
}
345345

346346
/// Checks out the reference [ref] in [repoPath].
347-
Future _checkOut(String repoPath, String ref) {
347+
Future _checkOut(String repoPath, String ref) async {
348348
return git.run(["checkout", ref], workingDir: repoPath)
349349
.then((result) => null)
350350
.catchError((_) {
@@ -359,14 +359,14 @@ class GitSource extends CachedSource {
359359
///
360360
/// It is possible that a pubspec didn't always exist, return null if
361361
/// that is the case.
362-
Future<Pubspec> _getPubspec(String repoPath, String ref) {
363-
return git.run(['show', '$ref:pubspec.yaml'], workingDir: repoPath)
364-
.catchError((_) => null)
365-
.then((result) {
366-
if (result != null) {
367-
return new Pubspec.parse(result.join('\n'), systemCache.sources);
368-
}
369-
});
362+
Future<Pubspec> _getPubspec(String repoPath, String ref) async {
363+
try {
364+
var result = await git.run(['show', '$ref:pubspec.yaml'],
365+
workingDir: repoPath);
366+
return new Pubspec.parse(result.join('\n'), systemCache.sources);
367+
} on git.GitException {
368+
return null;
369+
}
370370
}
371371

372372
/// Returns the path to the canonical clone of the repository referred to by

0 commit comments

Comments
 (0)