Skip to content

Commit aad6818

Browse files
authored
feat(1355): Add PR comment support. BREAKING CHANGE: new scm-base
This reverts commit c6c1b9a.
1 parent c6c1b9a commit aad6818

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,17 @@ class ScmRouter extends Scm {
257257
return this.chooseScm(config).then(scm => scm.getCommitSha(config));
258258
}
259259

260+
/**
261+
* Add a comment on a pull request
262+
* @method _addPrComment
263+
* @param {Object} config Configuration
264+
* @param {String} config.scmContext Name of scm context
265+
* @return {Promise}
266+
*/
267+
_addPrComment(config) {
268+
return this.chooseScm(config).then(scm => scm.addPrComment(config));
269+
}
270+
260271
/**
261272
* Update the commit status for a given repo and sha
262273
* @method _updateCommitStatus

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
},
4444
"dependencies": {
4545
"async": "^2.6.1",
46-
"screwdriver-scm-base": "^4.4.3"
46+
"screwdriver-scm-base": "^5.0.0"
4747
},
4848
"release": {
4949
"debug": false,

test/index.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ describe('index test', () => {
4646
'getPermissions',
4747
'getOrgPermissions',
4848
'getCommitSha',
49+
'addPrComment',
4950
'updateCommitStatus',
5051
'getFile',
5152
'getChangedFiles',
@@ -730,6 +731,25 @@ describe('index test', () => {
730731
});
731732
});
732733

734+
describe('_addPrComment', () => {
735+
const config = { scmContext: 'example.context' };
736+
737+
it('call origin addPrComment', () => {
738+
const scmGithub = scm.scms['github.context'];
739+
const exampleScm = scm.scms['example.context'];
740+
const scmGitlab = scm.scms['gitlab.context'];
741+
742+
return scm._addPrComment(config)
743+
.then((result) => {
744+
assert.strictEqual(result, 'example');
745+
assert.notCalled(scmGithub.addPrComment);
746+
assert.notCalled(scmGitlab.addPrComment);
747+
assert.calledOnce(exampleScm.addPrComment);
748+
assert.calledWith(exampleScm.addPrComment, config);
749+
});
750+
});
751+
});
752+
733753
describe('_updateCommitStatus', () => {
734754
const config = { scmContext: 'example.context' };
735755

0 commit comments

Comments
 (0)