Skip to content

Commit a908c17

Browse files
fix(init): truncate uncommitted file list to first 5 entries (#381)
## Summary - Truncates the uncommitted/untracked file list in the `init` git safety check to show only the first 5 files - Appends a summary line (e.g. `+ 12 more uncommitted files`) when there are more than 5 - Prevents terminal flooding in repos with many dirty files while still communicating the situation clearly ## Changes **`src/lib/init/git.ts`** — In `checkGitStatus`, instead of joining all files into the warning message, slice to `MAX_DISPLAYED_FILES` (5) and append a remainder count if truncated. Both the `--yes` auto-proceed and interactive prompt paths benefit from this.
1 parent 6d389c5 commit a908c17

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib/init/git.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
import { confirm, isCancel, log } from "@clack/prompts";
99

10+
/** Maximum number of uncommitted files to display before truncating. */
11+
const MAX_DISPLAYED_FILES = 5;
12+
1013
export function isInsideGitWorkTree(opts: { cwd: string }): boolean {
1114
const result = Bun.spawnSync(["git", "rev-parse", "--is-inside-work-tree"], {
1215
stdout: "ignore",
@@ -64,7 +67,12 @@ export async function checkGitStatus(opts: {
6467

6568
const uncommitted = getUncommittedOrUntrackedFiles({ cwd });
6669
if (uncommitted.length > 0) {
67-
const fileList = uncommitted.join("\n");
70+
const displayed = uncommitted.slice(0, MAX_DISPLAYED_FILES);
71+
const remaining = uncommitted.length - displayed.length;
72+
if (remaining > 0) {
73+
displayed.push(` + ${remaining} more uncommitted files`);
74+
}
75+
const fileList = displayed.join("\n");
6876
if (yes) {
6977
log.warn(
7078
`You have uncommitted or untracked files:\n${fileList}\nProceeding anyway (--yes).`

0 commit comments

Comments
 (0)