Fix downloads for repositories located at bitbucket.org

Signed-off-by: Mathias Åhsberg <mathias.ahsberg@resurs.se>
This commit is contained in:
Mathias Åhsberg
2021-07-01 14:48:27 +00:00
parent 7090564aca
commit b691a938e4
4 changed files with 11 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/integration': patch
---
Fix downloads from repositories located at bitbucket.org
@@ -119,14 +119,14 @@ describe('BitbucketUrlReader', () => {
),
),
rest.get(
'https://bitbucket.org/backstage/mock/get/master.tgz',
'https://bitbucket.org/backstage/mock/get/master.tar.gz',
(_, res, ctx) =>
res(
ctx.status(200),
ctx.set('Content-Type', 'application/zip'),
ctx.set(
'content-disposition',
'attachment; filename=backstage-mock-12ab34cd56ef.tgz',
'attachment; filename=backstage-mock-12ab34cd56ef.tar.gz',
),
ctx.body(repoBuffer),
),
@@ -304,14 +304,14 @@ describe('BitbucketUrlReader', () => {
),
),
rest.get(
'https://bitbucket.org/backstage/mock/get/master.tgz',
'https://bitbucket.org/backstage/mock/get/master.tar.gz',
(_, res, ctx) =>
res(
ctx.status(200),
ctx.set('Content-Type', 'application/zip'),
ctx.set(
'content-disposition',
'attachment; filename=backstage-mock-12ab34cd56ef.tgz',
'attachment; filename=backstage-mock-12ab34cd56ef.tar.gz',
),
ctx.body(repoBuffer),
),
@@ -192,7 +192,7 @@ describe('bitbucket core', () => {
config,
);
expect(result).toEqual(
'https://bitbucket.org/backstage/mock/get/master.tgz',
'https://bitbucket.org/backstage/mock/get/master.tar.gz',
);
});
});
+1 -1
View File
@@ -98,7 +98,7 @@ export async function getBitbucketDownloadUrl(
// /docs/index.md will download the docs folder and everything below it
const path = filepath ? `&path=${encodeURIComponent(filepath)}` : '';
const archiveUrl = isHosted
? `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tgz`
? `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`
: `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;
return archiveUrl;