Skip to content

Commit

Permalink
fix(lookup): currentVersion = lockedVersion (#12922)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Dec 2, 2021
1 parent e8e99ef commit 8e156ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
3 changes: 0 additions & 3 deletions lib/workers/repository/process/lookup/current.ts
Expand Up @@ -11,9 +11,6 @@ export function getCurrentVersion(
latestVersion: string,
allVersions: string[]
): string | null {
if (lockedVersion && is.undefined(currentValue)) {
return allVersions.pop();
}
// istanbul ignore if
if (!is.string(currentValue)) {
return null;
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/process/lookup/filter.ts
Expand Up @@ -29,6 +29,7 @@ export function filterVersions(
}
return true;
}
// istanbul ignore if: shouldn't happen
if (!currentVersion) {
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/process/lookup/index.spec.ts
Expand Up @@ -351,7 +351,7 @@ describe('workers/repository/process/lookup/index', () => {
expect(res.updates).toMatchInlineSnapshot(`
Array [
Object {
"bucket": "major",
"bucket": "non-major",
"isLockfileUpdate": true,
"isRange": true,
"newMajor": 1,
Expand Down
23 changes: 10 additions & 13 deletions lib/workers/repository/process/lookup/index.ts
Expand Up @@ -169,7 +169,11 @@ export async function lookupUpdates(
const nonDeprecatedVersions = dependency.releases
.filter((release) => !release.isDeprecated)
.map((release) => release.version);
const currentVersion =
let currentVersion: string;
if (rangeStrategy === 'update-lockfile') {
currentVersion = lockedVersion;
}
currentVersion ??=
getCurrentVersion(
currentValue,
lockedVersion,
Expand Down Expand Up @@ -209,22 +213,15 @@ export async function lookupUpdates(
newMajor: versioning.getMajor(currentVersion),
});
}
let filterStart = currentVersion;
if (lockedVersion) {
// istanbul ignore if
if (!versioning.isVersion(lockedVersion)) {
res.skipReason = SkipReason.InvalidVersion;
return res;
}
if (rangeStrategy === 'update-lockfile') {
// Look for versions greater than the current locked version that still satisfy the package.json range
filterStart = lockedVersion;
}
// istanbul ignore if
if (!versioning.isVersion(currentVersion)) {
res.skipReason = SkipReason.InvalidVersion;
return res;
}
// Filter latest, unstable, etc
let filteredReleases = filterVersions(
config,
filterStart,
currentVersion,
latestVersion,
allVersions,
versioning
Expand Down

0 comments on commit 8e156ef

Please sign in to comment.