-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: harden git stats parsing #904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 issues found across 3 files
Confidence score: 3/5
- Some risk due to concrete parsing issues in
src/shared/git-stats.tsthat can misclassify tracked/untracked files and report incorrect stats when paths contain spaces or special characters. - Test flakiness risk:
src/shared/git-stats.test.tsuses a shared mutable repo path, so concurrent runs or leftovers can cause intermittent failures. - Pay close attention to
src/shared/git-stats.ts,src/shared/git-stats.test.ts- path parsing correctness and test isolation.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/shared/git-stats.test.ts">
<violation number="1" location="src/shared/git-stats.test.ts:8">
P2: Tests share a mutable git repo at a fixed path, so failures or concurrent runs can leave/modify state and cause flakiness</violation>
</file>
<file name="src/shared/git-stats.ts">
<violation number="1" location="src/shared/git-stats.ts:78">
P2: Untracked file paths from `git status --porcelain` are used without unquoting, so quoted/escaped paths (spaces/special chars) fail to read and report wrong stats/path.</violation>
<violation number="2" location="src/shared/git-stats.ts:112">
P2: Tracked file paths are parsed with a leading space, so staged adds/deletes are misclassified when matching against git diff output.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/shared/git-stats.ts">
<violation number="1" location="src/shared/git-stats.ts:122">
P2: Status map keys are unquoted but numstat paths stay quoted, so files with tabs/newlines/backslashes are misclassified as modified instead of added/deleted.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| // For untracked files: path at index 3 | ||
| const pathStart = trimmed.startsWith("??") ? 3 : 2 | ||
| const rawPath = trimmed.substring(pathStart) | ||
| const path = parsePorcelainPath(rawPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Status map keys are unquoted but numstat paths stay quoted, so files with tabs/newlines/backslashes are misclassified as modified instead of added/deleted.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/shared/git-stats.ts, line 122:
<comment>Status map keys are unquoted but numstat paths stay quoted, so files with tabs/newlines/backslashes are misclassified as modified instead of added/deleted.</comment>
<file context>
@@ -110,7 +118,8 @@ export function getGitDiffStats(directory: string): GitFileStat[] {
const pathStart = trimmed.startsWith("??") ? 3 : 2
- const path = trimmed.substring(pathStart)
+ const rawPath = trimmed.substring(pathStart)
+ const path = parsePorcelainPath(rawPath)
const status = parseFileStatus(line)
statusMap.set(path, status)
</file context>
Summary
Summary by cubic
Hardened git stats parsing to include untracked files and avoid failures when git diff or HEAD is unavailable. Added a formatting helper and tests to keep file change summaries reliable.
Bug Fixes
New Features
Written for commit 0845588. Summary will update on new commits.