| 1142 | // Falls back to fetching from origin when local refs are missing |
| 1143 | // (common in shallow clones from actions/checkout). |
| 1144 | async function hasNewCommits(base: string, head: string) { |
| 1145 | const result = await gitStatus(["rev-list", "--count", `${base}..${head}`]) |
| 1146 | if (result.exitCode !== 0) { |
| 1147 | console.log(`rev-list failed, fetching origin/${base}...`) |
| 1148 | await gitStatus(["fetch", "origin", base, "--depth=1"]) |
| 1149 | const retry = await gitStatus(["rev-list", "--count", `origin/${base}..${head}`]) |
| 1150 | if (retry.exitCode !== 0) return true // assume dirty if we can't tell |
| 1151 | return parseInt(retry.stdout.toString().trim()) > 0 |
| 1152 | } |
| 1153 | return parseInt(result.stdout.toString().trim()) > 0 |
| 1154 | } |
| 1155 | |
| 1156 | async function assertPermissions() { |
| 1157 | // Only called for non-schedule events, so actor is defined |