Skip to content

Commit 89b1e95

Browse files
author
roeil
committed
docs: add paths filter to configuration docs
1 parent 66ac29e commit 89b1e95

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/input/docs/reference/mdsource/configuration.source.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,44 @@ Date and time in the format `yyyy-MM-ddTHH:mm:ss` (eg `commits-before:
225225
2015-10-23T12:23:15`) to setup an exclusion range. Effectively any commit before
226226
`commits-before` will be ignored.
227227

228+
#### paths
229+
A sequence of regular expressions that represent paths in the repository. Commits that modify these paths will be excluded from version calculations. For example, to filter out commits that belong to `docs`:
230+
```yaml
231+
ignore:
232+
paths:
233+
- ^docs\/
234+
```
235+
##### *Monorepo*
236+
This ignore config can be used to filter only those commits that belong to a specific project in a monorepo.
237+
As an example, consider a monorepo consisting of subdirectories for `ProjectA`, `ProjectB` and a shared `LibraryC`. For GitVersion to consider only commits that are part of `projectA` and shared library `LibraryC`, a regex that matches all paths except those starting with `ProjectA` or `LibraryC` can be used. Either one of the following configs would filter out `ProjectB`.
238+
* Specific match on `/ProjectB/*`:
239+
```yaml
240+
ignore:
241+
paths:
242+
- `^\/ProductB\/.*`
243+
```
244+
* Negative lookahead on anything other than `/ProjectA/*` and `/LibraryC/*`:
245+
```yaml
246+
ignore:
247+
paths:
248+
- `^(?!\/ProductA\/|\/LibraryC\/).*`
249+
```
250+
A commit having changes only in `/ProjectB/*` path would be ignored. A commit having changes in the following paths wouldn't be ignored:
251+
* `/ProductA/*`
252+
* `/LibraryC/*`
253+
* `/ProductA/*` and `/LibraryC/*`
254+
* `/ProductA/*` and `/ProductB/*`
255+
* `/LibraryC/*` and `/ProductB/*`
256+
* `/ProductA/*` and `/ProductB/*` and `/LibraryC/*`
257+
258+
:::
259+
Note: The `ignore.paths` configuration is case-sensitive. This can lead to unexpected behavior on case-insensitive file systems, such as Windows. To ensure consistent matching regardless of case, you can prefix your regular expressions with the case-insensitive flag `(?i)`. For example, `(?i)^docs\/` will match both `docs/` and `Docs/`.
260+
:::
261+
262+
::: {.alert .alert-warning}
263+
A commit is ignored by the `ignore.paths` configuration only if **all paths** changed in that commit match one or more of the specified regular expressions. If a path in a commit does not match any one of the ignore patterns, that commit will be included in version calculations.
264+
:::
265+
228266
### merge-message-formats
229267

230268
Custom merge message formats to enable identification of merge messages that do not

0 commit comments

Comments
 (0)