Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01ce73b

Browse files
feat(pre-commit): Add commitizen-branch hook
Check all commit messages on the current branch. This is useful for checking commit messages after the fact (e.g., pre-push or in CI) since the existing hook only works at commit time. Expand the documentation of the pre-existing commitizen hook to clarify the relationship between them.
1 parent 02ab1bf commit 01ce73b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

‎.pre-commit-hooks.yaml‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
- id: commitizen
22
name: commitizen check
3-
description: "Check whether the commit message follows commiting rules"
3+
description: >
4+
Check whether the current commit message follows commiting rules. Allow
5+
empty commit messages by default, because they typically indicate to Git
6+
that the commit should be aborted.
47
entry: cz check
58
args: [--allow-abort, --commit-msg-file]
69
stages: [commit-msg]
710
language: python
811
language_version: python3
912
minimum_pre_commit_version: "1.4.3"
13+
14+
- id: commitizen-branch
15+
name: commitizen check branch
16+
description: >
17+
Check all commit messages that are already on the current branch but not the
18+
default branch on the origin repository. Useful for checking messages after
19+
the fact (e.g., pre-push or in CI) without an expensive check of the entire
20+
repository history.
21+
entry: cz check
22+
args: [--rev-range, origin/HEAD..HEAD]
23+
always_run: true
24+
pass_filenames: false
25+
language: python
26+
language_version: python3
27+
minimum_pre_commit_version: "1.4.3"

‎docs/README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ cz commit -s
101101
```
102102

103103
### Integrating with Pre-commit
104-
Commitizen can lint your commit message for you with `cz check`.
104+
Commitizen can lint your commit messages for you with `cz check`.
105105
You can integrate this in your [pre-commit](https://pre-commit.com/) config with:
106106

107107
```yaml
@@ -111,12 +111,14 @@ repos:
111111
rev: master
112112
hooks:
113113
- id: commitizen
114+
- id: commitizen-branch
115+
stages: [push]
114116
```
115117
116118
After the configuration is added, you'll need to run
117119
118120
```sh
119-
pre-commit install --hook-type commit-msg
121+
pre-commit install --hook-type commit-msg pre-push
120122
```
121123

122124
Read more about the `check` command [here](check.md).

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /