diff --git a/index.js b/index.js index ab5d41a..310b6d1 100644 --- a/index.js +++ b/index.js @@ -257,6 +257,17 @@ class ScmRouter extends Scm { return this.chooseScm(config).then(scm => scm.getCommitSha(config)); } + /** + * Add a comment on a pull request + * @method _addPrComment + * @param {Object} config Configuration + * @param {String} config.scmContext Name of scm context + * @return {Promise} + */ + _addPrComment(config) { + return this.chooseScm(config).then(scm => scm.addPrComment(config)); + } + /** * Update the commit status for a given repo and sha * @method _updateCommitStatus diff --git a/package.json b/package.json index 4dd7706..6df15eb 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ }, "dependencies": { "async": "^2.6.1", - "screwdriver-scm-base": "^4.4.3" + "screwdriver-scm-base": "^5.0.0" }, "release": { "debug": false, diff --git a/test/index.test.js b/test/index.test.js index 15d1156..9f3820d 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -46,6 +46,7 @@ describe('index test', () => { 'getPermissions', 'getOrgPermissions', 'getCommitSha', + 'addPrComment', 'updateCommitStatus', 'getFile', 'getChangedFiles', @@ -730,6 +731,25 @@ describe('index test', () => { }); }); + describe('_addPrComment', () => { + const config = { scmContext: 'example.context' }; + + it('call origin addPrComment', () => { + const scmGithub = scm.scms['github.context']; + const exampleScm = scm.scms['example.context']; + const scmGitlab = scm.scms['gitlab.context']; + + return scm._addPrComment(config) + .then((result) => { + assert.strictEqual(result, 'example'); + assert.notCalled(scmGithub.addPrComment); + assert.notCalled(scmGitlab.addPrComment); + assert.calledOnce(exampleScm.addPrComment); + assert.calledWith(exampleScm.addPrComment, config); + }); + }); + }); + describe('_updateCommitStatus', () => { const config = { scmContext: 'example.context' };