fix(platform/gerrit): URI encode branch in gerrit's getFile() (#30753)

This commit is contained in:
Jonas 2024-08-14 09:20:48 +02:00 committed by GitHub
parent eccb4d5714
commit d554483f88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -415,11 +415,11 @@ describe('modules/platform/gerrit/client', () => {
httpMock
.scope(gerritEndpointUrl)
.get(
'/a/projects/test%2Frepo/branches/main/files/renovate.json/content',
'/a/projects/test%2Frepo/branches/base%2Fbranch/files/renovate.json/content',
)
.reply(200, gerritFileResponse('{}'));
await expect(
client.getFile('test/repo', 'main', 'renovate.json'),
client.getFile('test/repo', 'base/branch', 'renovate.json'),
).resolves.toBe('{}');
});
});

View file

@ -195,7 +195,7 @@ class GerritClient {
const base64Content = await this.gerritHttp.get(
`a/projects/${encodeURIComponent(
repo,
)}/branches/${branch}/files/${encodeURIComponent(fileName)}/content`,
)}/branches/${encodeURIComponent(branch)}/files/${encodeURIComponent(fileName)}/content`,
);
return Buffer.from(base64Content.body, 'base64').toString();
}