mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-10 14:06:30 +00:00
Merge ab2fd8b146
into b7f96b2ea1
This commit is contained in:
commit
a05db7d5e6
3 changed files with 90 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { HeadObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
import { HeadObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
||||||
import { mockClient } from 'aws-sdk-client-mock';
|
import { mockClient } from 'aws-sdk-client-mock';
|
||||||
|
import { codeBlock } from 'common-tags';
|
||||||
import { GoogleAuth as _googleAuth } from 'google-auth-library';
|
import { GoogleAuth as _googleAuth } from 'google-auth-library';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import type { Release, ReleaseResult } from '..';
|
import type { Release, ReleaseResult } from '..';
|
||||||
|
@ -315,6 +316,72 @@ describe('modules/datasource/maven/index', () => {
|
||||||
expect(res?.sourceUrl).toBe('https://github.com/example/test');
|
expect(res?.sourceUrl).toBe('https://github.com/example/test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('supports relocation', () => {
|
||||||
|
it('with only groupId present', async () => {
|
||||||
|
const pom = codeBlock`
|
||||||
|
<project>
|
||||||
|
<distributionManagement>
|
||||||
|
<relocation>
|
||||||
|
<groupId>io.example</groupId>
|
||||||
|
</relocation>
|
||||||
|
</distributionManagement>
|
||||||
|
</project>
|
||||||
|
`;
|
||||||
|
mockGenericPackage({ pom });
|
||||||
|
|
||||||
|
const res = await get();
|
||||||
|
|
||||||
|
expect(res).toMatchObject({
|
||||||
|
replacementName: 'io.example:package',
|
||||||
|
replacementVersion: '2.0.0',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('with only artifactId present', async () => {
|
||||||
|
const pom = codeBlock`
|
||||||
|
<project>
|
||||||
|
<distributionManagement>
|
||||||
|
<relocation>
|
||||||
|
<artifactId>foo</artifactId>
|
||||||
|
</relocation>
|
||||||
|
</distributionManagement>
|
||||||
|
</project>
|
||||||
|
`;
|
||||||
|
mockGenericPackage({ pom });
|
||||||
|
|
||||||
|
const res = await get();
|
||||||
|
|
||||||
|
expect(res).toMatchObject({
|
||||||
|
replacementName: 'org.example:foo',
|
||||||
|
replacementVersion: '2.0.0',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('with all elments present', async () => {
|
||||||
|
const pom = codeBlock`
|
||||||
|
<project>
|
||||||
|
<distributionManagement>
|
||||||
|
<relocation>
|
||||||
|
<groupId>io.example</groupId>
|
||||||
|
<artifactId>foo</artifactId>
|
||||||
|
<version>1.2.3</version>
|
||||||
|
<message>test relocation</message>
|
||||||
|
</relocation>
|
||||||
|
</distributionManagement>
|
||||||
|
</project>
|
||||||
|
`;
|
||||||
|
mockGenericPackage({ pom });
|
||||||
|
|
||||||
|
const res = await get();
|
||||||
|
|
||||||
|
expect(res).toMatchObject({
|
||||||
|
replacementName: 'io.example:foo',
|
||||||
|
replacementVersion: '1.2.3',
|
||||||
|
deprecationMessage: 'test relocation',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('removes authentication header after redirect', async () => {
|
it('removes authentication header after redirect', async () => {
|
||||||
const frontendHost = 'frontend_for_private_s3_repository';
|
const frontendHost = 'frontend_for_private_s3_repository';
|
||||||
const frontendUrl = `https://${frontendHost}/maven2`;
|
const frontendUrl = `https://${frontendHost}/maven2`;
|
||||||
|
|
|
@ -18,7 +18,12 @@ export type HttpResourceCheckResult = 'found' | 'not-found' | 'error' | Date;
|
||||||
|
|
||||||
export type DependencyInfo = Pick<
|
export type DependencyInfo = Pick<
|
||||||
ReleaseResult,
|
ReleaseResult,
|
||||||
'homepage' | 'sourceUrl' | 'packageScope'
|
| 'homepage'
|
||||||
|
| 'sourceUrl'
|
||||||
|
| 'packageScope'
|
||||||
|
| 'replacementName'
|
||||||
|
| 'replacementVersion'
|
||||||
|
| 'deprecationMessage'
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export interface MavenFetchSuccess<T = string> {
|
export interface MavenFetchSuccess<T = string> {
|
||||||
|
|
|
@ -543,6 +543,23 @@ export async function getDependencyInfo(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relocation = pomContent.descendantWithPath(
|
||||||
|
'distributionManagement.relocation',
|
||||||
|
);
|
||||||
|
if (relocation) {
|
||||||
|
const relocationGroup =
|
||||||
|
relocation.valueWithPath('groupId') ?? dependency.group;
|
||||||
|
const relocationName =
|
||||||
|
relocation.valueWithPath('artifactId') ?? dependency.name;
|
||||||
|
result.replacementName = `${relocationGroup}:${relocationName}`;
|
||||||
|
const relocationVersion = relocation.valueWithPath('version');
|
||||||
|
result.replacementVersion = relocationVersion ?? version;
|
||||||
|
const relocationMessage = relocation.valueWithPath('message');
|
||||||
|
if (relocationMessage) {
|
||||||
|
result.deprecationMessage = relocationMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const groupId = pomContent.valueWithPath('groupId');
|
const groupId = pomContent.valueWithPath('groupId');
|
||||||
if (groupId) {
|
if (groupId) {
|
||||||
result.packageScope = groupId;
|
result.packageScope = groupId;
|
||||||
|
|
Loading…
Reference in a new issue