MCPcopy
hub / github.com/vuejs/core / isInSyncWithRemote

Function isInSyncWithRemote

scripts/release.js:337–363  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

335}
336
337async 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
365async function getSha() {
366 return (await exec('git', ['rev-parse', 'HEAD'])).stdout

Callers 1

mainFunction · 0.85

Calls 3

getBranchFunction · 0.85
getShaFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected