MCPcopy Index your code
hub / github.com/codeaashu/claude-code / fileHistoryHasAnyChanges

Function fileHistoryHasAnyChanges

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

Source from the content-addressed store, hash-verified

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