Skip to content

Commit

Permalink
fix: getting ownerId if it's team account
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Dec 8, 2019
1 parent 4118637 commit bd86a78
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/services/bitbucket/BitbucketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ export class BitbucketService implements IVCSService {
}

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

Expand Down Expand Up @@ -129,7 +129,7 @@ export class BitbucketService implements IVCSService {
id: val.destination.repository.uuid,
owner: {
login: owner,
id: <string>ownerId,
id: ownerId,
url: ownerUrl,
},
},
Expand All @@ -152,8 +152,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 = '';
try {
ownerId = `${(await this.client.users.get({ username: owner })).data.uuid}`;
} catch (error) {
if (error.message.includes('is a team account')) {
ownerId = `${(await this.client.teams.get({ username: owner })).data.uuid}`;
}
}
const response = <DeepRequired<Bitbucket.Response<Bitbucket.Schema.Pullrequest>>>await this.client.pullrequests.get(params);
response.data;

Expand Down

0 comments on commit bd86a78

Please sign in to comment.