Skip to content

Commit 03e0c68

Browse files
committed
address feedback
1 parent 3b04689 commit 03e0c68

File tree

5 files changed

+35
-47
lines changed

5 files changed

+35
-47
lines changed

lib/modules/datasource/bitbucket-server-tags/index.spec.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ describe('modules/datasource/bitbucket-server-tags/index', () => {
7777
expect(res).toBeNull();
7878
});
7979

80+
it('returns null on missing registryUrl', async () => {
81+
const res = await getPkgReleases({
82+
datasource,
83+
packageName: 'some-org/notexisting',
84+
});
85+
expect(res).toBeNull();
86+
});
87+
8088
it('handles not found', async () => {
8189
httpMock
8290
.scope(apiBaseUrl)
@@ -132,23 +140,6 @@ describe('modules/datasource/bitbucket-server-tags/index', () => {
132140
);
133141
expect(res).toBeNull();
134142
});
135-
136-
it('fallback to invalid defaultRegistryUrl if none is provided', async () => {
137-
httpMock
138-
.scope('https://bitbucket.org/rest/api/1.0')
139-
.get('/projects/some-org/repos/notexisting/tags/v1.0.0')
140-
.reply(404);
141-
142-
await expect(
143-
getDigest(
144-
{
145-
datasource,
146-
packageName: 'some-org/notexisting',
147-
},
148-
'v1.0.0',
149-
),
150-
).rejects.toThrow(HttpError);
151-
});
152143
});
153144

154145
describe('getDigest', () => {
@@ -217,6 +208,14 @@ describe('modules/datasource/bitbucket-server-tags/index', () => {
217208
expect(res).toBeNull();
218209
});
219210

211+
it('returns null on missing registryUrl', async () => {
212+
const res = await getDigest({
213+
datasource,
214+
packageName: 'some-org/notexisting',
215+
});
216+
expect(res).toBeNull();
217+
});
218+
220219
it('handles not found', async () => {
221220
httpMock
222221
.scope(apiBaseUrl)

lib/modules/datasource/bitbucket-server-tags/index.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export class BitbucketServerTagsDatasource extends Datasource {
2020

2121
override http = new BitbucketServerHttp(BitbucketServerTagsDatasource.id);
2222

23-
static readonly defaultRegistryUrls = ['https://bitbucket.org'];
24-
2523
static readonly sourceUrlSupport = 'package';
2624
static readonly sourceUrlNote =
2725
'The source URL is determined by using the `packageName` and `registryUrl`.';
@@ -32,23 +30,20 @@ export class BitbucketServerTagsDatasource extends Datasource {
3230
super(BitbucketServerTagsDatasource.id);
3331
}
3432

35-
static getRegistryURL(registryUrl?: string): string {
36-
return (
37-
registryUrl?.replace(regEx(/\/rest\/api\/1.0$/), '') ??
38-
this.defaultRegistryUrls[0]
39-
);
33+
static getRegistryURL(registryUrl: string): string {
34+
return registryUrl?.replace(regEx(/\/rest\/api\/1.0$/), '');
4035
}
4136

4237
static getSourceUrl(
4338
projectKey: string,
4439
repositorySlug: string,
45-
registryUrl?: string,
40+
registryUrl: string,
4641
): string {
4742
const url = BitbucketServerTagsDatasource.getRegistryURL(registryUrl);
4843
return `${ensureTrailingSlash(url)}projects/${projectKey}/repos/${repositorySlug}`;
4944
}
5045

51-
static getApiUrl(registryUrl?: string): string {
46+
static getApiUrl(registryUrl: string): string {
5247
const res = BitbucketServerTagsDatasource.getRegistryURL(registryUrl);
5348
return `${ensureTrailingSlash(res)}rest/api/1.0/`;
5449
}
@@ -58,7 +53,7 @@ export class BitbucketServerTagsDatasource extends Datasource {
5853
repo: string,
5954
type: string,
6055
): string {
61-
return `${BitbucketServerTagsDatasource.getRegistryURL(registryUrl)}:${repo}:${type}`;
56+
return `${BitbucketServerTagsDatasource.getRegistryURL(registryUrl ?? '')}:${repo}:${type}`;
6257
}
6358

6459
// getReleases fetches list of tags for the repository
@@ -74,6 +69,10 @@ export class BitbucketServerTagsDatasource extends Datasource {
7469
async getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
7570
const { registryUrl, packageName } = config;
7671
const [projectKey, repositorySlug] = packageName.split('/');
72+
if (!registryUrl) {
73+
logger.debug('Missing registryUrl');
74+
return null;
75+
}
7776

7877
const result = Result.parse(config, ReleasesConfig)
7978
.transform(({ registryUrl }) => {
@@ -153,6 +152,10 @@ export class BitbucketServerTagsDatasource extends Datasource {
153152
): Promise<string | null> {
154153
const { registryUrl, packageName } = config;
155154
const [projectKey, repositorySlug] = packageName.split('/');
155+
if (!registryUrl) {
156+
logger.debug('Missing registryUrl');
157+
return null;
158+
}
156159

157160
const baseUrl = `${BitbucketServerTagsDatasource.getApiUrl(registryUrl)}projects/${projectKey}/repos/${repositorySlug}`;
158161

lib/util/http/bitbucket-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HttpBase, type InternalJsonUnsafeOptions } from './http';
33
import type { HttpMethod, HttpOptions, HttpResponse } from './types';
44

55
const MAX_LIMIT = 100;
6-
const MAX_PAGES = Number.MAX_SAFE_INTEGER;
6+
const MAX_PAGES = 100;
77

88
let baseUrl: string;
99
export const setBaseUrl = (url: string): void => {

lib/workers/repository/update/pr/changelog/bitbucket-server/index.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ import { Files } from '../../../../../../modules/platform/bitbucket-server/schem
55
import { BitbucketServerHttp } from '../../../../../../util/http/bitbucket-server';
66
import { ensureTrailingSlash, joinUrlParts } from '../../../../../../util/url';
77
import { compareChangelogFilePath } from '../common';
8-
import type {
9-
ChangeLogFile,
10-
ChangeLogNotes,
11-
ChangeLogProject,
12-
ChangeLogRelease,
13-
} from '../types';
8+
import type { ChangeLogFile } from '../types';
149

1510
export const id = 'bitbucket-server-changelog';
1611
const http = new BitbucketServerHttp(id);
@@ -72,15 +67,3 @@ export async function getReleaseNotesMd(
7267

7368
return { changelogFile, changelogMd };
7469
}
75-
76-
export function getReleaseList(
77-
_project: ChangeLogProject,
78-
_release: ChangeLogRelease,
79-
): ChangeLogNotes[] {
80-
logger.trace('bitbucketServer.getReleaseList()');
81-
logger.debug(
82-
'Unsupported Bitbucket Server feature. Skipping release fetching.',
83-
);
84-
85-
return [];
86-
}

lib/workers/repository/update/pr/changelog/release-notes.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export async function getReleaseList(
4646
case 'bitbucket':
4747
return bitbucket.getReleaseList(project, release);
4848
case 'bitbucket-server':
49-
return bitbucketServer.getReleaseList(project, release);
49+
logger.trace(
50+
'Unsupported Bitbucket Server feature. Skipping release fetching.',
51+
);
52+
return [];
5053
default:
5154
logger.warn({ apiBaseUrl, repository, type }, 'Invalid project type');
5255
return [];

0 commit comments

Comments
 (0)