MCPcopy
hub / github.com/claude-code-best/claude-code / fileHistoryHasAnyChanges

Function fileHistoryHasAnyChanges

src/utils/fileHistory.ts:496–533  ·  view source on GitHub ↗
(
  state: FileHistoryState,
  messageId: UUID,
)

Source from the content-addressed store, hash-verified

494 * callers that display insertions/deletions.
495 */
496export async function fileHistoryHasAnyChanges(
497 state: FileHistoryState,
498 messageId: UUID,
499): Promise<boolean> {
500 if (!fileHistoryEnabled()) {
501 return false
502 }
503
504 const targetSnapshot = state.snapshots.findLast(
505 snapshot => snapshot.messageId === messageId,
506 )
507 if (!targetSnapshot) {
508 return false
509 }
510
511 for (const trackingPath of state.trackedFiles) {
512 try {
513 const filePath = maybeExpandFilePath(trackingPath)
514 const targetBackup = targetSnapshot.trackedFileBackups[trackingPath]
515 const backupFileName: BackupFileName | undefined = targetBackup
516 ? targetBackup.backupFileName
517 : getBackupFileNameFirstVersion(trackingPath, state)
518
519 if (backupFileName === undefined) {
520 continue
521 }
522 if (backupFileName === null) {
523 // Backup says file did not exist; probe via stat (operate-then-catch).
524 if (await pathExists(filePath)) return true
525 continue
526 }
527 if (await checkOriginFileChanged(filePath, backupFileName)) return true
528 } catch (error) {
529 logError(error)
530 }
531 }
532 return false
533}
534
535/**
536 * Applies the given file snapshot state to the tracked files (writes/deletes

Callers 1

REPLFunction · 0.85

Calls 6

fileHistoryEnabledFunction · 0.85
maybeExpandFilePathFunction · 0.85
pathExistsFunction · 0.85
checkOriginFileChangedFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected