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 0dc39a2

Browse files
authored
Merge pull request #517 from Kurt-von-Laven/pre-commit-hook
feat(pre-commit): Add commitizen-branch hook
2 parents d33f5fc + bd4aa6f commit 0dc39a2

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

‎.pre-commit-config.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ repos:
1515
rev: v2.31.0 # automatically updated by Commitizen
1616
hooks:
1717
- id: commitizen
18-
stages: [commit-msg]
1918

2019
- repo: local
2120
hooks:

‎.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: 12 additions & 3 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,14 +111,23 @@ repos:
111111
rev: master
112112
hooks:
113113
- id: commitizen
114+
- id: commitizen-branch
115+
stages: [push]
114116
```
115117
116-
After the configuration is added, you'll need to run
118+
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

124+
If you aren't using both hooks, you needn't install both stages.
125+
126+
| Hook | Recommended Stage |
127+
| ----------------- | ----------------- |
128+
| commitizen | commit-msg |
129+
| commitizen-branch | pre-push |
130+
122131
Read more about the `check` command [here](check.md).
123132

124133
### Help

0 commit comments

Comments
(0)

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