feat: respect .gitignore in tree sidebar - #5136
Open
rkristelijn wants to merge 4 commits into
Open
Conversation
- Add pre-flight check in postinstall.ts for libx11-dev, libxkbfile-dev, libsecret-1-dev, pkg-config on Linux (dpkg-based distros) - Clear error message with exact apt-get command on failure - Add Makefile for dev workflow shortcuts (deps, install, dev, build)
- Add gitignore.ts helper that parses .gitignore at the opened folder root - Integrate with chokidar watcher's ignored callback - Uses the 'ignore' npm package for correct gitignore pattern matching - .git directory is always excluded when .gitignore is present - Additive to existing treePathExcludePatterns preference
Resolve rootPath and validate that the constructed .gitignore path stays within the root directory. Addresses SonarQube blocker: 'Change this code to not construct the path from user-controlled data.'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5135
Summary
When opening a folder that contains a
.gitignore, the tree sidebar now respects those patterns and hides ignored files/directories (e.g..git/, build artifacts,.amazonq/, etc.).Changes
packages/desktop/src/main/filesystem/gitignore.ts: Helper that loads and parses.gitignoreusing theignorepackage (spec-compliant gitignore matching including negation, nested patterns, etc.)packages/desktop/src/main/filesystem/watcher.ts: Integrates the gitignore filter into chokidar'signoredcallback, applied after existingtreePathExcludePatternspackages/desktop/package.json: Addedignore@7.0.4dependencyBehavior
.gitignoreexists at the opened folder root → patterns are applied.gitignoreexists → no change in behavior.git/is always excluded when a.gitignoreis presenttreePathExcludePatternspreference (both filters apply)Testing
pnpm typecheck)