Skip to content

Commit

Permalink
Merge branch 'main' into devbox-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
burritobill authored Jan 16, 2025
2 parents f200c96 + b3bd91b commit 9adb832
Show file tree
Hide file tree
Showing 12 changed files with 259 additions and 132 deletions.
5 changes: 2 additions & 3 deletions lib/modules/datasource/galaxy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ export class GalaxyDatasource extends Datasource {
}
}
if (body.results.length === 0) {
logger.info(
{ dependency: packageName },
`Received no results from ${galaxyAPIUrl}`,
logger.debug(
`Received no results for ${packageName} from ${galaxyAPIUrl} `,
);
return null;
}
Expand Down
67 changes: 67 additions & 0 deletions lib/modules/datasource/maven/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HeadObjectCommand, S3Client } from '@aws-sdk/client-s3';
import { mockClient } from 'aws-sdk-client-mock';
import { codeBlock } from 'common-tags';
import { GoogleAuth as _googleAuth } from 'google-auth-library';
import { DateTime } from 'luxon';
import type { Release, ReleaseResult } from '..';
Expand Down Expand Up @@ -315,6 +316,72 @@ describe('modules/datasource/maven/index', () => {
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 () => {
const frontendHost = 'frontend_for_private_s3_repository';
const frontendUrl = `https://${frontendHost}/maven2`;
Expand Down
7 changes: 6 additions & 1 deletion lib/modules/datasource/maven/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export type HttpResourceCheckResult = 'found' | 'not-found' | 'error' | Date;

export type DependencyInfo = Pick<
ReleaseResult,
'homepage' | 'sourceUrl' | 'packageScope'
| 'homepage'
| 'sourceUrl'
| 'packageScope'
| 'replacementName'
| 'replacementVersion'
| 'deprecationMessage'
>;

export interface MavenFetchSuccess<T = string> {
Expand Down
17 changes: 17 additions & 0 deletions lib/modules/datasource/maven/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
if (groupId) {
result.packageScope = groupId;
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/git-submodules/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function updateArtifacts({
const res: UpdateArtifactsResult[] = [];
updatedDeps.forEach((dep) => {
// TODO: types (#22198)
logger.info(`Updating submodule ${dep.depName}`);
logger.debug(`Updating submodule ${dep.depName}`);
res.push({
file: { type: 'addition', path: dep.depName!, contents: '' },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function updateLockedDependency(
currentVersion,
);
if (lockedDeps.some((dep) => dep.bundled)) {
logger.info(
logger.debug(
`Package ${depName}@${currentVersion} is bundled and cannot be updated`,
);
return { status: 'update-failed' };
Expand Down
3 changes: 1 addition & 2 deletions lib/modules/versioning/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export const Versioning = z

let versioning = versionings.get(versioningName);
if (!versioning) {
logger.info(
{ versioning: versioningSpec },
logger.debug(
`Versioning: '${versioningSpec}' not found, falling back to ${defaultVersioning.id}`,
);
return defaultVersioning.api;
Expand Down
18 changes: 15 additions & 3 deletions lib/modules/versioning/ubuntu/common.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
import { regEx } from '../../../util/regex';

const regex = regEx(/^(?<codename>\w+)-(?<date>\d{8})(?<suffix>\.\d{1,2})?$/);

function isDatedCodeName(input: string): boolean {
return regEx(/^(?<codename>\w+)-(?<date>\d{8})$/).test(input);
return regex.test(input);
}

function getDatedContainerImageCodename(version: string): null | string {
const groups = regEx(/^(?<codename>\w+)-(?<date>\d{8})$/).exec(version);
const groups = regex.exec(version);
if (!groups?.groups) {
return null;
}
return groups.groups.codename;
}

function getDatedContainerImageVersion(version: string): null | number {
const groups = regEx(/^(?<codename>\w+)-(?<date>\d{8})$/).exec(version);
const groups = regex.exec(version);
if (!groups?.groups) {
return null;
}

return parseInt(groups.groups.date, 10);
}

function getDatedContainerImageSuffix(version: string): null | string {
const groups = regex.exec(version);
if (!groups?.groups?.suffix) {
return null;
}

return groups.groups.suffix;
}

export {
isDatedCodeName,
getDatedContainerImageCodename,
getDatedContainerImageVersion,
getDatedContainerImageSuffix,
};
Loading

0 comments on commit 9adb832

Please sign in to comment.