Skip to content

Commit

Permalink
fix: as the bitbucket fails if the account is a team account add poss…
Browse files Browse the repository at this point in the history
…ibility to ownerId be a null
  • Loading branch information
adelkahomolova committed Dec 8, 2019
1 parent 633caea commit 37bc6f2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/services/bitbucket/BitbucketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ export class BitbucketService implements IVCSService {
}

const ownerUrl = `www.bitbucket.org/${owner}`;
const ownerId = `${(await this.client.users.get({ username: owner })).data.uuid}`;
let ownerId: string | null;
try {
ownerId = `${(await this.client.users.get({ username: 'atlassian' })).data.uuid}`;
} catch (error) {
if (error.message.includes('is a team account')) {
ownerId = null;
}
}

const response: DeepRequired<Bitbucket.Response<Bitbucket.Schema.PaginatedPullrequests>> = await axios.get(apiUrl);

Expand All @@ -122,7 +129,7 @@ export class BitbucketService implements IVCSService {
id: val.destination.repository.uuid,
owner: {
login: owner,
id: ownerId,
id: <string>ownerId,
url: ownerUrl,
},
},
Expand Down

0 comments on commit 37bc6f2

Please sign in to comment.