refactor: remove currentVersion (#8708)

This commit is contained in:
Rhys Arkins 2021-02-16 09:43:38 +01:00 committed by GitHub
parent dae58a49c2
commit acf57144f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 32 additions and 28 deletions

View file

@ -88,7 +88,6 @@ Object {
"branchName": "{{{branchPrefix}}}{{{additionalBranchPrefix}}}{{{branchTopic}}}{{{packageFileDir}}}", "branchName": "{{{branchPrefix}}}{{{additionalBranchPrefix}}}{{{branchTopic}}}{{{packageFileDir}}}",
"branchPrefix": "renovate/", "branchPrefix": "renovate/",
"commitMessage": "{{#if semanticCommitType}}{{semanticCommitType}}{{#if semanticCommitScope}}({{semanticCommitScope}}){{/if}}: {{/if}}some commit message", "commitMessage": "{{#if semanticCommitType}}{{semanticCommitType}}{{#if semanticCommitScope}}({{semanticCommitScope}}){{/if}}: {{/if}}some commit message",
"commitMessageExtra": "{{currentValue}} something",
"constraints": Object { "constraints": Object {
"python": "3.7", "python": "3.7",
}, },
@ -323,6 +322,22 @@ Object {
} }
`; `;
exports[`config/migration migrateConfig(config, parentConfig) migrates packageRules objects 1`] = `
Object {
"packageRules": Array [
Object {
"commitMessage": "fix(package): update peerDependency to accept typescript ^{{newValue}} {{newValue}}",
"matchPackageNames": Array [
"typescript",
],
"matchUpdateTypes": Array [
"major",
],
},
],
}
`;
exports[`config/migration migrateConfig(config, parentConfig) migrates packages 1`] = ` exports[`config/migration migrateConfig(config, parentConfig) migrates packages 1`] = `
Object { Object {
"packageRules": Array [ "packageRules": Array [

View file

@ -76,7 +76,6 @@ describe('config/migration', () => {
commitMessage: '{{semanticPrefix}}some commit message', commitMessage: '{{semanticPrefix}}some commit message',
prTitle: '{{semanticPrefix}}some pr title', prTitle: '{{semanticPrefix}}some pr title',
semanticPrefix: 'fix(deps): ', semanticPrefix: 'fix(deps): ',
commitMessageExtra: '{{currentVersion}} something',
pathRules: [ pathRules: [
{ {
paths: ['examples/**'], paths: ['examples/**'],
@ -314,7 +313,7 @@ describe('config/migration', () => {
packageNames: ['typescript'], packageNames: ['typescript'],
updateTypes: ['major'], updateTypes: ['major'],
commitMessage: commitMessage:
'fix(package): update peerDependency to accept typescript ^{{newVersion}}', 'fix(package): update peerDependency to accept typescript ^{{newVersion}} {{newVersion}}',
}, },
} as any; } as any;
const { isMigrated, migratedConfig } = configMigration.migrateConfig( const { isMigrated, migratedConfig } = configMigration.migrateConfig(
@ -322,6 +321,7 @@ describe('config/migration', () => {
defaultConfig defaultConfig
); );
expect(isMigrated).toBe(true); expect(isMigrated).toBe(true);
expect(migratedConfig).toMatchSnapshot();
expect(migratedConfig.packageRules).toHaveLength(1); expect(migratedConfig.packageRules).toHaveLength(1);
}); });
it('migrates node to travis', () => { it('migrates node to travis', () => {

View file

@ -504,7 +504,7 @@ export function migrateConfig(
migratedConfig.binarySource = 'global'; migratedConfig.binarySource = 'global';
} }
const migratedTemplates = { const migratedTemplates = {
currentVersion: 'currentValue', currentVersion: 'toVersion',
newVersion: 'newValue', newVersion: 'newValue',
newValueMajor: 'newMajor', newValueMajor: 'newMajor',
newValueMinor: 'newMinor', newValueMinor: 'newMinor',

View file

@ -137,11 +137,11 @@ export async function getReleases({
dep.homepage = `https://registry.terraform.io/modules/${repository}`; dep.homepage = `https://registry.terraform.io/modules/${repository}`;
} }
// set published date for latest release // set published date for latest release
const currentVersion = dep.releases.find( const latestVersion = dep.releases.find(
(release) => res.version === release.version (release) => res.version === release.version
); );
if (currentVersion) { if (latestVersion) {
currentVersion.releaseTimestamp = res.published_at; latestVersion.releaseTimestamp = res.published_at;
} }
logger.trace({ dep }, 'dep'); logger.trace({ dep }, 'dep');
const cacheMinutes = 30; const cacheMinutes = 30;

View file

@ -59,12 +59,12 @@ async function queryRegistry(
version, version,
})); }));
// set published date for latest release // set published date for latest release
const currentVersion = dep.releases.find( const latestVersion = dep.releases.find(
(release) => res.version === release.version (release) => res.version === release.version
); );
// istanbul ignore else // istanbul ignore else
if (currentVersion) { if (latestVersion) {
currentVersion.releaseTimestamp = res.published_at; latestVersion.releaseTimestamp = res.published_at;
} }
dep.homepage = `${registryURL}/providers/${repository}`; dep.homepage = `${registryURL}/providers/${repository}`;
logger.trace({ dep }, 'dep'); logger.trace({ dep }, 'dep');

View file

@ -12,12 +12,12 @@ function updateWithNewVersion(
currentValue: string, currentValue: string,
newValue: string newValue: string
): string { ): string {
const currentVersion = currentValue.replace(/^v/, ''); const replaceFrom = currentValue.replace(/^v/, '');
const newVersion = newValue.replace(/^v/, ''); const replaceTo = newValue.replace(/^v/, '');
let newContent = content; let newContent = content;
do { do {
newContent = newContent.replace(currentVersion, newVersion); newContent = newContent.replace(replaceFrom, replaceTo);
} while (newContent.includes(currentVersion)); } while (newContent.includes(replaceFrom));
return newContent; return newContent;
} }

View file

@ -187,7 +187,6 @@ export interface Upgrade<T = Record<string, any>>
NpmLockFiles { NpmLockFiles {
isLockfileUpdate?: boolean; isLockfileUpdate?: boolean;
currentRawValue?: any; currentRawValue?: any;
currentVersion?: string;
depGroup?: string; depGroup?: string;
dockerRepository?: string; dockerRepository?: string;
localDir?: string; localDir?: string;

View file

@ -153,7 +153,6 @@ describe('manager/gomod/update', () => {
const upgrade = { const upgrade = {
depName: 'github.com/spf13/jwalterweatherman', depName: 'github.com/spf13/jwalterweatherman',
managerData: { lineNumber: 43, multiLine: true }, managerData: { lineNumber: 43, multiLine: true },
currentVersion: 'v0.0.0',
updateType: 'digest' as UpdateType, updateType: 'digest' as UpdateType,
currentDigest: '14d3d4c51834', currentDigest: '14d3d4c51834',
newDigest: '123456123456abcdef', newDigest: '123456123456abcdef',
@ -168,7 +167,6 @@ describe('manager/gomod/update', () => {
const upgrade = { const upgrade = {
depName: 'github.com/spf13/jwalterweatherman', depName: 'github.com/spf13/jwalterweatherman',
managerData: { lineNumber: 43, multiLine: true }, managerData: { lineNumber: 43, multiLine: true },
currentVersion: 'v0.0.0',
updateType: 'digest' as UpdateType, updateType: 'digest' as UpdateType,
currentDigest: 'abcdefabcdef', currentDigest: 'abcdefabcdef',
newDigest: '14d3d4c51834000000', newDigest: '14d3d4c51834000000',

View file

@ -40,7 +40,6 @@ export const allowedFields = {
baseBranch: 'The baseBranch for this branch/PR', baseBranch: 'The baseBranch for this branch/PR',
body: 'The body of the release notes', body: 'The body of the release notes',
currentValue: 'The extracted current value of the dependency being updated', currentValue: 'The extracted current value of the dependency being updated',
currentVersion: 'The current version that is being updated',
datasource: 'The datasource used to look up the upgrade', datasource: 'The datasource used to look up the upgrade',
depName: 'The name of the dependency being updated', depName: 'The name of the dependency being updated',
depNameLinked: depNameLinked:
@ -52,7 +51,7 @@ export const allowedFields = {
displayFrom: 'The current value, formatted for display', displayFrom: 'The current value, formatted for display',
displayTo: 'The to value, formatted for display', displayTo: 'The to value, formatted for display',
fromVersion: fromVersion:
'The version that would be currently installed. For example, if currentValue is ^3.0.0 then currentVersion might be 3.1.0.', 'The version that would be currently installed. For example, if currentValue is ^3.0.0 then fromVersion might be 3.1.0.',
hasReleaseNotes: 'true if the upgrade has release notes', hasReleaseNotes: 'true if the upgrade has release notes',
isLockfileUpdate: 'true if the branch is a lock file update', isLockfileUpdate: 'true if the branch is a lock file update',
isMajor: 'true if the upgrade is major', isMajor: 'true if the upgrade is major',

View file

@ -31,7 +31,6 @@ export interface BranchUpgradeConfig
currentDigest?: string; currentDigest?: string;
currentDigestShort?: string; currentDigestShort?: string;
currentValue?: string; currentValue?: string;
currentVersion?: string;
endpoint?: string; endpoint?: string;
excludeCommitPaths?: string[]; excludeCommitPaths?: string[];
githubName?: string; githubName?: string;

View file

@ -48,8 +48,6 @@ export async function flattenUpdates(
for (const update of dep.updates) { for (const update of dep.updates) {
let updateConfig = mergeChildConfig(depConfig, update); let updateConfig = mergeChildConfig(depConfig, update);
delete updateConfig.updates; delete updateConfig.updates;
// Massage legacy vars just in case
updateConfig.currentVersion = updateConfig.currentValue;
updateConfig.newVersion = updateConfig.newVersion =
updateConfig.newVersion || updateConfig.newValue; updateConfig.newVersion || updateConfig.newValue;
if (updateConfig.updateType) { if (updateConfig.updateType) {

View file

@ -120,8 +120,7 @@ export function generateBranchConfig(
} }
if (!upgrade.displayFrom) { if (!upgrade.displayFrom) {
if (upgrade.currentValue === upgrade.newValue) { if (upgrade.currentValue === upgrade.newValue) {
upgrade.displayFrom = upgrade.displayFrom = upgrade.currentDigestShort || '';
upgrade.currentDigestShort || upgrade.currentVersion || '';
upgrade.displayTo = upgrade.displayTo =
upgrade.displayTo || upgrade.displayTo ||
upgrade.newDigestShort || upgrade.newDigestShort ||
@ -129,10 +128,7 @@ export function generateBranchConfig(
''; '';
} else { } else {
upgrade.displayFrom = upgrade.displayFrom =
upgrade.currentValue || upgrade.currentValue || upgrade.currentDigestShort || '';
upgrade.currentVersion ||
upgrade.currentDigestShort ||
'';
upgrade.displayTo = upgrade.displayTo =
upgrade.displayTo || upgrade.displayTo ||
upgrade.newValue || upgrade.newValue ||