mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix: better validation before bumping package version (#23684)
This commit is contained in:
parent
2f99b3cf25
commit
29cec2cb91
6 changed files with 20 additions and 17 deletions
|
@ -14,6 +14,7 @@ export function bumpPackageVersion(
|
|||
);
|
||||
let newChartVersion: string | null;
|
||||
let bumpedContent = content;
|
||||
|
||||
try {
|
||||
newChartVersion = semver.inc(currentValue, bumpVersion);
|
||||
if (!newChartVersion) {
|
||||
|
|
|
@ -55,7 +55,7 @@ export function updateDependency({
|
|||
|
||||
export function bumpPackageVersion(
|
||||
content: string,
|
||||
currentValue: string | undefined,
|
||||
currentValue: string,
|
||||
bumpVersion: ReleaseType
|
||||
): BumpPackageVersionResult {
|
||||
logger.debug(
|
||||
|
@ -64,11 +64,6 @@ export function bumpPackageVersion(
|
|||
);
|
||||
let bumpedContent = content;
|
||||
|
||||
if (!currentValue) {
|
||||
logger.warn('Unable to bump pom.xml version, pom.xml has no version');
|
||||
return { bumpedContent };
|
||||
}
|
||||
|
||||
if (!semver.valid(currentValue)) {
|
||||
logger.warn(
|
||||
{ currentValue },
|
||||
|
|
|
@ -23,6 +23,7 @@ export function bumpPackageVersion(
|
|||
// TODO: types (#7154)
|
||||
let newPjVersion: string | null;
|
||||
let bumpedContent = content;
|
||||
|
||||
try {
|
||||
if (isMirrorBumpVersion(bumpVersion)) {
|
||||
const mirrorPackage = bumpVersion.replace('mirror:', '');
|
||||
|
|
|
@ -7,7 +7,7 @@ import { findVersion } from './util';
|
|||
|
||||
export function bumpPackageVersion(
|
||||
content: string,
|
||||
currentValue: string | undefined,
|
||||
currentValue: string,
|
||||
bumpVersion: ReleaseType
|
||||
): BumpPackageVersionResult {
|
||||
logger.debug(
|
||||
|
@ -16,11 +16,6 @@ export function bumpPackageVersion(
|
|||
);
|
||||
let bumpedContent = content;
|
||||
|
||||
if (!currentValue) {
|
||||
logger.warn('Unable to bump project version, project has no version');
|
||||
return { bumpedContent };
|
||||
}
|
||||
|
||||
if (!semver.valid(currentValue)) {
|
||||
logger.warn(
|
||||
{ currentValue },
|
||||
|
|
|
@ -476,6 +476,7 @@ describe('workers/repository/update/branch/get-updated', () => {
|
|||
branchName: '',
|
||||
bumpVersion: 'patch',
|
||||
manager: 'npm',
|
||||
packageFileVersion: 'old version',
|
||||
});
|
||||
npm.updateDependency.mockReturnValue('old version');
|
||||
npm.bumpPackageVersion.mockReturnValue({ bumpedContent: 'new version' });
|
||||
|
@ -497,6 +498,7 @@ describe('workers/repository/update/branch/get-updated', () => {
|
|||
branchName: '',
|
||||
bumpVersion: 'patch',
|
||||
manager: 'helmv3',
|
||||
packageFileVersion: '0.0.1',
|
||||
});
|
||||
autoReplace.doAutoReplace.mockResolvedValueOnce('version: 0.0.1');
|
||||
helmv3.bumpPackageVersion.mockReturnValue({
|
||||
|
|
|
@ -173,10 +173,14 @@ export async function getUpdatedPackageFiles(
|
|||
);
|
||||
firstUpdate = false;
|
||||
if (res) {
|
||||
if (bumpPackageVersion && upgrade.bumpVersion) {
|
||||
if (
|
||||
bumpPackageVersion &&
|
||||
upgrade.bumpVersion &&
|
||||
upgrade.packageFileVersion
|
||||
) {
|
||||
const { bumpedContent } = await bumpPackageVersion(
|
||||
res,
|
||||
upgrade.packageFileVersion!,
|
||||
upgrade.packageFileVersion,
|
||||
upgrade.bumpVersion
|
||||
);
|
||||
res = bumpedContent;
|
||||
|
@ -202,10 +206,15 @@ export async function getUpdatedPackageFiles(
|
|||
fileContent: packageFileContent!,
|
||||
upgrade,
|
||||
});
|
||||
if (bumpPackageVersion && upgrade.bumpVersion) {
|
||||
if (
|
||||
newContent &&
|
||||
bumpPackageVersion &&
|
||||
upgrade.bumpVersion &&
|
||||
upgrade.packageFileVersion
|
||||
) {
|
||||
const { bumpedContent } = await bumpPackageVersion(
|
||||
newContent!,
|
||||
upgrade.packageFileVersion!,
|
||||
newContent,
|
||||
upgrade.packageFileVersion,
|
||||
upgrade.bumpVersion
|
||||
);
|
||||
newContent = bumpedContent;
|
||||
|
|
Loading…
Reference in a new issue