Skip to content

Commit

Permalink
refactor: remove currentVersion (#8708)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 16, 2021
1 parent dae58a4 commit acf5714
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 28 deletions.
17 changes: 16 additions & 1 deletion lib/config/__snapshots__/migration.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ Object {
"branchName": "{{{branchPrefix}}}{{{additionalBranchPrefix}}}{{{branchTopic}}}{{{packageFileDir}}}",
"branchPrefix": "renovate/",
"commitMessage": "{{#if semanticCommitType}}{{semanticCommitType}}{{#if semanticCommitScope}}({{semanticCommitScope}}){{/if}}: {{/if}}some commit message",
"commitMessageExtra": "{{currentValue}} something",
"constraints": Object {
"python": "3.7",
},
Expand Down Expand Up @@ -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`] = `
Object {
"packageRules": Array [
Expand Down
4 changes: 2 additions & 2 deletions lib/config/migration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ describe('config/migration', () => {
commitMessage: '{{semanticPrefix}}some commit message',
prTitle: '{{semanticPrefix}}some pr title',
semanticPrefix: 'fix(deps): ',
commitMessageExtra: '{{currentVersion}} something',
pathRules: [
{
paths: ['examples/**'],
Expand Down Expand Up @@ -314,14 +313,15 @@ describe('config/migration', () => {
packageNames: ['typescript'],
updateTypes: ['major'],
commitMessage:
'fix(package): update peerDependency to accept typescript ^{{newVersion}}',
'fix(package): update peerDependency to accept typescript ^{{newVersion}} {{newVersion}}',
},
} as any;
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
config,
defaultConfig
);
expect(isMigrated).toBe(true);
expect(migratedConfig).toMatchSnapshot();
expect(migratedConfig.packageRules).toHaveLength(1);
});
it('migrates node to travis', () => {
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: 'currentValue',
currentVersion: 'toVersion',
newVersion: 'newValue',
newValueMajor: 'newMajor',
newValueMinor: 'newMinor',
Expand Down
6 changes: 3 additions & 3 deletions lib/datasource/terraform-module/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ export async function getReleases({
dep.homepage = `https://registry.terraform.io/modules/${repository}`;
}
// set published date for latest release
const currentVersion = dep.releases.find(
const latestVersion = dep.releases.find(
(release) => res.version === release.version
);
if (currentVersion) {
currentVersion.releaseTimestamp = res.published_at;
if (latestVersion) {
latestVersion.releaseTimestamp = res.published_at;
}
logger.trace({ dep }, 'dep');
const cacheMinutes = 30;
Expand Down
6 changes: 3 additions & 3 deletions lib/datasource/terraform-provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ async function queryRegistry(
version,
}));
// set published date for latest release
const currentVersion = dep.releases.find(
const latestVersion = dep.releases.find(
(release) => res.version === release.version
);
// istanbul ignore else
if (currentVersion) {
currentVersion.releaseTimestamp = res.published_at;
if (latestVersion) {
latestVersion.releaseTimestamp = res.published_at;
}
dep.homepage = `${registryURL}/providers/${repository}`;
logger.trace({ dep }, 'dep');
Expand Down
8 changes: 4 additions & 4 deletions lib/manager/bazel/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ function updateWithNewVersion(
currentValue: string,
newValue: string
): string {
const currentVersion = currentValue.replace(/^v/, '');
const newVersion = newValue.replace(/^v/, '');
const replaceFrom = currentValue.replace(/^v/, '');
const replaceTo = newValue.replace(/^v/, '');
let newContent = content;
do {
newContent = newContent.replace(currentVersion, newVersion);
} while (newContent.includes(currentVersion));
newContent = newContent.replace(replaceFrom, replaceTo);
} while (newContent.includes(replaceFrom));
return newContent;
}

Expand Down
1 change: 0 additions & 1 deletion lib/manager/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ export interface Upgrade<T = Record<string, any>>
NpmLockFiles {
isLockfileUpdate?: boolean;
currentRawValue?: any;
currentVersion?: string;
depGroup?: string;
dockerRepository?: string;
localDir?: string;
Expand Down
2 changes: 0 additions & 2 deletions lib/manager/gomod/update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ describe('manager/gomod/update', () => {
const upgrade = {
depName: 'github.com/spf13/jwalterweatherman',
managerData: { lineNumber: 43, multiLine: true },
currentVersion: 'v0.0.0',
updateType: 'digest' as UpdateType,
currentDigest: '14d3d4c51834',
newDigest: '123456123456abcdef',
Expand All @@ -168,7 +167,6 @@ describe('manager/gomod/update', () => {
const upgrade = {
depName: 'github.com/spf13/jwalterweatherman',
managerData: { lineNumber: 43, multiLine: true },
currentVersion: 'v0.0.0',
updateType: 'digest' as UpdateType,
currentDigest: 'abcdefabcdef',
newDigest: '14d3d4c51834000000',
Expand Down
3 changes: 1 addition & 2 deletions lib/util/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const allowedFields = {
baseBranch: 'The baseBranch for this branch/PR',
body: 'The body of the release notes',
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',
depName: 'The name of the dependency being updated',
depNameLinked:
Expand All @@ -52,7 +51,7 @@ export const allowedFields = {
displayFrom: 'The current value, formatted for display',
displayTo: 'The to value, formatted for display',
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',
isLockfileUpdate: 'true if the branch is a lock file update',
isMajor: 'true if the upgrade is major',
Expand Down
1 change: 0 additions & 1 deletion lib/workers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export interface BranchUpgradeConfig
currentDigest?: string;
currentDigestShort?: string;
currentValue?: string;
currentVersion?: string;
endpoint?: string;
excludeCommitPaths?: string[];
githubName?: string;
Expand Down
2 changes: 0 additions & 2 deletions lib/workers/repository/updates/flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ export async function flattenUpdates(
for (const update of dep.updates) {
let updateConfig = mergeChildConfig(depConfig, update);
delete updateConfig.updates;
// Massage legacy vars just in case
updateConfig.currentVersion = updateConfig.currentValue;
updateConfig.newVersion =
updateConfig.newVersion || updateConfig.newValue;
if (updateConfig.updateType) {
Expand Down
8 changes: 2 additions & 6 deletions lib/workers/repository/updates/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,15 @@ export function generateBranchConfig(
}
if (!upgrade.displayFrom) {
if (upgrade.currentValue === upgrade.newValue) {
upgrade.displayFrom =
upgrade.currentDigestShort || upgrade.currentVersion || '';
upgrade.displayFrom = upgrade.currentDigestShort || '';
upgrade.displayTo =
upgrade.displayTo ||
upgrade.newDigestShort ||
upgrade.newVersion ||
'';
} else {
upgrade.displayFrom =
upgrade.currentValue ||
upgrade.currentVersion ||
upgrade.currentDigestShort ||
'';
upgrade.currentValue || upgrade.currentDigestShort || '';
upgrade.displayTo =
upgrade.displayTo ||
upgrade.newValue ||
Expand Down

0 comments on commit acf5714

Please sign in to comment.