| 155 | } |
| 156 | |
| 157 | async function findPRForCommit(commitHash) { |
| 158 | try { |
| 159 | // Use gh CLI to find PR associated with commit |
| 160 | const result = execSync( |
| 161 | `gh api repos/${REPO}/commits/${commitHash}/pulls --jq '.[0].number'`, |
| 162 | { encoding: `utf8`, stdio: [`pipe`, `pipe`, `pipe`] } |
| 163 | ).trim() |
| 164 | |
| 165 | if (result && result !== `null`) { |
| 166 | console.log(` Commit ${commitHash} -> PR #${result}`) |
| 167 | return parseInt(result, 10) |
| 168 | } |
| 169 | } catch (e) { |
| 170 | // Commit might not be associated with a PR (direct push) |
| 171 | console.log(` Commit ${commitHash} has no associated PR`) |
| 172 | } |
| 173 | return null |
| 174 | } |
| 175 | |
| 176 | async function commentOnPR(prNumber, packages) { |
| 177 | const packageList = packages |