MCPcopy Index your code
hub / github.com/liuup/claude-code-analysis / getFrequentlyModifiedFiles

Function getFrequentlyModifiedFiles

src/utils/exampleCommands.ts:86–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84}
85
86async function getFrequentlyModifiedFiles(): Promise<string[]> {
87 if (process.env.NODE_ENV === 'test') return []
88 if (env.platform === 'win32') return []
89 if (!(await getIsGit())) return []
90
91 try {
92 // Collect frequently-modified files, preferring the user's own commits.
93 const userEmail = await getGitEmail()
94
95 const logArgs = [
96 'log',
97 '-n',
98 '1000',
99 '--pretty=format:',
100 '--name-only',
101 '--diff-filter=M',
102 ]
103
104 const counts = new Map<string, number>()
105 const tallyInto = (stdout: string) => {
106 for (const line of stdout.split('\n')) {
107 const f = line.trim()
108 if (f) counts.set(f, (counts.get(f) ?? 0) + 1)
109 }
110 }
111
112 if (userEmail) {
113 const { stdout } = await execFileNoThrowWithCwd(
114 'git',
115 [...logArgs, `--author=${userEmail}`],
116 { cwd: getCwd() },
117 )
118 tallyInto(stdout)
119 }
120
121 // Fall back to all authors if the user's own history is thin.
122 if (counts.size < 10) {
123 const { stdout } = await execFileNoThrowWithCwd(gitExe(), logArgs, {
124 cwd: getCwd(),
125 })
126 tallyInto(stdout)
127 }
128
129 const sorted = Array.from(counts.entries())
130 .sort((a, b) => b[1] - a[1])
131 .map(([p]) => p)
132
133 return pickDiverseCoreFiles(sorted, 5)
134 } catch (err) {
135 logError(err as Error)
136 return []
137 }
138}
139
140const ONE_WEEK_IN_MS = 7 * 24 * 60 * 60 * 1000
141

Callers 1

exampleCommands.tsFile · 0.85

Calls 6

execFileNoThrowWithCwdFunction · 0.85
getCwdFunction · 0.85
tallyIntoFunction · 0.85
pickDiverseCoreFilesFunction · 0.85
entriesMethod · 0.80
logErrorFunction · 0.70

Tested by

no test coverage detected