Comparing version 2.0.1 to 2.0.2
@@ -54,2 +54,3 @@ 'use strict'; | ||
internals.getOpenPullRequestForSpecificBranch = (github, repo_owner, repo_name, branch_name) => { | ||
const head = `${ repo_owner }:refs/heads/${ branch_name }`; | ||
return new _promise2.default((resolve, reject) => { | ||
@@ -60,3 +61,3 @@ github.pullRequests.getAll({ | ||
state: 'open', | ||
head: branch_name | ||
head: head | ||
}, (err, res) => { | ||
@@ -68,11 +69,20 @@ if (err) { | ||
if (res && Array.isArray(res) && res.length > 0) { | ||
resolve(res[0]); | ||
if (!res || !Array.isArray(res) || res.length === 0) { | ||
reject(createError({ | ||
code: 404, | ||
message: `No open pull request found for this branch: ${ branch_name }` | ||
})); | ||
return; | ||
} | ||
reject(createError({ | ||
code: 404, | ||
message: `No open pull request found for this branch: ${ branch_name }` | ||
})); | ||
const filtered_pull_request = res.find(item => item.head.ref === branch_name); | ||
if (!filtered_pull_request) { | ||
reject(createError({ | ||
code: 404, | ||
message: `Could not find the pull request for branch: ${ branch_name }` | ||
})); | ||
return; | ||
} | ||
resolve(filtered_pull_request); | ||
}); | ||
@@ -79,0 +89,0 @@ }); |
@@ -64,3 +64,3 @@ { | ||
}, | ||
"version": "2.0.1" | ||
"version": "2.0.2" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11965
161