MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / trackFileDeletion

Function trackFileDeletion

src/utils/commitAttribution.ts:454–481  ·  view source on GitHub ↗
(
  state: AttributionState,
  filePath: string,
  oldContent: string,
)

Source from the content-addressed store, hash-verified

452 * Used when Claude deletes a file through a non-tracked mechanism.
453 */
454export function trackFileDeletion(
455 state: AttributionState,
456 filePath: string,
457 oldContent: string,
458): AttributionState {
459 const normalizedPath = normalizeFilePath(filePath)
460 const existingState = state.fileStates.get(normalizedPath)
461 const existingContribution = existingState?.claudeContribution ?? 0
462 const deletedChars = oldContent.length
463
464 const newFileState: FileAttributionState = {
465 contentHash: '', // Empty hash for deleted files
466 claudeContribution: existingContribution + deletedChars,
467 mtime: Date.now(),
468 }
469
470 const newFileStates = new Map(state.fileStates)
471 newFileStates.set(normalizedPath, newFileState)
472
473 logForDebugging(
474 `Attribution: Tracked deletion of ${normalizedPath} (${deletedChars} chars removed, total contribution: ${newFileState.claudeContribution})`,
475 )
476
477 return {
478 ...state,
479 fileStates: newFileStates,
480 }
481}
482
483// --
484

Callers

nothing calls this directly

Calls 5

normalizeFilePathFunction · 0.85
nowMethod · 0.80
setMethod · 0.80
logForDebuggingFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected