getVersions static method
Implementation
static Future<List<(String, Version)>> getVersions(String? root) async {
final tags = await getTags(root);
if (tags.isEmpty) {
throw const GitException('No tags found');
}
final versions = tags
.where((tag) => tag.isNotEmpty)
.map((tag) {
String version = tag;
if (tag.startsWith('v')) {
version = tag.substring(1);
}
try {
return (tag, Version.parse(version));
} catch (e) {
logger.detail('Skipping tag $tag . Not a valid version.');
return null;
}
})
.whereType<(String, Version)>()
.toList();
final sortedVersions = versions.toList()..sort((a, b) => a.$2.compareTo(b.$2));
return sortedVersions;
}