Skip to content

Commit

Permalink
feat(platform/bitbucket-server): modify getJsonFile to use branchOrTa…
Browse files Browse the repository at this point in the history
…g on Bitbucket server (#12824)

Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
olegkrivtsov and rarkins committed Nov 24, 2021
1 parent 4285713 commit 2ec5c54
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
12 changes: 6 additions & 6 deletions lib/platform/bitbucket-server/__snapshots__/index.spec.ts.snap
Expand Up @@ -2027,7 +2027,7 @@ Array [
]
`;

exports[`platform/bitbucket-server/index endpoint with no path getJsonFile() ignores branchOrTag argument 1`] = `
exports[`platform/bitbucket-server/index endpoint with no path getJsonFile() returns file content 1`] = `
Array [
Object {
"headers": Object {
Expand Down Expand Up @@ -2068,7 +2068,7 @@ Array [
]
`;

exports[`platform/bitbucket-server/index endpoint with no path getJsonFile() returns file content 1`] = `
exports[`platform/bitbucket-server/index endpoint with no path getJsonFile() returns file content from branch or tag 1`] = `
Array [
Object {
"headers": Object {
Expand Down Expand Up @@ -2104,7 +2104,7 @@ Array [
"x-atlassian-token": "no-check",
},
"method": "GET",
"url": "https://stash.renovatebot.com/rest/api/1.0/projects/SOME/repos/repo/browse/file.json?limit=20000",
"url": "https://stash.renovatebot.com/rest/api/1.0/projects/SOME/repos/repo/browse/file.json?limit=20000&at=dev",
},
]
`;
Expand Down Expand Up @@ -6525,7 +6525,7 @@ Array [
]
`;
exports[`platform/bitbucket-server/index endpoint with path getJsonFile() ignores branchOrTag argument 1`] = `
exports[`platform/bitbucket-server/index endpoint with path getJsonFile() returns file content 1`] = `
Array [
Object {
"headers": Object {
Expand Down Expand Up @@ -6566,7 +6566,7 @@ Array [
]
`;
exports[`platform/bitbucket-server/index endpoint with path getJsonFile() returns file content 1`] = `
exports[`platform/bitbucket-server/index endpoint with path getJsonFile() returns file content from branch or tag 1`] = `
Array [
Object {
"headers": Object {
Expand Down Expand Up @@ -6602,7 +6602,7 @@ Array [
"x-atlassian-token": "no-check",
},
"method": "GET",
"url": "https://stash.renovatebot.com/vcs/rest/api/1.0/projects/SOME/repos/repo/browse/file.json?limit=20000",
"url": "https://stash.renovatebot.com/vcs/rest/api/1.0/projects/SOME/repos/repo/browse/file.json?limit=20000&at=dev",
},
]
`;
Expand Down
4 changes: 2 additions & 2 deletions lib/platform/bitbucket-server/index.spec.ts
Expand Up @@ -2150,12 +2150,12 @@ Followed by some information.
expect(httpMock.getTrace()).toMatchSnapshot();
});

it('ignores branchOrTag argument', async () => {
it('returns file content from branch or tag', async () => {
const data = { foo: 'bar' };
const scope = await initRepo();
scope
.get(
`${urlPath}/rest/api/1.0/projects/SOME/repos/repo/browse/file.json?limit=20000`
`${urlPath}/rest/api/1.0/projects/SOME/repos/repo/browse/file.json?limit=20000&at=dev`
)
.reply(200, {
isLastPage: true,
Expand Down
4 changes: 3 additions & 1 deletion lib/platform/bitbucket-server/index.ts
Expand Up @@ -128,7 +128,9 @@ export async function getRawFile(
): Promise<string | null> {
const repo = repoName ?? config.repository;
const [project, slug] = repo.split('/');
const fileUrl = `./rest/api/1.0/projects/${project}/repos/${slug}/browse/${fileName}?limit=20000`;
const fileUrl =
`./rest/api/1.0/projects/${project}/repos/${slug}/browse/${fileName}?limit=20000` +
(branchOrTag ? '&at=' + branchOrTag : '');
const res = await bitbucketServerHttp.getJson<FileData>(fileUrl);
const { isLastPage, lines, size } = res.body;
if (isLastPage) {
Expand Down

0 comments on commit 2ec5c54

Please sign in to comment.