Skip to content

Commit 02d5669

Browse files
author
jinzhongjia
committed
docs(readme): document file filtering with glob patterns
- add exclude_files option to configuration examples - describe file filtering support in feature lists - provide usage examples and glob pattern details - update documentation to explain use cases and configuration
1 parent 28f05d8 commit 02d5669

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A CodeCompanion extension that generates AI-powered git commit messages followin
1212
- ⌨️ Smart keymap integration for gitcommit buffers
1313
- 🌍 Multi-language support for commit messages
1414
- 🔄 Support for both regular commits and `git commit --amend`
15+
- 📁 File filtering support with glob patterns to exclude files from diff analysis
1516

1617
## Installation
1718

@@ -29,6 +30,7 @@ require("codecompanion").setup({
2930
adapter = "openai", -- Optional: specify LLM adapter (defaults to codecompanion chat adapter)
3031
model = "gpt-4", -- Optional: specify model (defaults to codecompanion chat model)
3132
languages = { "English", "简体中文", "日本語", "Français", "Español" }, -- Optional: list of languages for commit messages
33+
exclude_files = { "*.pb.go", "*.min.js", "package-lock.json" }, -- Optional: exclude files from diff analysis
3234
buffer = {
3335
enabled = true, -- Enable gitcommit buffer keymaps
3436
keymap = "<leader>gc", -- Keymap for generating commit message in gitcommit buffer
@@ -113,6 +115,7 @@ Handles all git-related operations:
113115

114116
- Repository detection with filesystem and git command fallback
115117
- Staged changes retrieval and contextual diff generation
118+
- File filtering support with glob patterns to exclude files from analysis
116119
- Support for both regular commits and `git commit --amend`
117120
- Commit execution with proper error handling
118121

@@ -216,6 +219,7 @@ opts = {
216219
adapter = "openai", -- LLM adapter to use (default: codecompanion chat adapter)
217220
model = "gpt-4", -- Model to use (default: codecompanion chat model)
218221
languages = { "English", "简体中文", "日本語", "Français", "Español" }, -- Languages for commit messages
222+
exclude_files = { "*.pb.go", "*.min.js", "package-lock.json" }, -- File patterns to exclude from diff analysis
219223
buffer = {
220224
enabled = true, -- Enable gitcommit buffer keymaps (default: true)
221225
keymap = "<leader>gc", -- Keymap for generating commit message (default: "<leader>gc")
@@ -238,10 +242,28 @@ The specific model to use with the adapter. If not specified, defaults to the mo
238242
A list of languages that can be used for generating commit messages. When specified, the extension will prompt you to select a language before generating the commit message. If not provided or empty, commit messages will be generated in English by default.
239243

240244
Example:
245+
241246
```lua
242247
languages = { "English", "简体中文", "日本語", "Français", "Español" }
243248
```
244249

250+
#### `exclude_files` (table, optional)
251+
A list of file patterns to exclude from git diff analysis when generating commit messages. Supports glob patterns using `*` and `?` wildcards. This is useful for excluding generated files, minified files, or large files that don't need AI analysis.
252+
253+
Examples:
254+
255+
```lua
256+
exclude_files = {
257+
"*.pb.go", -- Protocol buffer generated files
258+
"*.min.js", -- Minified JavaScript files
259+
"package-lock.json", -- NPM lock file
260+
"yarn.lock", -- Yarn lock file
261+
"*.generated.ts", -- Generated TypeScript files
262+
"dist/*", -- Distribution directory
263+
"build/*" -- Build directory
264+
}
265+
```
266+
245267
#### `buffer.enabled` (boolean, default: `true`)
246268
Controls whether gitcommit buffer keymap integration is enabled.
247269

doc/codecompanion-gitcommit.txt

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ analyze your staged changes and create appropriate commit messages.
3838
• Smart keymap integration for gitcommit buffers
3939
• Multi-language support for commit messages
4040
• Support for both regular commits and `git commit --amend`
41+
• File filtering support with glob patterns to exclude files from analysis
4142

4243
==============================================================================
4344
3. INSTALLATION *codecompanion-gitcommit-install*
@@ -53,6 +54,7 @@ Add this extension to your CodeCompanion configuration:
5354
adapter = "openai", -- Optional: specify LLM adapter (defaults to codecompanion chat adapter)
5455
model = "gpt-4", -- Optional: specify model (defaults to codecompanion chat model)
5556
languages = { "English", "Chinese", "Japanese" }, -- Optional: list of languages for commit messages
57+
exclude_files = { "*.pb.go", "*.min.js", "package-lock.json" }, -- Optional: exclude files from diff analysis
5658
buffer = {
5759
enabled = true, -- Enable gitcommit buffer keymaps
5860
keymap = "<leader>gc", -- Keymap for generating commit message
@@ -72,6 +74,7 @@ opts = {
7274
adapter = "openai", -- LLM adapter to use (optional)
7375
model = "gpt-4", -- Model to use (optional)
7476
languages = { "English", "简体中文", "日本語" }, -- Languages for commit messages (optional)
77+
exclude_files = { "*.pb.go", "*.min.js", "package-lock.json" }, -- File patterns to exclude from diff analysis (optional)
7578
buffer = {
7679
enabled = true, -- Enable gitcommit buffer keymaps
7780
keymap = "<leader>gc", -- Keymap for generating commit message
@@ -109,6 +112,18 @@ languages *gitcommit-languages*
109112

110113
Example: { "English", "简体中文", "日本語", "Français" }
111114

115+
exclude_files *gitcommit-exclude-files*
116+
Type: table
117+
Default: {} (no files excluded)
118+
A list of file patterns to exclude from git diff analysis when
119+
generating commit messages. Supports glob patterns using `*` and `?`
120+
wildcards. This is useful for excluding generated files, minified
121+
files, or large files that don't need AI analysis.
122+
123+
Examples:
124+
{ "*.pb.go", "*.min.js", "package-lock.json", "yarn.lock" }
125+
{ "dist/*", "build/*", "*.generated.ts" }
126+
112127
buffer.enabled *gitcommit-buffer-enabled*
113128
Type: boolean
114129
Default: true
@@ -200,6 +215,39 @@ the following keymaps are available:
200215
`q` or `<Esc>` *gitcommit-keymap-q*
201216
Close the floating window without taking any action.
202217

218+
5.6 File Filtering *codecompanion-gitcommit-filtering*
219+
220+
The extension supports filtering files from diff analysis using glob
221+
patterns. This is useful to exclude files that don't contribute meaningful
222+
information to commit message generation:
223+
224+
Common Use Cases:~
225+
• Generated files (protobuf, generated code)
226+
• Minified files (*.min.js, *.min.css)
227+
• Lock files (package-lock.json, yarn.lock)
228+
• Build artifacts (dist/, build/)
229+
• Binary files or large data files
230+
231+
Example configuration:~
232+
>
233+
exclude_files = {
234+
"*.pb.go", -- Protocol buffer files
235+
"*.min.js", -- Minified JavaScript
236+
"*.min.css", -- Minified CSS
237+
"package-lock.json", -- NPM lock file
238+
"yarn.lock", -- Yarn lock file
239+
"dist/*", -- Distribution directory
240+
"build/*", -- Build directory
241+
"*.generated.*", -- Any generated files
242+
}
243+
<
244+
245+
Glob Pattern Support:~
246+
`*` - Matches any sequence of characters
247+
`?` - Matches any single character
248+
`dir/*` - Matches all files in directory
249+
`*.ext` - Matches all files with extension
250+
203251
==============================================================================
204252
6. COMMANDS *codecompanion-gitcommit-commands*
205253

@@ -293,8 +341,9 @@ Module Overview:~
293341

294342
git.lua~
295343
Handles all git-related operations including repository detection,
296-
staged changes retrieval, commit execution, and `git commit --amend`
297-
support. Includes contextual diff analysis and error handling.
344+
staged changes retrieval, file filtering with glob patterns,
345+
commit execution, and `git commit --amend` support. Includes
346+
contextual diff analysis and error handling.
298347

299348
generator.lua~
300349
Manages LLM interaction including prompt creation for commit message

0 commit comments

Comments
 (0)