Skip to content

Commit

Permalink
feat(1355): Add PR comment support. BREAKING CHANGE: new scm-base
Browse files Browse the repository at this point in the history
This reverts commit c6c1b9a.
  • Loading branch information
tkyi authored Dec 21, 2018
1 parent c6c1b9a commit aad6818
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"dependencies": {
"async": "^2.6.1",
"screwdriver-scm-base": "^4.4.3"
"screwdriver-scm-base": "^5.0.0"
},
"release": {
"debug": false,
Expand Down
20 changes: 20 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('index test', () => {
'getPermissions',
'getOrgPermissions',
'getCommitSha',
'addPrComment',
'updateCommitStatus',
'getFile',
'getChangedFiles',
Expand Down Expand Up @@ -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' };

Expand Down

0 comments on commit aad6818

Please sign in to comment.