MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / countLinesChanged

Function countLinesChanged

source code/utils/diff.ts:51–81  ·  view source on GitHub ↗
(
  patch: StructuredPatchHunk[],
  newFileContent?: string,
)

Source from the content-addressed store, hash-verified

49 * @param newFileContent Optional content string for new files
50 */
51export function countLinesChanged(
52 patch: StructuredPatchHunk[],
53 newFileContent?: string,
54): void {
55 let numAdditions = 0
56 let numRemovals = 0
57
58 if (patch.length === 0 && newFileContent) {
59 // For new files, count all lines as additions
60 numAdditions = newFileContent.split(/\r?\n/).length
61 } else {
62 numAdditions = patch.reduce(
63 (acc, hunk) => acc + count(hunk.lines, _ => _.startsWith('+')),
64 0,
65 )
66 numRemovals = patch.reduce(
67 (acc, hunk) => acc + count(hunk.lines, _ => _.startsWith('-')),
68 0,
69 )
70 }
71
72 addToTotalLinesChanged(numAdditions, numRemovals)
73
74 getLocCounter()?.add(numAdditions, { type: 'added' })
75 getLocCounter()?.add(numRemovals, { type: 'removed' })
76
77 logEvent('tengu_file_changed', {
78 lines_added: numAdditions,
79 lines_removed: numRemovals,
80 })
81}
82
83export function getPatchFromContents({
84 filePath,

Callers 2

callFunction · 0.85
callFunction · 0.85

Calls 5

countFunction · 0.85
addToTotalLinesChangedFunction · 0.85
getLocCounterFunction · 0.85
logEventFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected