Description
In \src/core/git.ts:98-102:
\\ s
export async function getStaleBranches(days: number, cwd?: string): Promise<GitBranch[]> {
const branches = await getLocalBranches(cwd)
const cutoff = new Date()
cutoff.setDate(cutoff.getDate() - days)
return branches.filter((b) => b.lastCommitDate < cutoff)
}
\\
The function accepts \days: number\ but does not validate it.
Impact
- NaN: \cutoff.getDate() - NaN\ produces \NaN, and \setDate(NaN)\ creates an Invalid Date. All \Date < InvalidDate\ comparisons return \alse, so no branches are ever stale.
- Negative values: The cutoff is in the future, so no branches are ever stale.
- Zero: Every branch is immediately considered stale, potentially causing mass deletion.
Suggested Fix
Validate that \days\ is a positive integer (\days > 0 && Number.isFinite(days)) and throw or return an error for invalid input.
Description
In \src/core/git.ts:98-102:
\\ s
export async function getStaleBranches(days: number, cwd?: string): Promise<GitBranch[]> {
const branches = await getLocalBranches(cwd)
const cutoff = new Date()
cutoff.setDate(cutoff.getDate() - days)
return branches.filter((b) => b.lastCommitDate < cutoff)
}
\\
The function accepts \days: number\ but does not validate it.
Impact
Suggested Fix
Validate that \days\ is a positive integer (\days > 0 && Number.isFinite(days)) and throw or return an error for invalid input.