perf(git): optimize git status for large monorepos#1613
perf(git): optimize git status for large monorepos#1613arnestrickmann merged 2 commits intogeneralaction:mainfrom
Conversation
|
@kchung is attempting to deploy a commit to the General Action Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRefactors GitService.getStatus to run Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant GitService
participant GitCLI
Client->>GitService: getStatus(taskPath)
GitService->>GitCLI: git status --porcelain=v2 -z --no-ahead-behind --no-optional-locks
GitService->>GitCLI: git diff --numstat --cached --no-optional-locks
GitService->>GitCLI: git diff --numstat --no-optional-locks
Note right of GitCLI: Commands run concurrently
GitCLI-->>GitService: statusOutput, stagedNumstat, unstagedNumstat
GitService->>GitService: if statusOutput.trim() === '' -> return []
GitService->>GitService: parse statusOutput -> entries
GitService->>GitService: build staged/unstaged maps from numstat
GitService-->>Client: entries (with staged/unstaged info)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Run status and numstat commands in parallel instead of sequentially. Add --no-optional-locks to avoid blocking on concurrent git processes, --no-ahead-behind to skip commit-graph walks, and --untracked-files=normal to avoid recursive enumeration of untracked directories.
b2f6a58 to
98076ea
Compare
|
@kchung proper review soon! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/services/GitService.ts`:
- Around line 171-183: The git status flag `--untracked-files=normal` returns
directory entries which breaks file-only logic in functions like
countFileNewlinesCapped and deleteUntracked; update both execFileAsync calls
that pass '--untracked-files=normal' (the two occurrences shown near the
execFileAsync invocations using MAX_DIFF_OUTPUT_BYTES) to use
'--untracked-files=all' instead so untracked directories are expanded into
individual file paths that the rest of GitService.ts can handle; ensure both
fallback and primary git calls are changed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3bc84f9d-fede-4124-bfec-f72de417f856
📒 Files selected for processing (1)
src/main/services/GitService.ts
Ensures individual file paths are returned instead of directory entries, which downstream file-level operations depend on.
|
Thanks @arnestrickmann! I'll connect with you in a bit! |
|
Cool! Looking forward to connect and also jam on Emdash improvements / wishes you might have for future releases. @kchung |
|
Thanks again, for the contribution! @kchung |
Summary
Optimizes
GitService.getStatus()for large monorepos by running git commands in parallel and adding flags to reduce unnecessary work:git statusand bothgit diff --numstatcommands now run concurrently viaPromise.allinstead of sequentially--no-optional-locks: Preventsgit statusfrom blocking when a concurrentgit fetchholds the index lock--no-ahead-behind: Skips commit-graph traversal for branch tracking info we don't use--untracked-files=normal: Shows untracked directories as single entries instead of recursively enumerating every file within themFixes
N/A
Snapshot
Testing steps in the video:
cmd + r)This test uses the exact same repo with the exact same changes, one running the latest Emdash dist and one running this PR. This is running on an Apple M4 Max 64GB
Before
before.mov
After
after.mov
Type of change
Mandatory Tasks
Checklist
pnpm run format)pnpm run lint)Summary by CodeRabbit
Performance Improvements
Compatibility
Reliability