@@ -67,10 +67,12 @@ class GitSource extends CachedSource {
67
67
}
68
68
try {
69
69
// Use Version.parse to determine valid version tags
70
- PackageId packageAtVersion = new PackageId (
71
- name, this .name, new Version .parse (version), description);
70
+ Version validVersion = new Version .parse (version);
72
71
// Fetch the pubspec for this version
73
- validVersions.add (await describeUncached (packageAtVersion));
72
+ Pubspec pubspec = await _getPubspec (cachePath, validVersion.toString ());
73
+ if (pubspec != null ) {
74
+ validVersions.add (pubspec);
75
+ }
74
76
} on FormatException {}
75
77
}
76
78
@@ -352,6 +354,21 @@ class GitSource extends CachedSource {
352
354
});
353
355
}
354
356
357
+ /// Use `git show` to get the pubspec.yaml at a particular ref,
358
+ /// then parse it into a Pubspec object
359
+ ///
360
+ /// It is possible that a pubspec didn't always exist, return null if
361
+ /// 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
+ });
370
+ }
371
+
355
372
/// Returns the path to the canonical clone of the repository referred to by
356
373
/// [id] (the one in `<system cache>/git/cache` ).
357
374
String _repoCachePath (PackageId id) {
0 commit comments