fix: filter gitignored files from sandbox commit and modified-file detection#154
fix: filter gitignored files from sandbox commit and modified-file detection#154it-baron wants to merge 1 commit intomichaelshimeles:mainfrom
Conversation
…tection Agents running in sandboxes would stage and commit OS/build artifacts (.DS_Store, node_modules, dist, __pycache__, .tsbuildinfo) causing noisy diffs and failed commits. This change: - sandbox.ts: adds ALWAYS_SKIP_NAMES/ALWAYS_SKIP_EXTENSIONS sets and shouldSkipEntry() to pre-filter commonly gitignored entries in getModifiedFiles() at any directory depth - sandbox-git.ts: runs git check-ignore on modified files before staging and gracefully handles the case when all files are ignored - Adds comprehensive tests for both modules
|
@it-baron is attempting to deploy a commit to the Goshen Labs Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR implements a two-layer filtering system to prevent OS metadata files ( Key changes:
Issues found:
Confidence Score: 4/5
Important Files Changed
Flowchartflowchart TD
A[Agent modifies files in sandbox] --> B[getModifiedFiles called]
B --> C{Check file/dir name}
C -->|In ALWAYS_SKIP_NAMES| D[Skip - Layer 1 filter]
C -->|Has ALWAYS_SKIP_EXTENSIONS| D
C -->|Not in skip list| E[Add to modifiedFiles list]
E --> F[commitSandboxChanges called]
F --> G{modifiedFiles.length > 0?}
G -->|No| H[Return success with empty branch]
G -->|Yes| I[Create new branch]
I --> J[Copy files from sandbox to original]
J --> K[Run git check-ignore on files]
K --> L{Any files ignored?}
L -->|Yes| M[Filter out ignored files - Layer 2]
L -->|No| N[Keep all files]
M --> O{filesToStage.length > 0?}
N --> O
O -->|No| P[Return success with empty branch]
O -->|Yes| Q[Stage filesToStage]
Q --> R[Create commit]
R --> S[Return to original branch]
Last reviewed commit: 6646bc3 |
Additional Comments (2)
Prompt To Fix With AIThis is a comment left during a code review.
Path: cli/src/execution/sandbox-git.ts
Line: 139:139
Comment:
logs `modifiedFiles.length` but actually staging only `filesToStage.length` files
```suggestion
logDebug(`Agent ${agentNum}: Committed ${filesToStage.length} files to ${branchName}`);
```
How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix With AIThis is a comment left during a code review.
Path: cli/src/execution/sandbox-git.ts
Line: 147:147
Comment:
returns `modifiedFiles.length` but should return `filesToStage.length` since some files may have been filtered out
```suggestion
filesCommitted: filesToStage.length,
```
How can I resolve this? If you propose a fix, please make it concise. |
Summary
.DS_Store,node_modules,dist,__pycache__,.tsbuildinfo,Thumbs.db) from being staged and committed by sandbox agentsgetModifiedFiles()+git check-ignorevalidation before staging incommitSandboxChanges()sandbox.tsandsandbox-git.tsProblem
When agents run inside sandboxes,
getModifiedFiles()would report OS metadata files (.DS_Store) and build artifacts (node_modules/,dist/,__pycache__/,*.tsbuildinfo) as modified. These would then be staged and committed bycommitSandboxChanges(), producing noisy diffs and sometimes causing commit failures when.gitignorerules rejected them at staging time.Solution
Layer 1 - Static pre-filter (
sandbox.ts)Added
ALWAYS_SKIP_NAMESandALWAYS_SKIP_EXTENSIONSsets with ashouldSkipEntry()helper.getModifiedFiles()now skips these entries at any directory depth during its recursive walk, avoiding unnecessary file-system comparisons entirely.Layer 2 - Git-aware filter (
sandbox-git.ts)Before calling
git add,commitSandboxChanges()now runsgit check-ignoreon the modified file list and removes any files the repo's.gitignorewould reject. If all files are ignored, it returns early with{ success: true, branchName: "", filesCommitted: 0 }instead of creating an empty commit.Changes
cli/src/execution/sandbox.tsALWAYS_SKIP_NAMES,ALWAYS_SKIP_EXTENSIONS,shouldSkipEntry(), and integrated intogetModifiedFiles()cli/src/execution/sandbox-git.tsgit check-ignorefiltering and early-return when all files are ignoredcli/src/execution/sandbox.test.tscli/src/execution/sandbox-git.test.tsTest plan
getModifiedFiles()skip-list behavior (.DS_Store,node_modules,dist,__pycache__,.tsbuildinfo,Thumbs.dbat root and nested levels)commitSandboxChanges()gitignore filtering (mixed valid/ignored files, all-ignored early return, nested directories).DS_Storefiles and verify they are excluded from the commitcc @michaelshimeles