Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 807305f

Browse files
committed
Merge pull request #3733 from ussuri/bower-use-git-salt-for-tags
Use git-salt's tag fetching i/o GitHub API to avoid hitting API rate limit
1 parent 7d0e230 commit 807305f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

ide/web/lib/package_mgmt/bower_fetcher.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class GitProvider {
6565
}
6666
}
6767

68+
GitProvider _gitProvider = null;
69+
6870
class BowerFetcher {
6971
static final _ZIP_TOP_LEVEL_DIR_RE = new RegExp('[^/]*\/');
7072

@@ -80,8 +82,6 @@ class BowerFetcher {
8082
final _unresolvedDepsComments = new Set<String>();
8183
final _ignoredDepsComments = new Set<String>();
8284

83-
GitProvider _gitProvider = null;
84-
8585
BowerFetcher(this._packagesDir, this._packageSpecFileName, this._monitor) {
8686
_packagesDir.createDirectory('.bower-git').then((dir) {
8787
_gitProvider = new GitProvider(dir);
@@ -456,6 +456,9 @@ class _Package {
456456
static final _BOWER_REGISTRY_INFO_URL_REGEXP =
457457
new RegExp(_BOWER_REGISTRY_INFO_URL);
458458

459+
static const _GIT_TAG = r'refs/tags/(.+)';
460+
static final _GIT_TAG_REGEXP = new RegExp(_GIT_TAG);
461+
459462
final String name;
460463
final String fullPath;
461464
String path;
@@ -567,15 +570,18 @@ class _Package {
567570
}
568571
}
569572

570-
return _fetchTags().then((List<Map<String, dynamic>> tags) {
573+
return _fetchTags().then((List<String> tags) {
571574
if (tags == null || tags.isEmpty) {
572575
return _resolveWith(_Unresolved.BAD_OR_MISSING_GITHUB_TAGS);
573576
}
574577

575578
List<semver.Version> candidateVersions = [];
576579

577580
for (final tag in tags) {
578-
final String tagName = tag['name'];
581+
final Match match = _GIT_TAG_REGEXP.matchAsPrefix(tag);
582+
if (match == null) continue;
583+
final String tagName = match.group(1);
584+
579585
try {
580586
final ver = new semver.Version.parse(tagName);
581587
if (constraint.allows(ver)) {
@@ -605,14 +611,8 @@ class _Package {
605611
});
606612
}
607613

608-
Future<List<Map<String, dynamic>>> _fetchTags() {
609-
return util.downloadFileViaXhr(getTagsUrl()).then((String tagsStr) {
610-
try {
611-
return JSON.decode(tagsStr);
612-
} on FormatException catch (e) {
613-
return null;
614-
}
615-
});
614+
Future<List<String>> _fetchTags() {
615+
return _gitProvider.operations.then((ops) => ops.lsRemoteRefs(getRootUrl()));
616616
}
617617

618618
Future<_Resolution> _resolveWith(_Resolution resolution) {

0 commit comments

Comments
 (0)