| 243 | } |
| 244 | |
| 245 | private async hasDiff(base: string, upstream: string): Promise<boolean> { |
| 246 | try { |
| 247 | const comparison = await this.github.repos.compareCommits({ |
| 248 | owner: this.owner, |
| 249 | repo: this.repo, |
| 250 | head: upstream, |
| 251 | base, |
| 252 | per_page: 1, |
| 253 | }); |
| 254 | return comparison.data.total_commits > 0; |
| 255 | } catch (e) { |
| 256 | if (e instanceof Error) { |
| 257 | if (e.message.match(/this diff is taking too long to generate/i)) { |
| 258 | return true; |
| 259 | } else if (e.message.match(/not found/i)) { |
| 260 | this.logger.debug( |
| 261 | `${this.owner}:${base}...${upstream} Not found`, |
| 262 | ); |
| 263 | return false; |
| 264 | } else if (e.message.match(/no common ancestor/i)) { |
| 265 | this.logger.debug( |
| 266 | `${this.owner}:${base}...${upstream} No common ancestor`, |
| 267 | ); |
| 268 | return false; |
| 269 | } |
| 270 | } |
| 271 | this.logger.error( |
| 272 | { |
| 273 | err: e, |
| 274 | head: upstream, |
| 275 | }, |
| 276 | `Unable to fetch diff`, |
| 277 | ); |
| 278 | return false; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | private async getOpenPR(base: string, head: string) { |
| 283 | this.logger.debug( |