MCPcopy Create free account
hub / github.com/scopecraft/command / getFilesToCheck

Function getFilesToCheck

scripts/code-check.ts:74–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72
73// Determine what files to check
74async function getFilesToCheck(): Promise<{ files: string[], mode: string, base?: string }> {
75 if (values.full) {
76 return { files: [], mode: 'full' };
77 }
78
79 if (values.staged) {
80 const stagedFiles = await git.diff(['--staged', '--name-status']);
81 const files = stagedFiles.split('\n')
82 .filter(line => line.trim() && !line.startsWith('D\t'))
83 .map(line => line.split('\t')[1])
84 .filter(f => f);
85 return {
86 files,
87 mode: 'staged'
88 };
89 }
90
91 if (values.base) {
92 try {
93 const diffFiles = await git.diff(['--name-status', `${values.base}...HEAD`]);
94 const files = diffFiles.split('\n')
95 .filter(line => line.trim() && !line.startsWith('D\t'))
96 .map(line => line.split('\t')[1])
97 .filter(f => f);
98 return {
99 files,
100 mode: 'base-comparison',
101 base: values.base
102 };
103 } catch (error) {
104 console.error(`❌ Error: Could not compare against '${values.base}'. Branch/commit may not exist.`);
105 process.exit(1);
106 }
107 }
108
109 // Default: files changed since last commit
110 try {
111 const changedFiles = await git.diff(['--name-status', 'HEAD~1']);
112 const files = changedFiles.split('\n')
113 .filter(line => line.trim() && !line.startsWith('D\t'))
114 .map(line => line.split('\t')[1])
115 .filter(f => f);
116 return {
117 files,
118 mode: 'since-last-commit'
119 };
120 } catch (error) {
121 // Fallback to staged files if no previous commit
122 const stagedFiles = await git.diff(['--staged', '--name-status']);
123 const files = stagedFiles.split('\n')
124 .filter(line => line.trim() && !line.startsWith('D\t'))
125 .map(line => line.split('\t')[1])
126 .filter(f => f);
127 return {
128 files,
129 mode: 'staged-fallback'
130 };
131 }

Callers 1

runChecksFunction · 0.85

Calls 1

errorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…