Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(1769): Do not throw err if cannot get changed files #142

Merged
merged 1 commit into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ class GithubScm extends Scm {

/**
* Get a users permissions on an organization
* @method getOrgPermissions
* @method _getOrgPermissions
* @param {Object} config Configuration
* @param {String} config.organization The organization to get permissions on
* @param {String} config.username The user to check against
Expand Down Expand Up @@ -651,7 +651,7 @@ class GithubScm extends Scm {

/**
* Get a commit sha from a reference
* @async getCommitRefSha
* @async _getCommitRefSha
* @param {Object} config
* @param {String} config.token The token used to authenticate to the SCM
* @param {String} config.owner The owner of the target repository
Expand Down Expand Up @@ -1029,7 +1029,8 @@ class GithubScm extends Scm {
return files.map(file => file.filename);
} catch (err) {
winston.error('Failed to getChangedFiles: ', err);
throw err;

return [];
}
}

Expand Down Expand Up @@ -1236,8 +1237,9 @@ class GithubScm extends Scm {

/**
* Resolve a pull request object based on the config
* @async getPrRef
* @async _getPrInfo
* @param {Object} config
* @param {Object} [config.scmRepo] The SCM repository to look up
* @param {String} config.scmUri The scmUri to get PR info of
* @param {String} config.token The token used to authenticate to the SCM
* @param {Integer} config.prNum The PR number used to fetch the PR
Expand Down Expand Up @@ -1286,6 +1288,7 @@ class GithubScm extends Scm {

/**
* Add a PR comment
* @async _addPrComment
* @param {Object} config
* @param {String} config.comment The PR comment
* @param {Integer} config.prNum The PR number
Expand Down Expand Up @@ -1326,7 +1329,7 @@ class GithubScm extends Scm {

/**
* Get an array of scm context (e.g. github:github.com)
* @method getScmContexts
* @method _getScmContexts
* @return {Array} Array of scm contexts
*/
_getScmContexts() {
Expand All @@ -1339,7 +1342,7 @@ class GithubScm extends Scm {

/**
* Determine if an scm module can handle the received webhook
* @async canHandleWebhook
* @async _canHandleWebhook
* @param {Object} headers The request headers associated with the webhook payload
* @param {Object} payload The webhook payload received from the SCM service
* @return {Promise} Resolves a boolean denoting whether scm module supports webhook
Expand Down
11 changes: 4 additions & 7 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ jobs:
});
});

it('rejects when failing to communicate with github', () => {
it('returns empty array when failing to communicate with github', () => {
const testError = new Error('someGithubCommError');

type = 'pr';
Expand All @@ -1150,11 +1150,8 @@ jobs:
type,
token,
payload: testPayloadOpen
}).then(() => {
assert.fail('This should not fail the test');
}, (err) => {
assert.deepEqual(err, testError);

}).then((result) => {
assert.deepEqual(result, []);
assert.calledWith(githubMock.paginate,
'GET /repos/:owner/:repo/pulls/:number/files', {
owner: 'baxterthehacker',
Expand Down Expand Up @@ -2005,7 +2002,7 @@ jobs:
});
});

describe('_getOpenedPRs', () => {
describe('getOpenedPRs', () => {
const scmUri = 'github.com:111:branchName';
const config = {
scmUri,
Expand Down