/**
 * Determines if a commit is in a pull-request
 * @param {object} context - Probot context object
 * @param {string} sha - Commit sha
 * @returns {number|boolean} - The PR number if it exists or false
 */
async function commitIsInPR (context, sha) {
  const prs = await context.github.pullRequests.getAll(context.repo())
  if (!prs.data || prs.data.length === 0) return false

  prs.data.forEach(async pr => {
    const commits = await context.github.pullRequests.getCommits(context.repo({number: pr.number}))
    if (!commits.data || commits.data.length === 0) return false

    if (commits.data.some(c => c.sha === sha)) {
      return pr.number
    }
  })
  return false
}

module.exports = commitIsInPR

@@ -202,16 +202,33 @@
 lse%0A */%0A
+module.exports = 
 async fu
@@ -397,256 +397,111 @@
 %0A%0A  
-prs.data.forEach(async pr =%3E %7B%0A    const commits = await context.github.pullRequests.getCommits(context.repo(%7Bnumber: pr.number%7D))%0A    if (!commits.data %7C%7C commits.data.length === 0) return false%0A%0A    if (commits.data.some(c =%3E c.sha === sha)
+const found = prs.data.find(pr =%3E 'refs/heads/' + pr.head.ref === context.payload.ref)%0A%0A  if (found
 ) %7B%0A
-  
     
@@ -507,18 +507,21 @@
  return 
-pr
+found
 .number%0A
@@ -526,17 +526,19 @@
 r%0A  
-  %7D%0A  %7D)%0A
+%7D else %7B%0A  
   re
@@ -552,37 +552,10 @@
 lse%0A
-%7D%0A%0Amodule.exports = commitIsInPR
+  %7D%0A%7D
 %0A

Fix PR testing