You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/reference/filters.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -183,7 +183,8 @@ parents.
183
183
### Commit message rewriting **`:"template"`** or **`:"template";"regex"`**
184
184
185
185
Rewrite commit messages using a template string. The template can use regex capture groups
186
-
to extract and reformat parts of the original commit message.
186
+
to extract and reformat parts of the original commit message, as well as special template variables
187
+
for commit metadata.
187
188
188
189
**Simple message replacement:**
189
190
```
@@ -200,6 +201,27 @@ which are then used in the template. The regex `(?s)^(?P<type>fix|feat|docs): (?
200
201
commit messages starting with "fix:", "feat:", or "docs:" followed by a message, and the template
201
202
reformats them as `[type] message`.
202
203
204
+
**Using template variables:**
205
+
The template supports special variables that provide access to commit metadata:
206
+
-`{#}` - The tree object ID (SHA-1 hash) of the commit
207
+
-`{@}` - The commit object ID (SHA-1 hash)
208
+
-`{/path}` - The content of the file at the specified path in the commit tree
209
+
-`{#path}` - The object ID (SHA-1 hash) of the tree entry at the specified path
210
+
211
+
Regex capture groups take priority over template variables. If a regex capture group has the same name as a template variable, the capture group value will be used.
212
+
213
+
Example:
214
+
```
215
+
:"Message: {#} {@}"
216
+
```
217
+
This replaces commit messages with "Message: " followed by the tree ID and commit ID.
218
+
219
+
**Combining regex capture groups and template variables:**
0 commit comments