mcp(developer): add fallback on .gitignore if no .gooseignore is present (#2661)

This commit is contained in:
Raduan Al-Shedivat
2025-06-03 22:12:40 +02:00
committed by GitHub
parent 3a22d6b452
commit d1dc6c3ff0
2 changed files with 229 additions and 2 deletions

View File

@@ -23,6 +23,24 @@ Goose supports two types of `.gooseignore` files:
You can use both global and local `.gooseignore` files simultaneously. When both exist, Goose will combine the restrictions from both files to determine which paths are restricted.
:::
## Automatic `.gitignore` fallback
If no `.gooseignore` file is found in your current directory, Goose will automatically use your `.gitignore` file as a fallback. This means:
1. **Priority Order**: Goose checks for ignore patterns in this order:
- Global `.gooseignore` (if exists)
- Local `.gooseignore` (if exists)
- Local `.gitignore` (if no local `.gooseignore` and `.gitignore` exists)
- Default patterns (if none of the above exist)
2. **Seamless Integration**: Projects with existing `.gitignore` files get automatic protection without needing a separate `.gooseignore` file.
3. **Override Capability**: Creating a local `.gooseignore` file will completely override `.gitignore` patterns for that directory.
:::info Debug logging
When Goose uses `.gitignore` as a fallback, it will log a message to help you understand which ignore file is being used.
:::
## Example `.gooseignore` file
In your `.gooseignore` file, you can write patterns to match files you want Goose to ignore. Here are some common patterns:
@@ -49,7 +67,7 @@ downloads/ # Ignore everything in the "downloads" directory
## Default patterns
By default, if you haven't created any `.gooseignore` files, Goose will not modify files matching these patterns:
By default, if you haven't created any `.gooseignore` files **and no `.gitignore` file exists**, Goose will not modify files matching these patterns:
```plaintext
**/.env
@@ -57,6 +75,8 @@ By default, if you haven't created any `.gooseignore` files, Goose will not modi
**/secrets.*
```
These default patterns only apply when neither `.gooseignore` nor `.gitignore` files are found in your project.
## Common use cases
Here are some typical scenarios where `.gooseignore` is helpful:
@@ -65,4 +85,6 @@ Here are some typical scenarios where `.gooseignore` is helpful:
- **Third-Party Code**: Keep Goose from changing external libraries or dependencies
- **Important Configurations**: Protect critical configuration files from accidental modifications
- **Version Control**: Prevent changes to version control files like `.git` directory
- **Existing Projects**: Most projects already have `.gitignore` files that work automatically as ignore patterns for Goose
- **Custom Restrictions**: Create `.gooseignore` when you need different patterns than your `.gitignore` (e.g., allowing Goose to read files that Git ignores)