(cwd, relativePath)
| 194 | } |
| 195 | |
| 196 | function formatUntrackedFile(cwd, relativePath) { |
| 197 | const absolutePath = path.join(cwd, relativePath); |
| 198 | let stat; |
| 199 | try { |
| 200 | stat = fs.statSync(absolutePath); |
| 201 | } catch { |
| 202 | return `### ${relativePath}\n(skipped: broken symlink or unreadable file)`; |
| 203 | } |
| 204 | if (stat.isDirectory()) { |
| 205 | return `### ${relativePath}\n(skipped: directory)`; |
| 206 | } |
| 207 | if (stat.size > MAX_UNTRACKED_BYTES) { |
| 208 | return `### ${relativePath}\n(skipped: ${stat.size} bytes exceeds ${MAX_UNTRACKED_BYTES} byte limit)`; |
| 209 | } |
| 210 | |
| 211 | let buffer; |
| 212 | try { |
| 213 | buffer = fs.readFileSync(absolutePath); |
| 214 | } catch { |
| 215 | return `### ${relativePath}\n(skipped: broken symlink or unreadable file)`; |
| 216 | } |
| 217 | if (!isProbablyText(buffer)) { |
| 218 | return `### ${relativePath}\n(skipped: binary file)`; |
| 219 | } |
| 220 | |
| 221 | return [`### ${relativePath}`, "```", buffer.toString("utf8").trimEnd(), "```"].join("\n"); |
| 222 | } |
| 223 | |
| 224 | function collectWorkingTreeContext(cwd, state, options = {}) { |
| 225 | const includeDiff = options.includeDiff !== false; |
no test coverage detected