Skip to content

Commit fcffdc9

Browse files
authored
feat(bitbucket): Enable HTTP cache for PR list and json fetch (#28024)
1 parent 0dfea67 commit fcffdc9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

lib/modules/platform/bitbucket/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { parseJson } from '../../../util/common';
77
import * as git from '../../../util/git';
88
import * as hostRules from '../../../util/host-rules';
99
import { BitbucketHttp, setBaseUrl } from '../../../util/http/bitbucket';
10+
import { repoCacheProvider } from '../../../util/http/cache/repository-http-cache-provider';
1011
import type { HttpOptions } from '../../../util/http/types';
1112
import { regEx } from '../../../util/regex';
1213
import { sanitize } from '../../../util/sanitize';
@@ -163,7 +164,10 @@ export async function getRawFile(
163164
`/2.0/repositories/${repo}/src/` +
164165
(finalBranchOrTag ?? `HEAD`) +
165166
`/${path}`;
166-
const res = await bitbucketHttp.get(url);
167+
const res = await bitbucketHttp.get(url, {
168+
cacheProvider: repoCacheProvider,
169+
memCache: true,
170+
});
167171
return res.body;
168172
}
169173

lib/modules/platform/bitbucket/pr-cache.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ describe('modules/platform/bitbucket/pr-cache', () => {
7474
},
7575
]);
7676
expect(cache).toEqual({
77+
httpCache: {},
7778
platform: {
7879
bitbucket: {
7980
pullRequestsCache: {
@@ -120,6 +121,7 @@ describe('modules/platform/bitbucket/pr-cache', () => {
120121
{ number: 2, title: 'title' },
121122
]);
122123
expect(cache).toEqual({
124+
httpCache: {},
123125
platform: {
124126
bitbucket: {
125127
pullRequestsCache: {

lib/modules/platform/bitbucket/pr-cache.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { logger } from '../../../logger';
44
import * as memCache from '../../../util/cache/memory';
55
import { getCache } from '../../../util/cache/repository';
66
import type { BitbucketHttp } from '../../../util/http/bitbucket';
7+
import { repoCacheProvider } from '../../../util/http/cache/repository-http-cache-provider';
78
import type { Pr } from '../types';
89
import type { BitbucketPrCacheData, PagedResult, PrResponse } from './types';
910
import { prFieldsFilter, prInfo, prStates } from './utils';
@@ -128,7 +129,11 @@ export class BitbucketPrCache {
128129
private async sync(http: BitbucketHttp): Promise<BitbucketPrCache> {
129130
logger.debug('Syncing PR list');
130131
const url = this.getUrl();
131-
const opts = { paginate: true, pagelen: 50 };
132+
const opts = {
133+
paginate: true,
134+
pagelen: 50,
135+
cacheProvider: repoCacheProvider,
136+
};
132137
const res = await http.getJson<PagedResult<PrResponse>>(url, opts);
133138
this.reconcile(res.body.values);
134139
return this;

0 commit comments

Comments
 (0)