Skip to content

Commit

Permalink
Merge pull request #73 from fabn/gitlab-links
Browse files Browse the repository at this point in the history
Add provider links for gitlab
  • Loading branch information
rafinskipg authored Jan 11, 2017
2 parents 5d469ae + dc3c4ac commit 6df54f0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
13 changes: 12 additions & 1 deletion tasks/lib/get-provider-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ function getProviderLinks() {
bitbucket: {
issue: '[#%s](' + this.options.repo_url + '/issues/%s)',
commit: '[%s](' + this.options.repo_url + '/commits/%s)'
},
gitlab: {
issue: '[#%s](' + this.options.repo_url + '/issues/%s)',
commit: '[%s](' + this.options.repo_url + '/commit/%s)'
}
};

this.provider = this.options.repo_url.indexOf('github.com') !== -1 ? 'github' :'bitbucket';
if (this.options.repo_url.match(/bitbucket/)) {
this.provider = 'bitbucket';
} else if (this.options.repo_url.match(/gitlab/)) {
this.provider = 'gitlab';
} else {
// use github as default provider
this.provider = 'github';
}
this.links = providerLinks[this.provider];
}

Expand Down
24 changes: 19 additions & 5 deletions test/git_changelog_generate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,38 @@ describe('git_changelog_generate.js', function() {
expect(changelog.provider).to.equal('github');

expect(changelog.links.issue).to.contain(repo_url);
expect(changelog.links.issue).to.contain('issue');
expect(changelog.links.issue).to.contain('issues/%s');

expect(changelog.links.commit).to.contain(repo_url);
expect(changelog.links.commit).to.contain('commit');
expect(changelog.links.commit).to.contain('commit/%s');
});

it('should set provider/links to BitBucket', function() {
var repo_url = 'https://www.bitbuket.com/owner/repo';
var repo_url = 'https://www.bitbucket.com/owner/repo';
changelog.options.repo_url = repo_url;
changelog.getProviderLinks();

expect(changelog.provider).to.equal('bitbucket');

expect(changelog.links.issue).to.contain(repo_url);
expect(changelog.links.issue).to.contain('issue');
expect(changelog.links.issue).to.contain('issues/%s');

expect(changelog.links.commit).to.contain(repo_url);
expect(changelog.links.commit).to.contain('commit');
expect(changelog.links.commit).to.contain('commits/%s');
});

it('should set provider/links to GitLab', function() {
var repo_url = 'https://gitlab.com/owner/repo';
changelog.options.repo_url = repo_url;
changelog.getProviderLinks();

expect(changelog.provider).to.equal('gitlab');

expect(changelog.links.issue).to.contain(repo_url);
expect(changelog.links.issue).to.contain('issues/%s');

expect(changelog.links.commit).to.contain(repo_url);
expect(changelog.links.commit).to.contain('commit/%s');
});

});
Expand Down

0 comments on commit 6df54f0

Please sign in to comment.