Skip to content

Commit

Permalink
refactor: lookup updates loop
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 12, 2021
1 parent 55afac8 commit e61a32a
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,20 @@ export async function lookupUpdates(
update.newMinor = version.getMinor(toVersion);
update.updateType =
update.updateType || getType(config, update.fromVersion, toVersion);

const bucket = getBucket(config, update);
if (buckets[bucket]) {
buckets[bucket].push(update);
} else {
buckets[bucket] = [update];
}
}
for (const updates of Object.values(buckets)) {
const sortedUpdates = updates.sort((u1, u2) =>
version.sortVersions(u1.toVersion, u2.toVersion)
);
const update = sortedUpdates.pop();
const { toVersion } = update;
update.isSingleVersion =
update.isSingleVersion || !!version.isSingleVersion(update.newValue);
if (!version.isVersion(update.newValue)) {
Expand All @@ -359,19 +373,6 @@ export async function lookupUpdates(
update[field] = updateRelease[field] as never;
}
});

const bucket = getBucket(config, update);
if (buckets[bucket]) {
buckets[bucket].push(update);
} else {
buckets[bucket] = [update];
}
}
for (const updates of Object.values(buckets)) {
const sortedUpdates = updates.sort((u1, u2) =>
version.sortVersions(u1.toVersion, u2.toVersion)
);
const update = sortedUpdates.pop();
if (sortedUpdates.length) {
update.skippedOverVersions = sortedUpdates.map((u) => u.toVersion);
}
Expand Down

0 comments on commit e61a32a

Please sign in to comment.