MCPcopy Index your code
hub / github.com/simstudioai/sim / changedMigrationFiles

Function changedMigrationFiles

scripts/check-migrations-safety.ts:393–418  ·  view source on GitHub ↗

New migration files on this branch vs base, plus uncommitted ones locally.

(baseRef: string)

Source from the content-addressed store, hash-verified

391
392/** New migration files on this branch vs base, plus uncommitted ones locally. */
393function changedMigrationFiles(baseRef: string): string[] {
394 const files = new Set<string>()
395 const inDir = (p: string) => p.startsWith(`${MIGRATIONS_DIR}/`) && p.endsWith('.sql')
396
397 const mergeBase = git(['merge-base', baseRef, 'HEAD']) ?? baseRef
398 const committed = git([
399 'diff',
400 '--name-only',
401 '--diff-filter=AM',
402 mergeBase,
403 'HEAD',
404 '--',
405 MIGRATIONS_DIR,
406 ])
407 if (committed === null) return [] // git unavailable → fail open (handled by caller)
408 for (const f of committed.split('\n')) if (inDir(f)) files.add(f)
409
410 const status = git(['status', '--porcelain', '--', MIGRATIONS_DIR])
411 if (status) {
412 for (const raw of status.split('\n')) {
413 const p = raw.slice(3).trim()
414 if (inDir(p)) files.add(p)
415 }
416 }
417 return [...files]
418}
419
420async function listSqlFiles(dir: string): Promise<string[]> {
421 const out: string[] = []

Callers 1

resolveFilesFunction · 0.85

Calls 3

gitFunction · 0.85
inDirFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected