Skip to content

Commit 170725b

Browse files
authored
Add documentation for new git history limiting configuration (#764)
1 parent 9e28b00 commit 170725b

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

docs/automation-actions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ automations:
500500

501501
For more information about the `codeExperts` filter function, see the [filter functions documentation](https://docs.gitstream.cm/filter-functions/#codeexperts).
502502

503+
!!! tip "Limit git history for code experts"
504+
505+
Use the [`config.git_history_since`](./cm-file.md#configgit_history_since) configuration to limit the git history analysis to commits after a specific date. This is useful for team transitions or when you want to focus on recent contributors only.
506+
503507
#### `merge` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
504508

505509
Once triggered, merge the PR if possible. It can be set to wait for all checks to pass or only required ones.

docs/cm-file.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,13 @@ The manifest version field is used to parse the `.cm` file, in the future if bre
171171

172172
The `config` section in the `.cm` file is optional and specifies settings that affect gitStream's operation within a given context.
173173

174-
| Key | Type | Default | Scope | Description |
175-
| --------------------- | ---------------- | ------- | -------------- | ----------------------------------------------------------------------------------- |
176-
| `config` | Map | - | per `.cm` file | Root configuration section, applies to the automations defined in the current file. |
177-
| `config.admin.users` | [String] | `[]` | `gitstream.cm` | List of admin users, identified by Git provider usernames. |
178-
| `config.ignore_files` | [String] | `[]` | per `.cm` file | Files to exclude from consideration. |
179-
| `config.user_mapping` | [String: String] | `[]` | per `.cm` file | Map Git user details to provider account names. |
174+
| Key | Type | Default | Scope | Description |
175+
| ------------------------ | ---------------- | ------- | -------------- | ----------------------------------------------------------------------------------- |
176+
| `config` | Map | - | per `.cm` file | Root configuration section, applies to the automations defined in the current file. |
177+
| `config.admin.users` | [String] | `[]` | `gitstream.cm` | List of admin users, identified by Git provider usernames. |
178+
| `config.git_history_since` | String | - | per `.cm` file | Limit git history analysis to commits after the specified date (YYYY-MM-DD). |
179+
| `config.ignore_files` | [String] | `[]` | per `.cm` file | Files to exclude from consideration. |
180+
| `config.user_mapping` | [String: String] | `[]` | per `.cm` file | Map Git user details to provider account names. |
180181

181182
##### `config.admin.users`
182183

@@ -247,6 +248,46 @@ On the other hand, when using `explainRankByGitBlame` with `add-comment@v1` it s
247248
1. `rankByGitBlame` will drop `null` users
248249
2. `explainRankByGitBlame` will NOT drop `null` users
249250

251+
##### `config.git_history_since`
252+
253+
The `config.git_history_since` configuration limits how far back gitStream looks in git history when analyzing code expertise and git blame results. This affects filters and actions that rely on git history analysis, including:
254+
255+
- `codeExperts` filter
256+
- `rankByGitBlame` filter
257+
- `explainRankByGitBlame` filter
258+
- `explain-code-experts` action
259+
260+
When `git_history_since` is configured, gitStream will only consider commits made on or after the specified date when determining code experts and calculating git blame rankings. This is particularly useful for:
261+
262+
- **Team transitions**: When a project changes hands between teams, you can set the date to when the new team took over to ensure only current team members are suggested as reviewers
263+
- **Performance optimization**: Large repositories with extensive history can benefit from limiting the analysis scope
264+
- **Relevant expertise**: Focus on recent contributions rather than legacy code changes
265+
266+
The value should be specified as a date in `YYYY-MM-DD` format.
267+
268+
```yaml title="example"
269+
config:
270+
git_history_since: '2025-01-01' # Only consider commits from January 1, 2025 onwards
271+
```
272+
273+
**Example use case**: If your team took over a project on January 1, 2025, and you want to ensure that only current team members are suggested as code experts:
274+
275+
```yaml title=".cm/gitstream.cm"
276+
config:
277+
git_history_since: '2025-01-01'
278+
279+
automations:
280+
assign_code_experts:
281+
if:
282+
- {{ files | codeExperts(gt=10) | length > 0 }}
283+
run:
284+
- action: add-reviewers@v1
285+
args:
286+
reviewers: {{ files | codeExperts(gt=10) }}
287+
```
288+
289+
With this configuration, the `codeExperts` filter will only analyze git blame data from commits made on or after January 1, 2025, effectively filtering out previous team members from reviewer suggestions.
290+
250291
#### `triggers`
251292

252293
The `triggers` is section specifies when automations are executed, supporting `include` and `exclude` lists for branch and repository patterns at the file level. The `on` keyword can also be used within individual automations to define specific events that trigger those automations.

docs/filter-functions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@ automations:
415415
reviewers: {{ repo | codeExperts(gt=10) }}
416416
```
417417

418+
!!! tip "Limit git history for code experts"
419+
420+
Use the [`config.git_history_since`](./cm-file.md#configgit_history_since) configuration to limit the git history analysis to commits after a specific date. This is useful for team transitions or when you want to focus on recent contributors only.
421+
418422
#### `decode`
419423

420424
Decode Base64 encoded string into an object. Encoded strings are formatted: `"base64: <encoded_string>"`

0 commit comments

Comments
 (0)