Skip to content

Commit

Permalink
refactor: remove newVersion usage (#8710)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 16, 2021
1 parent a8819c4 commit 0869d6e
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 43 deletions.
2 changes: 1 addition & 1 deletion lib/config/__snapshots__/migration.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates packageRu
Object {
"packageRules": Array [
Object {
"commitMessage": "fix(package): update peerDependency to accept typescript ^{{newValue}} {{newValue}}",
"commitMessage": "fix(package): update peerDependency to accept typescript ^{{newMajor}} {{newMajor}}",
"matchPackageNames": Array [
"typescript",
],
Expand Down
2 changes: 1 addition & 1 deletion lib/config/migration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ describe('config/migration', () => {
packageNames: ['typescript'],
updateTypes: ['major'],
commitMessage:
'fix(package): update peerDependency to accept typescript ^{{newVersion}} {{newVersion}}',
'fix(package): update peerDependency to accept typescript ^{{newValueMajor}} {{newValueMajor}}',
},
} as any;
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
Expand Down
2 changes: 1 addition & 1 deletion lib/config/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ export function migrateConfig(
}
const migratedTemplates = {
fromVersion: 'currentVersion',
newVersion: 'newValue',
newValueMajor: 'newMajor',
newValueMinor: 'newMinor',
newVersion: 'toVersion',
newVersionMajor: 'newMajor',
newVersionMinor: 'newMinor',
};
Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const defaultConfig = {
commitMessageTopic: '{{{depName}}} Docker tag',
major: { enabled: false },
commitMessageExtra:
'to v{{#if isMajor}}{{{newMajor}}}{{else}}{{{newVersion}}}{{/if}}',
'to v{{#if isMajor}}{{{newMajor}}}{{else}}{{{toVersion}}}{{/if}}',
digest: {
branchTopic: '{{{depNameSanitized}}}-{{{currentValue}}}',
commitMessageExtra: 'to {{newDigestShort}}',
Expand Down
8 changes: 4 additions & 4 deletions lib/manager/batect-wrapper/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as httpMock from '../../../test/http-mock';
import { UpdateArtifact } from '../common';
import { updateArtifacts } from './artifacts';

const newVersion = '1.2.3';
const newUnixWrapperContent = `Unix wrapper script for ${newVersion}`;
const newWindowsWrapperContent = `Windows wrapper script for ${newVersion}`;
const defaultTo = '1.2.3';
const newUnixWrapperContent = `Unix wrapper script for ${defaultTo}`;
const newWindowsWrapperContent = `Windows wrapper script for ${defaultTo}`;

function artifactForPath(
path: string,
toVersion: string = newVersion
toVersion: string = defaultTo
): UpdateArtifact {
return {
packageFileName: path,
Expand Down
2 changes: 0 additions & 2 deletions lib/manager/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export interface LookupUpdate {
newMajor?: number;
newMinor?: number;
newValue: string;
newVersion?: string;
semanticCommitType?: string;
skippedOverVersions?: string[];
toVersion?: string;
Expand Down Expand Up @@ -195,7 +194,6 @@ export interface Upgrade<T = Record<string, any>>
newFrom?: string;
newMajor?: number;
newValue?: string;
newVersion?: string;
packageFile?: string;
rangeStrategy?: RangeStrategy;
toVersion?: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/git-submodules/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default async function updateDependency({

try {
await git.submoduleUpdate(['--init', upgrade.depName]);
await submoduleGit.checkout([upgrade.newVersion]);
await submoduleGit.checkout([upgrade.toVersion]);
return fileContent;
} catch (err) {
return null;
Expand Down
30 changes: 15 additions & 15 deletions lib/manager/gradle/build-gradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface UpdateFunction {
(
dependency: GradleDependency,
buildGradleContent: string,
newVersion: string
newValue: string
): string;
}

Expand Down Expand Up @@ -240,7 +240,7 @@ export function init(): void {
function updateVersionLiterals(
dependency: GradleDependency,
buildGradleContent: string,
newVersion: string
newValue: string
): string | null {
const regexes: RegExp[] = [
moduleStringVersionFormatMatch(dependency),
Expand All @@ -254,7 +254,7 @@ function updateVersionLiterals(
for (const regex of regexes) {
const match = regex.exec(result);
if (match) {
result = result.replace(match[0], `${match[1]}${newVersion}${match[2]}`);
result = result.replace(match[0], `${match[1]}${newValue}${match[2]}`);
}
}
return result === buildGradleContent ? null : result;
Expand All @@ -263,7 +263,7 @@ function updateVersionLiterals(
function updateLocalVariables(
dependency: GradleDependency,
buildGradleContent: string,
newVersion: string
newValue: string
): string | null {
const regexes: RegExp[] = [
...moduleMapVariableVersionFormatMatch(dependency),
Expand All @@ -284,7 +284,7 @@ function updateLocalVariables(
if (variableDefinitionMatch) {
return buildGradleContent.replace(
variableDefinitionMatch[0],
`${variableDefinitionMatch[1]}${newVersion}${variableDefinitionMatch[3]}`
`${variableDefinitionMatch[1]}${newValue}${variableDefinitionMatch[3]}`
);
}
}
Expand All @@ -295,7 +295,7 @@ function updateLocalVariables(
function updateGlobalVariables(
dependency: GradleDependency,
buildGradleContent: string,
newVersion: string
newValue: string
): string | null {
const variable = variables[`${dependency.group}:${dependency.name}`];
if (variable) {
Expand All @@ -304,7 +304,7 @@ function updateGlobalVariables(
if (match) {
return buildGradleContent.replace(
match[0],
`${match[1]}${newVersion}${match[3]}`
`${match[1]}${newValue}${match[3]}`
);
}
}
Expand All @@ -314,7 +314,7 @@ function updateGlobalVariables(
function updateGlobalMapVariables(
dependency: GradleDependency,
buildGradleContent: string,
newVersion: string
newValue: string
): string | null {
let variable = variables[`${dependency.group}:${dependency.name}`];
if (variable) {
Expand All @@ -327,7 +327,7 @@ function updateGlobalMapVariables(
if (match) {
return buildGradleContent.replace(
match[0],
`${match[1]}${newVersion}${match[3]}`
`${match[1]}${newValue}${match[3]}`
);
}

Expand All @@ -341,7 +341,7 @@ function updateGlobalMapVariables(
function updateKotlinVariablesByExtra(
dependency: GradleDependency,
buildGradleContent: string,
newVersion: string
newValue: string
): string | null {
const variable = variables[`${dependency.group}:${dependency.name}`];
if (variable) {
Expand All @@ -352,7 +352,7 @@ function updateKotlinVariablesByExtra(
if (match) {
return buildGradleContent.replace(
match[0],
`${match[1]}${newVersion}${match[3]}`
`${match[1]}${newValue}${match[3]}`
);
}
}
Expand All @@ -362,14 +362,14 @@ function updateKotlinVariablesByExtra(
function updatePropertyFileGlobalVariables(
dependency: GradleDependency,
buildGradleContent: string,
newVersion: string
newValue: string
): string | null {
const variable = variables[`${dependency.group}:${dependency.name}`];
if (variable) {
const regex = regEx(`(${variable}\\s*=\\s*)(.*)`);
const match = regex.exec(buildGradleContent);
if (match) {
return buildGradleContent.replace(match[0], `${match[1]}${newVersion}`);
return buildGradleContent.replace(match[0], `${match[1]}${newValue}`);
}
}
return null;
Expand All @@ -378,7 +378,7 @@ function updatePropertyFileGlobalVariables(
export function updateGradleVersion(
buildGradleContent: string,
dependency: GradleDependency,
newVersion: string
newValue: string
): string {
if (dependency) {
const updateFunctions: UpdateFunction[] = [
Expand All @@ -394,7 +394,7 @@ export function updateGradleVersion(
const gradleContentUpdated = updateFunction(
dependency,
buildGradleContent,
newVersion
newValue
);
if (gradleContentUpdated) {
return gradleContentUpdated;
Expand Down
8 changes: 4 additions & 4 deletions lib/manager/sbt/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ export function bumpPackageVersion(
'Checking if we should bump build.sbt version'
);
let bumpedContent = content;
const newVersion = inc(currentValue, bumpVersion as ReleaseType);
if (!newVersion) {
const bumpedVersion = inc(currentValue, bumpVersion as ReleaseType);
if (!bumpedVersion) {
logger.warn('Version incremental failed');
return { bumpedContent };
}
bumpedContent = content.replace(
/^(version\s*:=\s*).*$/m,
`$1"${newVersion}"`
`$1"${bumpedVersion}"`
);

if (bumpedContent === content) {
logger.debug('Version was already bumped');
} else {
logger.debug({ newVersion }, 'Bumped build.sbt version');
logger.debug({ bumpedVersion }, 'Bumped build.sbt version');
}

return { bumpedContent };
Expand Down
1 change: 0 additions & 1 deletion lib/util/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export const allowedFields = {
'The minor version of the new version. e.g. "1" if the new version if "3.1.0"',
newValue:
'The new value in the upgrade. Can be a range or version e.g. "^3.0.0" or "3.1.0"',
newVersion: 'The new version in the upgrade.',
packageFile: 'The filename that the dependency was found in',
packageFileDir:
'The directory with full path where the packageFile was found',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ Object {
Object {
"currentVersion": undefined,
"newValue": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
"newVersion": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
"toVersion": undefined,
"toVersion": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
"updateType": "digest",
},
],
Expand Down Expand Up @@ -1285,7 +1284,6 @@ Object {
"newMajor": 9,
"newMinor": null,
"newValue": "9",
"newVersion": "9",
"toVersion": "9",
"updateType": "major",
},
Expand All @@ -1309,7 +1307,6 @@ Object {
"newMajor": 8,
"newMinor": 2,
"newValue": "8.2",
"newVersion": "8.2",
"toVersion": "8.2",
"updateType": "minor",
},
Expand All @@ -1320,7 +1317,6 @@ Object {
"newMajor": 9,
"newMinor": 0,
"newValue": "9.0",
"newVersion": "9.0",
"toVersion": "9.0",
"updateType": "major",
},
Expand All @@ -1344,7 +1340,6 @@ Object {
"newMajor": 8,
"newMinor": 2,
"newValue": "8.2.5",
"newVersion": "8.2.5",
"skippedOverVersions": Array [
"8.1.5",
"8.2.0",
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export async function lookupUpdates(
}
if (versioning.valueToVersion) {
for (const update of res.updates || []) {
update.newVersion = versioning.valueToVersion(update.newValue);
update.toVersion = versioning.valueToVersion(update.newValue);
update.currentVersion = versioning.valueToVersion(
update.currentVersion
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Object {
"datasource": "npm",
"depName": "@types/some-dep",
"displayFrom": "0.5.7",
"displayTo": "",
"displayTo": "0.5.8",
"isRange": false,
"prTitle": "some-title",
"prettyDepType": "dependency",
Expand Down
4 changes: 2 additions & 2 deletions lib/workers/repository/updates/flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export async function flattenUpdates(
for (const update of dep.updates) {
let updateConfig = mergeChildConfig(depConfig, update);
delete updateConfig.updates;
updateConfig.newVersion =
updateConfig.newVersion || updateConfig.newValue;
updateConfig.toVersion =
updateConfig.toVersion || updateConfig.newValue;
if (updateConfig.updateType) {
updateConfig[`is${upper(updateConfig.updateType)}`] = true;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/workers/repository/updates/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ export function generateBranchConfig(
upgrade.displayTo =
upgrade.displayTo ||
upgrade.newDigestShort ||
upgrade.newVersion ||
upgrade.toVersion ||
'';
} else {
upgrade.displayFrom =
upgrade.currentValue || upgrade.currentDigestShort || '';
upgrade.displayTo =
upgrade.displayTo ||
upgrade.newValue ||
upgrade.newVersion ||
upgrade.toVersion ||
upgrade.newDigestShort ||
'';
}
Expand Down

0 comments on commit 0869d6e

Please sign in to comment.