Skip to content

Commit

Permalink
Merge pull request #74 from Treyone/master
Browse files Browse the repository at this point in the history
feat(providers): Add possibility to set providers in the options
  • Loading branch information
rafinskipg authored Jan 18, 2017
2 parents 6df54f0 + 14da6fe commit 4d539ac
Show file tree
Hide file tree
Showing 2 changed files with 893 additions and 855 deletions.
57 changes: 31 additions & 26 deletions tasks/lib/get-provider-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,38 @@
var debug = require('debug')('changelog:getProviderLinks');

function getProviderLinks() {
debug('getting provider links');
// This is just in case they differ their urls at some point in the future.
// Also brings the posibility of adding more providers
var providerLinks = {
github: {
issue: '[#%s](' + this.options.repo_url + '/issues/%s)',
commit: '[%s](' + this.options.repo_url + '/commit/%s)'
},
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)'
}
};
debug('getting provider links');
// This is just in case they differ their urls at some point in the future.
// Also brings the posibility of adding more providers
var providerLinks = {
github: {
issue: '[#%s](' + this.options.repo_url + '/issues/%s)',
commit: '[%s](' + this.options.repo_url + '/commit/%s)'
},
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)'
}
};

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];
if (this.options.provider && typeof(providerLinks[this.options.provider]) !== 'undefined') {
this.provider = this.options.provider;
}
else {
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];
}

module.exports = getProviderLinks;
Loading

0 comments on commit 4d539ac

Please sign in to comment.