Skip to content

Commit

Permalink
refactor: fromVersion -> currentVersion (#8709)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 16, 2021
1 parent 5b38d39 commit a8819c4
Show file tree
Hide file tree
Showing 56 changed files with 501 additions and 448 deletions.
2 changes: 1 addition & 1 deletion docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The command to install dependencies is necessary because, by default, the instal
"postUpgradeTasks": {
"commands": [
"npm ci --ignore-scripts",
"npx ng update {{{depName}}} --from={{{fromVersion}}} --to={{{toVersion}}} --migrateOnly --allowDirty --force"
"npx ng update {{{depName}}} --from={{{currentVersion}}} --to={{{toVersion}}} --migrateOnly --allowDirty --force"
],
"fileFilters": ["**/**"]
}
Expand Down
2 changes: 1 addition & 1 deletion lib/config/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ export function migrateConfig(
migratedConfig.binarySource = 'global';
}
const migratedTemplates = {
currentVersion: 'fromVersion',
fromVersion: 'currentVersion',
newVersion: 'newValue',
newValueMajor: 'newMajor',
newValueMinor: 'newMinor',
Expand Down
4 changes: 2 additions & 2 deletions lib/manager/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export interface LookupUpdate {
isRange?: boolean;
isRollback?: boolean;
isSingleVersion?: boolean;
fromVersion?: string;
currentVersion?: string;
newDigest?: string;
newDigestShort?: string;
newMajor?: number;
Expand All @@ -165,7 +165,7 @@ export interface PackageDependency<T = Record<string, any>> extends Package<T> {
displayFrom?: string;
displayTo?: string;
fixedVersion?: string;
fromVersion?: string;
currentVersion?: string;
lockedVersion?: string;
propSource?: string;
registryUrls?: string[];
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/npm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export const defaultConfig = {
versioning: npmVersioning.id,
prBodyDefinitions: {
Change:
"[{{#if displayFrom}}`{{{displayFrom}}}` -> {{else}}{{#if currentValue}}`{{{currentValue}}}` -> {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}]({{#if depName}}https://renovatebot.com/diffs/npm/{{replace '/' '%2f' depName}}/{{{fromVersion}}}/{{{toVersion}}}{{/if}})",
"[{{#if displayFrom}}`{{{displayFrom}}}` -> {{else}}{{#if currentValue}}`{{{currentValue}}}` -> {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}]({{#if depName}}https://renovatebot.com/diffs/npm/{{replace '/' '%2f' depName}}/{{{currentVersion}}}/{{{toVersion}}}{{/if}})",
},
};
60 changes: 30 additions & 30 deletions lib/manager/pip_requirements/__snapshots__/extract.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ Object {
"deps": Array [
Object {
"currentValue": "==0.3.1",
"currentVersion": "0.3.1",
"datasource": "pypi",
"depName": "some-package",
"fromVersion": "0.3.1",
},
Object {
"currentValue": "==1.0.0",
"currentVersion": "1.0.0",
"datasource": "pypi",
"depName": "some-other-package",
"fromVersion": "1.0.0",
},
Object {
"currentValue": "==1.9",
"currentVersion": "1.9",
"datasource": "pypi",
"depName": "not_semver",
"fromVersion": "1.9",
},
],
"registryUrls": Array [
Expand All @@ -32,33 +32,33 @@ exports[`lib/manager/pip_requirements/extract extractPackageFile() extracts mult
Array [
Object {
"currentValue": "==1",
"currentVersion": "1",
"datasource": "pypi",
"depName": "Django",
"fromVersion": "1",
},
Object {
"currentValue": "==0.6.27",
"currentVersion": "0.6.27",
"datasource": "pypi",
"depName": "distribute",
"fromVersion": "0.6.27",
},
Object {
"currentValue": "==0.2",
"currentVersion": "0.2",
"datasource": "pypi",
"depName": "dj-database-url",
"fromVersion": "0.2",
},
Object {
"currentValue": "==2.4.5",
"currentVersion": "2.4.5",
"datasource": "pypi",
"depName": "psycopg2",
"fromVersion": "2.4.5",
},
Object {
"currentValue": "==0.1.2",
"currentVersion": "0.1.2",
"datasource": "pypi",
"depName": "wsgiref",
"fromVersion": "0.1.2",
},
]
`;
Expand All @@ -67,34 +67,34 @@ exports[`lib/manager/pip_requirements/extract extractPackageFile() handles comme
Array [
Object {
"currentValue": "==1.11.23",
"currentVersion": "1.11.23",
"datasource": "pypi",
"depName": "Django",
"fromVersion": "1.11.23",
},
Object {
"currentValue": "==0.6.27",
"currentVersion": "0.6.27",
"datasource": "pypi",
"depName": "distribute",
"fromVersion": "0.6.27",
"skipReason": "ignored",
},
Object {
"currentValue": "==0.2",
"currentVersion": "0.2",
"datasource": "pypi",
"depName": "dj-database-url",
"fromVersion": "0.2",
},
Object {
"currentValue": "==2.4.5",
"currentVersion": "2.4.5",
"datasource": "pypi",
"depName": "psycopg2",
"fromVersion": "2.4.5",
},
Object {
"currentValue": "==0.1.2",
"currentVersion": "0.1.2",
"datasource": "pypi",
"depName": "wsgiref",
"fromVersion": "0.1.2",
},
]
`;
Expand All @@ -104,15 +104,15 @@ Object {
"deps": Array [
Object {
"currentValue": "==2.0.12",
"currentVersion": "2.0.12",
"datasource": "pypi",
"depName": "Django",
"fromVersion": "2.0.12",
},
Object {
"currentValue": "==4.1.1",
"currentVersion": "4.1.1",
"datasource": "pypi",
"depName": "celery",
"fromVersion": "4.1.1",
},
Object {
"currentValue": " == 3.2.1",
Expand All @@ -121,21 +121,21 @@ Object {
},
Object {
"currentValue": "==0.3.1",
"currentVersion": "0.3.1",
"datasource": "pypi",
"depName": "some-package",
"fromVersion": "0.3.1",
},
Object {
"currentValue": "==1.0.0",
"currentVersion": "1.0.0",
"datasource": "pypi",
"depName": "some-other-package",
"fromVersion": "1.0.0",
},
Object {
"currentValue": "==1.9",
"currentVersion": "1.9",
"datasource": "pypi",
"depName": "not_semver",
"fromVersion": "1.9",
},
],
"registryUrls": Array [
Expand All @@ -150,15 +150,15 @@ Object {
"deps": Array [
Object {
"currentValue": "==2.0.12",
"currentVersion": "2.0.12",
"datasource": "pypi",
"depName": "Django",
"fromVersion": "2.0.12",
},
Object {
"currentValue": "==4.1.1",
"currentVersion": "4.1.1",
"datasource": "pypi",
"depName": "celery",
"fromVersion": "4.1.1",
},
Object {
"currentValue": " == 3.2.1",
Expand All @@ -167,21 +167,21 @@ Object {
},
Object {
"currentValue": "==0.3.1",
"currentVersion": "0.3.1",
"datasource": "pypi",
"depName": "some-package",
"fromVersion": "0.3.1",
},
Object {
"currentValue": "==1.0.0",
"currentVersion": "1.0.0",
"datasource": "pypi",
"depName": "some-other-package",
"fromVersion": "1.0.0",
},
Object {
"currentValue": "==1.9",
"currentVersion": "1.9",
"datasource": "pypi",
"depName": "not_semver",
"fromVersion": "1.9",
},
],
"registryUrls": Array [
Expand All @@ -196,15 +196,15 @@ Object {
"deps": Array [
Object {
"currentValue": "==2.0.12",
"currentVersion": "2.0.12",
"datasource": "pypi",
"depName": "Django",
"fromVersion": "2.0.12",
},
Object {
"currentValue": "==4.1.1",
"currentVersion": "4.1.1",
"datasource": "pypi",
"depName": "celery",
"fromVersion": "4.1.1",
},
Object {
"currentValue": " == 3.2.1",
Expand All @@ -213,21 +213,21 @@ Object {
},
Object {
"currentValue": "==0.3.1",
"currentVersion": "0.3.1",
"datasource": "pypi",
"depName": "some-package",
"fromVersion": "0.3.1",
},
Object {
"currentValue": "==1.0.0",
"currentVersion": "1.0.0",
"datasource": "pypi",
"depName": "some-other-package",
"fromVersion": "1.0.0",
},
Object {
"currentValue": "==1.9",
"currentVersion": "1.9",
"datasource": "pypi",
"depName": "not_semver",
"fromVersion": "1.9",
},
],
"registryUrls": Array [
Expand All @@ -242,15 +242,15 @@ Object {
"deps": Array [
Object {
"currentValue": "==2.0.12",
"currentVersion": "2.0.12",
"datasource": "pypi",
"depName": "Django",
"fromVersion": "2.0.12",
},
Object {
"currentValue": "==4.1.1",
"currentVersion": "4.1.1",
"datasource": "pypi",
"depName": "celery",
"fromVersion": "4.1.1",
},
Object {
"currentValue": " == 3.2.1",
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/pip_requirements/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function extractPackageFile(
datasource: datasourcePypi.id,
};
if (currentValue?.startsWith('==')) {
dep.fromVersion = currentValue.replace(/^==/, '');
dep.currentVersion = currentValue.replace(/^==/, '');
}
return dep;
})
Expand Down
13 changes: 13 additions & 0 deletions lib/util/cache/repository/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ describe('lib/util/cache/repository', () => {
expect(fs.readFile.mock.calls).toHaveLength(1);
expect(fs.outputFile.mock.calls).toHaveLength(1);
});
it('migrates', async () => {
fs.readFile.mockResolvedValueOnce(
'{"repository":"abc/def","branches":[{"upgrades":[{"fromVersion":"1.0.0"}]}]}' as any
);
await repositoryCache.initialize({
...config,
repositoryCache: 'enabled',
});
expect(repositoryCache.getCache().branches[0].upgrades[0]).toEqual({
currentVersion: '1.0.0',
});
await repositoryCache.finalize();
});
it('gets', () => {
expect(repositoryCache.getCache()).toEqual({ scan: {} });
});
Expand Down
11 changes: 10 additions & 1 deletion lib/util/cache/repository/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface BranchUpgradeCache {
datasource?: string;
depName?: string;
fixedVersion?: string;
fromVersion?: string;
currentVersion?: string;
lookupName?: string;
newDigest?: string;
newValue?: string;
Expand Down Expand Up @@ -87,6 +87,15 @@ export function getCache(): Cache {
cache = cache || Object.create({});
delete cache.init;
cache.scan = cache.scan || Object.create({});
for (const branch of cache.branches || []) {
for (const upgrade of (branch.upgrades || []) as any) {
// migrate fromVersion to currentVersion
if (upgrade.fromVersion) {
upgrade.currentVersion = upgrade.fromVersion;
delete upgrade.fromVersion;
}
}
}
return cache;
}

Expand Down

0 comments on commit a8819c4

Please sign in to comment.