Skip to content

Commit

Permalink
fix: log warning for managers which don't support replacements (#13276)
Browse files Browse the repository at this point in the history
Co-authored-by: Anne Stellingwerf <astellin@opentext.com>
  • Loading branch information
JamieMagee and astellingwerf committed Jan 14, 2022
1 parent 8112381 commit fe72cd7
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/manager/gomod/update.spec.ts
Expand Up @@ -279,5 +279,12 @@ describe('manager/gomod/update', () => {
expect(res).not.toEqual(gomod1);
expect(res).toContain('github.com/caarlos0/env/v6 v6.1.0');
});
it('should return null for replacement', () => {
const res = updateDependency({
fileContent: undefined,
upgrade: { updateType: 'replacement' },
});
expect(res).toBeNull();
});
});
});
6 changes: 5 additions & 1 deletion lib/manager/gomod/update.ts
Expand Up @@ -16,7 +16,11 @@ export function updateDependency({
}: UpdateDependencyConfig): string | null {
try {
logger.debug(`gomod.updateDependency: ${upgrade.newValue}`);
const { depName, depType } = upgrade;
const { depName, depType, updateType } = upgrade;
if (updateType === 'replacement') {
logger.warn('gomod manager does not support replacement updates yet');
return null;
}
const depNameNoVersion = getDepNameWithNoVersion(depName);
const lines = fileContent.split('\n');
const lineToChange = lines[upgrade.managerData.lineNumber];
Expand Down
8 changes: 8 additions & 0 deletions lib/manager/gradle/deep/index.spec.ts
Expand Up @@ -494,5 +494,13 @@ describe('manager/gradle/deep/index', () => {

expect(execSnapshots).toBeEmpty();
});

it('should return null for replacement', () => {
const res = updateDependency({
fileContent: undefined,
upgrade: { deepExtract: true, updateType: 'replacement' },
});
expect(res).toBeNull();
});
});
});
5 changes: 5 additions & 0 deletions lib/manager/gradle/deep/index.ts
Expand Up @@ -173,6 +173,11 @@ export function updateDependency({
// prettier-ignore
logger.debug(`gradle.updateDependency(): packageFile:${upgrade.packageFile} depName:${upgrade.depName}, version:${upgrade.currentValue} ==> ${upgrade.newValue}`);

if (upgrade.updateType === 'replacement') {
logger.warn('gradle manager does not support replacement updates yet');
return null;
}

return updateGradleVersion(
fileContent,
buildGradleDependency(upgrade),
Expand Down
8 changes: 8 additions & 0 deletions lib/manager/gradle/shallow/update.spec.ts
Expand Up @@ -75,4 +75,12 @@ describe('manager/gradle/shallow/update', () => {
})
).toBeNull();
});

it('should return null for replacement', () => {
const res = updateDependency({
fileContent: undefined,
upgrade: { updateType: 'replacement' },
});
expect(res).toBeNull();
});
});
6 changes: 5 additions & 1 deletion lib/manager/gradle/shallow/update.ts
Expand Up @@ -7,7 +7,11 @@ export function updateDependency({
fileContent,
upgrade,
}: UpdateDependencyConfig<GradleManagerData>): string | null {
const { depName, currentValue, newValue, managerData } = upgrade;
const { depName, currentValue, newValue, managerData, updateType } = upgrade;
if (updateType === 'replacement') {
logger.warn('gradle manager does not support replacement updates yet');
return null;
}
const offset = managerData.fileReplacePosition;
const leftPart = fileContent.slice(0, offset);
const rightPart = fileContent.slice(offset);
Expand Down
7 changes: 7 additions & 0 deletions lib/manager/maven/index.spec.ts
Expand Up @@ -269,5 +269,12 @@ describe('manager/maven/index', () => {
pomContent
);
});
it('should return null for replacement', () => {
const res = updateDependency({
fileContent: undefined,
upgrade: { updateType: 'replacement' },
});
expect(res).toBeNull();
});
});
});
4 changes: 4 additions & 0 deletions lib/manager/maven/update.ts
Expand Up @@ -28,6 +28,10 @@ export function updateDependency({
fileContent,
upgrade,
}: UpdateDependencyConfig): string | null {
if (upgrade.updateType === 'replacement') {
logger.warn('maven manager does not support replacement updates yet');
return null;
}
const offset = fileContent.indexOf('<');
const spaces = fileContent.slice(0, offset);
const restContent = fileContent.slice(offset);
Expand Down

0 comments on commit fe72cd7

Please sign in to comment.