Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datasource/hex): allow custom registries #29534

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/modules/datasource/hex/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`modules/datasource/hex/index getReleases process public repo without auth 1`] = `
{
"homepage": "https://hex.pm/packages/certifi",
"registryUrl": "https://hex.pm/",
"registryUrl": "https://hex.pm",
"releases": [
{
"isDeprecated": true,
Expand Down Expand Up @@ -93,7 +93,7 @@ exports[`modules/datasource/hex/index getReleases process public repo without au
exports[`modules/datasource/hex/index getReleases processes a private repo with auth 1`] = `
{
"homepage": "https://hex.pm/packages/renovate_test/private_package",
"registryUrl": "https://hex.pm/",
"registryUrl": "https://hex.pm",
"releases": [
{
"releaseTimestamp": "2021-08-04T15:26:26.500Z",
Expand All @@ -110,7 +110,7 @@ exports[`modules/datasource/hex/index getReleases processes a private repo with
exports[`modules/datasource/hex/index getReleases processes real data 1`] = `
{
"homepage": "https://hex.pm/packages/certifi",
"registryUrl": "https://hex.pm/",
"registryUrl": "https://hex.pm",
"releases": [
{
"isDeprecated": true,
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/hex/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('modules/datasource/hex/index', () => {

expect(result).toEqual({
homepage: 'https://hex.pm/packages/renovate_test/private_package',
registryUrl: 'https://hex.pm/',
registryUrl: 'https://hex.pm',
releases: [
{ releaseTimestamp: '2021-08-04T15:26:26.500Z', version: '0.1.0' },
{ releaseTimestamp: '2021-08-04T17:46:00.274Z', version: '0.1.1' },
Expand Down
11 changes: 7 additions & 4 deletions lib/modules/datasource/hex/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { logger } from '../../../logger';
import { cache } from '../../../util/cache/package/decorator';
import { joinUrlParts } from '../../../util/url';
import * as hexVersioning from '../../versioning/hex';
import { Datasource } from '../datasource';
import type { GetReleasesConfig, ReleaseResult } from '../types';
Expand All @@ -12,9 +13,7 @@ export class HexDatasource extends Datasource {
super(HexDatasource.id);
}

override readonly defaultRegistryUrls = ['https://hex.pm/'];

override readonly customRegistrySupport = false;
override readonly defaultRegistryUrls = ['https://hex.pm'];

override readonly defaultVersioning = hexVersioning.id;

Expand Down Expand Up @@ -47,7 +46,11 @@ export class HexDatasource extends Datasource {
const organizationUrlPrefix = organizationName
? `repos/${organizationName}/`
: '';
const hexUrl = `${registryUrl}api/${organizationUrlPrefix}packages/${hexPackageName}`;

const hexUrl = joinUrlParts(
registryUrl,
`/api/${organizationUrlPrefix}packages/${hexPackageName}`,
);

const { val: result, err } = await this.http
.getJsonSafe(hexUrl, HexRelease)
Expand Down