Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Conversation

@0xnmn
Copy link
Contributor

@0xnmn 0xnmn commented Jul 31, 2025

Re-implementing PR: https://github.com/sourcegraph/cody/pull/8037

This introduces the ability to exclude files from Cody's context based on the files.exclude, search.exclude, and .gitignore / .sourcegraph/.ignore .cody/ignore files located in the codebase root directory settings in VS Code.

The ContextFiltersProvider now utilizes these settings to determine if a file should be ignored. This is achieved by:

  • Adding minimatch as a dependency to perform pattern matching.
  • Introducing a static excludePatternGetter to fetch the exclude patterns and workspace folder.
  • Implementing isExcludedByPatterns to check if a file path matches any of the exclude patterns.
  • Adding ContextFiltersProviderError.ExcludePatternMatch to indicate when a file is excluded by the patterns.

This enhancement ensures that Cody respects the user's VS Code settings for excluding files, preventing irrelevant files from being included in the context.

Note: .sourcegraph/.ignore instead of .codyignore so that the same file can be used across sourcegraph products and not just cody

Test plan

  • Try to open a file that is listed in the .gitignore / .sourcegraph/.ignore file at the root of the repo
  • Confirm you can see the file being ignored tooltip when hovered over the cody icon at the bottom menu bar
image

@0xnmn 0xnmn force-pushed the naman/ignore-cody branch from ba66ff1 to 5035e3c Compare July 31, 2025 17:49
@0xnmn 0xnmn force-pushed the naman/ignore-cody branch from 5035e3c to 2fc9def Compare July 31, 2025 17:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants