| 335 | } |
| 336 | |
| 337 | async function isInSyncWithRemote() { |
| 338 | try { |
| 339 | const branch = await getBranch() |
| 340 | const res = await fetch( |
| 341 | `https://api.github.com/repos/vuejs/core/commits/${branch}?per_page=1`, |
| 342 | ) |
| 343 | const data = await res.json() |
| 344 | if (data.sha === (await getSha())) { |
| 345 | return true |
| 346 | } else { |
| 347 | /** @type {{ yes: boolean }} */ |
| 348 | const { yes } = await prompt({ |
| 349 | type: 'confirm', |
| 350 | name: 'yes', |
| 351 | message: pico.red( |
| 352 | `Local HEAD is not up-to-date with remote. Are you sure you want to continue?`, |
| 353 | ), |
| 354 | }) |
| 355 | return yes |
| 356 | } |
| 357 | } catch { |
| 358 | console.error( |
| 359 | pico.red('Failed to check whether local HEAD is up-to-date with remote.'), |
| 360 | ) |
| 361 | return false |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | async function getSha() { |
| 366 | return (await exec('git', ['rev-parse', 'HEAD'])).stdout |