Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lookup): currentVersion = lockedVersion #12922

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/workers/repository/process/lookup/current.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function filterVersions(
}
return true;
}
// istanbul ignore if: shouldn't happen
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will happen but also don't want to remove it in case I'm wrong

if (!currentVersion) {
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/process/lookup/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ describe('workers/repository/process/lookup/index', () => {
expect(res.updates).toMatchInlineSnapshot(`
Array [
Object {
"bucket": "major",
"bucket": "non-major",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.2.1 -> 1.4.1

"isLockfileUpdate": true,
"isRange": true,
"newMajor": 1,
Expand Down
23 changes: 10 additions & 13 deletions lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
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