MCPcopy
hub / github.com/vercel/next.js / checkGitStatus

Function checkGitStatus

packages/next-codemod/lib/utils.ts:4–32  ·  view source on GitHub ↗
(force)

Source from the content-addressed store, hash-verified

2import isGitClean from 'is-git-clean'
3
4export function checkGitStatus(force) {
5 let clean = false
6 let errorMessage = 'Unable to determine if git directory is clean'
7 try {
8 clean = isGitClean.sync(process.cwd())
9 errorMessage = 'Git directory is not clean'
10 } catch (err) {
11 if (err && err.stderr && err.stderr.includes('Not a git repository')) {
12 clean = true
13 }
14 }
15
16 if (!clean) {
17 if (force) {
18 console.log(`WARNING: ${errorMessage}. Forcibly continuing.`)
19 } else {
20 console.log('Thank you for using @next/codemod!')
21 console.log(
22 yellow(
23 '\nBut before we continue, please stash or commit your git changes.'
24 )
25 )
26 console.log(
27 '\nYou may use the --force flag to override this safety check.'
28 )
29 process.exit(1)
30 }
31 }
32}
33
34export function onCancel() {
35 process.exit(1)

Callers 1

runTransformFunction · 0.90

Calls 4

yellowFunction · 0.85
includesMethod · 0.80
logMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…