Skip to content

Commit

Permalink
fix(bitbucket): attempt to fix bitbucket URL parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopsimek committed Nov 16, 2019
1 parent e733cd6 commit ef1a4d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/services/bitbucket/BitbucketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,19 @@ export class BitbucketService implements ICVSService {

this.client = new Bitbucket(clientOptions);

const username = GitUrlParse(argumentsProvider.uri).owner;
let username: string;
let password: string | undefined;
if (argumentsProvider.auth?.includes(':')) {
username = argumentsProvider.auth.split(':')[0];
password = argumentsProvider.auth.split(':')[1];
} else {
username = GitUrlParse(argumentsProvider.uri).owner;
password = argumentsProvider.auth;
}

let auth: Bitbucket.Auth;
if (argumentsProvider.auth) {
auth = { type: 'apppassword', username: username, password: argumentsProvider.auth };
auth = { type: 'apppassword', username, password: password! };
this.client.authenticate(auth);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/services/git/GitServiceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class GitServiceUtils {
switch (service) {
case GitService.github:
return `/tree/${branch}${path}`;
case GitService.bitbucket:
return `/src/${branch}${path}`;

default:
return assertNever(service);
Expand Down
1 change: 1 addition & 0 deletions src/services/git/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum GitService {
github = 'github.com',
bitbucket = 'bitbucket.org',
}

export interface UserInfo {
Expand Down

0 comments on commit ef1a4d8

Please sign in to comment.