Merge branch 'master' of https://github.com/spotify/backstage into lintMod

This commit is contained in:
Debajyoti Halder
2021-01-29 14:05:27 +05:30
244 changed files with 4425 additions and 1286 deletions
+7
View File
@@ -1,5 +1,12 @@
# @backstage/integration
## 0.3.1
### Patch Changes
- 6800da78d: Fix default branch API url for custom hosted Bitbucket server
- 9dd057662: Upgrade [git-url-parse](https://www.npmjs.com/package/git-url-parse) to [v11.4.4](https://github.com/IonicaBizau/git-url-parse/pull/125) which fixes parsing an Azure DevOps branch ref.
## 0.3.0
### Minor Changes
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@backstage/integration",
"version": "0.3.0",
"version": "0.3.1",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
@@ -31,13 +31,13 @@
"dependencies": {
"@backstage/config": "^0.1.2",
"cross-fetch": "^3.0.6",
"git-url-parse": "^11.4.3",
"git-url-parse": "^11.4.4",
"@octokit/rest": "^18.0.12",
"@octokit/auth-app": "^2.10.5",
"luxon": "^1.25.0"
},
"devDependencies": {
"@backstage/cli": "^0.4.7",
"@backstage/cli": "^0.5.0",
"@backstage/test-utils": "^0.1.5",
"@types/jest": "^26.0.7",
"@types/luxon": "^1.25.0",
@@ -116,7 +116,7 @@ describe('bitbucket core', () => {
};
worker.use(
rest.get(
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/branches/default',
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/default-branch',
(_, res, ctx) =>
res(
ctx.status(200),
@@ -144,7 +144,7 @@ describe('bitbucket core', () => {
};
worker.use(
rest.get(
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/branches/default',
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/default-branch',
(_, res, ctx) =>
res(
ctx.status(200),
@@ -231,7 +231,7 @@ describe('bitbucket core', () => {
};
worker.use(
rest.get(
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/branches/default',
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/default-branch',
(_, res, ctx) =>
res(
ctx.status(200),
+6 -2
View File
@@ -31,9 +31,10 @@ export async function getBitbucketDefaultBranch(
const { name: repoName, owner: project, resource } = parseGitUrl(url);
const isHosted = resource === 'bitbucket.org';
// Bitbucket Server https://docs.atlassian.com/bitbucket-server/rest/7.9.0/bitbucket-rest.html#idp184
const branchUrl = isHosted
? `${config.apiBaseUrl}/repositories/${project}/${repoName}`
: `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;
: `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;
const response = await fetch(branchUrl, getBitbucketRequestOptions(config));
if (!response.ok) {
@@ -50,7 +51,10 @@ export async function getBitbucketDefaultBranch(
defaultBranch = displayId;
}
if (!defaultBranch) {
throw new Error(`Failed to read default branch from ${branchUrl}`);
throw new Error(
`Failed to read default branch from ${branchUrl}. ` +
`Response ${response.status} ${response.json()}`,
);
}
return defaultBranch;
}
+8 -3
View File
@@ -147,10 +147,15 @@ export async function getProjectId(
repoIDLookup.toString(),
getGitLabRequestOptions(config),
);
const projectIDJson = await response.json();
const projectID = Number(projectIDJson.id);
const data = await response.json();
return projectID;
if (!response.ok) {
throw new Error(
`GitLab Error '${data.error}', ${data.error_description}`,
);
}
return Number(data.id);
} catch (e) {
throw new Error(`Could not get GitLab project ID for: ${target}, ${e}`);
}