Skip to content

Commit

Permalink
fix: also support git@bitbucket like urls
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Feb 11, 2018
1 parent daa9226 commit 37fe559
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/bitbucket-repository-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export class BitbucketProvider extends Provider {
name = url.pathname;
name = name.replace(/\.git$/, '');
name = name.replace(/^\//, '');
} else if (name.startsWith('git@')) {
const [host, pathname] = name.split(/:/);
name = pathname;
name = name.replace(/\.git$/, '');
name = name.replace(/^\//, '');
}

let r = this.repositories.get(name);
Expand Down
15 changes: 14 additions & 1 deletion tests/bitbucket-repository-provider-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('provider', async t => {
t.is(branch.name, 'master');
});

test('provider url', async t => {
test('provider url https', async t => {
const provider = new BitbucketProvider(config);
const repository = await provider.repository(
'https://arlac77@bitbucket.org/arlac77/sync-test-repository.git'
Expand All @@ -43,6 +43,19 @@ test('provider url', async t => {
t.is(branch.name, 'master');
});

test('provider url git@', async t => {
const provider = new BitbucketProvider(config);
const repository = await provider.repository(
'git@bitbucket.org:arlac77/sync-test-repository.git'
);

t.is(repository.name, 'arlac77/sync-test-repository');
t.is(repository.user, 'arlac77');

const branch = await repository.branch('master');
t.is(branch.name, 'master');
});

test('provider repo with branch name', async t => {
const provider = new BitbucketProvider(config);

Expand Down

0 comments on commit 37fe559

Please sign in to comment.