commitfmt-windows 0.0.2a1__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- commitfmt_windows-0.1.1/PKG-INFO +246 -0
- commitfmt_windows-0.1.1/README.md +227 -0
- commitfmt_windows-0.1.1/commitfmt_windows.egg-info/PKG-INFO +246 -0
- {commitfmt_windows-0.0.2a1 → commitfmt_windows-0.1.1}/pyproject.toml +1 -1
- commitfmt_windows-0.0.2a1/PKG-INFO +0 -20
- commitfmt_windows-0.0.2a1/README.md +0 -1
- commitfmt_windows-0.0.2a1/commitfmt_windows.egg-info/PKG-INFO +0 -20
- {commitfmt_windows-0.0.2a1 → commitfmt_windows-0.1.1}/commitfmt_windows/__init__.py +0 -0
- {commitfmt_windows-0.0.2a1 → commitfmt_windows-0.1.1}/commitfmt_windows.egg-info/SOURCES.txt +0 -0
- {commitfmt_windows-0.0.2a1 → commitfmt_windows-0.1.1}/commitfmt_windows.egg-info/dependency_links.txt +0 -0
- {commitfmt_windows-0.0.2a1 → commitfmt_windows-0.1.1}/commitfmt_windows.egg-info/top_level.txt +0 -0
- {commitfmt_windows-0.0.2a1 → commitfmt_windows-0.1.1}/setup.cfg +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: commitfmt_windows
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Utility for formatting and verifying the commit message.
|
|
5
|
+
Author-email: Mikhael Khrustik <misha@myrt.co>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: git,hook
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<img width="350" src="./docs/assets/logo.svg" alt="commitfmt logo" />
|
|
22
|
+
<br />
|
|
23
|
+
<br />
|
|
24
|
+
Utility for formatting and verifying commit messages.
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<a href="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml">
|
|
31
|
+
<img src="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml/badge.svg" alt="Quality Assurance" />
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://npmjs.com/package/commitfmt">
|
|
34
|
+
<img src="https://img.shields.io/npm/v/commitfmt.svg?color=red" alt="NPM Version" />
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://pypi.org/project/commitfmt/">
|
|
37
|
+
<img src="https://img.shields.io/pypi/v/commitfmt.svg?color=blue" alt="PyPI Version" />
|
|
38
|
+
</a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
It's not a linter. At least not a complete replacement for [commitlint](https://commitlint.js.org), because commitfmt can't prevent you from writing a body or force you to write a description in uppercase (I don't know why you might want to do that), but it will help keep git history clean and readable.
|
|
42
|
+
|
|
43
|
+
By design, commitfmt runs on the `prepare-commit-msg` hook and formats the message according to git standards and [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) in particular.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
### Formatting
|
|
48
|
+
|
|
49
|
+
commitfmt by default transforms a message like this:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
feat ( scope , scope ) : add new feature.
|
|
53
|
+
body description
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
into well-formatted message:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
feat(scope, scope): add new feature
|
|
60
|
+
|
|
61
|
+
body description
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Linting
|
|
65
|
+
|
|
66
|
+
commitfmt can check that developers follow the rules set by the project.
|
|
67
|
+
|
|
68
|
+
For example, check that only allowed types and scopes are used. To do this, add the following to the <nobr>[configuration file](#configuration)</nobr>:
|
|
69
|
+
|
|
70
|
+
```toml
|
|
71
|
+
[lint.header]
|
|
72
|
+
# Check allowed commit type
|
|
73
|
+
type-enum = ["chore", "ci", "feat", "fix", "refactor", "style", "test"]
|
|
74
|
+
# Check allowed commit scopes
|
|
75
|
+
scope-enum = ["cc", "config", "git", "linter"]
|
|
76
|
+
|
|
77
|
+
[lint.footer]
|
|
78
|
+
# Check required footers
|
|
79
|
+
exists = ["Issue-ID", "Authored-By"]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Performance
|
|
83
|
+
|
|
84
|
+
commitfmt is very fast because its code is written in Rust with memory consumption and performance in mind.
|
|
85
|
+
|
|
86
|
+
It natively supports following platforms:
|
|
87
|
+
|
|
88
|
+
| OS | Architecture |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| macOS | x86_64, arm64 |
|
|
91
|
+
| Windows | x86_64, i686 |
|
|
92
|
+
| Linux | x86_64, i686, arm64 |
|
|
93
|
+
|
|
94
|
+
## Installation
|
|
95
|
+
|
|
96
|
+
### Script
|
|
97
|
+
|
|
98
|
+
You can use a simple [script](https://github.com/mishamyrt/commitfmt/blob/refs/heads/main/scripts/install.sh) to install commitfmt.
|
|
99
|
+
It will download the latest version of the binary and install it to the system.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Install latest version
|
|
103
|
+
curl -sSfL https://raw.githubusercontent.com/mishamyrt/commitfmt/refs/heads/main/scripts/install.sh | bash
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### pnpm
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pnpm add --save-dev commitfmt
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### npm
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm install --save-dev commitfmt
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### yarn
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
yarn add --dev commitfmt
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### pip
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pip install commitfmt
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Hook
|
|
131
|
+
|
|
132
|
+
After installing the package, you need to add a hook to the `prepare-commit-msg` event. You can use any hook manager.
|
|
133
|
+
|
|
134
|
+
> **Important:** if you are using a pnpm, yarn or any other package manager, you need to run `pnpm commitfmt`, `yarn commitfmt`, etc. instead of `commitfmt`.
|
|
135
|
+
|
|
136
|
+
### Script
|
|
137
|
+
|
|
138
|
+
You can use a simple script to add a hook.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
echo "#!/bin/sh" > .git/hooks/prepare-commit-msg
|
|
142
|
+
echo "commitfmt" >> .git/hooks/prepare-commit-msg
|
|
143
|
+
chmod +x .git/hooks/prepare-commit-msg
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### [Lefthook](https://github.com/evilmartians/lefthook)
|
|
147
|
+
|
|
148
|
+
Add to your `lefthook.yml` file:
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
prepare-commit-msg:
|
|
152
|
+
- name: format commit message
|
|
153
|
+
run: commitfmt
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### [Husky](https://github.com/typicode/husky)
|
|
157
|
+
|
|
158
|
+
Add to your `.husky` folder `prepare-commit-msg` file with the following content:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
#!/bin/sh
|
|
162
|
+
commitfmt
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Configuration
|
|
166
|
+
|
|
167
|
+
In commitfmt, you cannot customize basic formatting rules such as extra spaces removal.
|
|
168
|
+
|
|
169
|
+
It is an opinionated formatter and the author has established best practices that should not harm anyone.
|
|
170
|
+
|
|
171
|
+
### Linting
|
|
172
|
+
|
|
173
|
+
Most of the linting rules are disabled by default. Default config contains 3 rules as they can be safely auto-fixed:
|
|
174
|
+
|
|
175
|
+
```toml
|
|
176
|
+
[lint.header]
|
|
177
|
+
full-stop = true
|
|
178
|
+
|
|
179
|
+
[lint.body]
|
|
180
|
+
new-line = true
|
|
181
|
+
|
|
182
|
+
[lint.footer]
|
|
183
|
+
breaking-exclamation = true
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
To enable more rules, create a `commitfmt.toml` or (`.commitfmt.toml`) file in the root of your project. Available lint rules can be found in the [rules.md](https://github.com/mishamyrt/commitfmt/blob/main/crates/commitfmt_linter/docs/rules.md) file.
|
|
187
|
+
|
|
188
|
+
If there is a problem with an enabled rule and it cannot be automatically fixed, the commit process will be aborted.
|
|
189
|
+
|
|
190
|
+
#### Unsafe fixes
|
|
191
|
+
|
|
192
|
+
Some rules may be fixed, but in certain contexts this fix may not be what is desired. For example, adding a full stop to the end of body will be useful in most cases, if there is a log at the end of the message, the period may distort it. You can see which rules have unsafe patches in the same `rules.md` file mentioned above.
|
|
193
|
+
|
|
194
|
+
To enable unsafe fixes, add the following to your config file:
|
|
195
|
+
|
|
196
|
+
```toml
|
|
197
|
+
[lint]
|
|
198
|
+
unsafe-fixes = true
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Additional footers
|
|
202
|
+
|
|
203
|
+
commitfmt can add additional footers to the commit message.
|
|
204
|
+
|
|
205
|
+
#### Value template
|
|
206
|
+
|
|
207
|
+
You can use a template to format the value of the footer. Inside of template expression you can use any shell command available at the `PATH`.
|
|
208
|
+
|
|
209
|
+
For example, to add the `Authored-By` footer with the current user name, add the following to your config file:
|
|
210
|
+
|
|
211
|
+
```toml
|
|
212
|
+
[additional-footers]
|
|
213
|
+
key = "Authored-By"
|
|
214
|
+
value-template = "{{ echo $USER }}"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### Branch value pattern
|
|
218
|
+
|
|
219
|
+
You can also add the ticket number from the task tracker to the footer if it is in the branch name:
|
|
220
|
+
|
|
221
|
+
```toml
|
|
222
|
+
[additional-footers]
|
|
223
|
+
key = "Ticket-ID"
|
|
224
|
+
branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
For example, if your branch name is `feature/CC-123/add-new-feature` or `feature/CC-123`, the `Ticket-ID` footer will be added to the commit message with the value `CC-123`.
|
|
228
|
+
|
|
229
|
+
If the ticket number is not found in the branch name, footer will be skipped.
|
|
230
|
+
|
|
231
|
+
#### On conflict
|
|
232
|
+
|
|
233
|
+
If the footer already exists in the commit message, you can specify what to do with it. By default, the footer will be skipped.
|
|
234
|
+
|
|
235
|
+
```toml
|
|
236
|
+
[additional-footers]
|
|
237
|
+
key = "Ticket-ID"
|
|
238
|
+
branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
|
|
239
|
+
on-conflict = "skip" # skip, append, error
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Available options:
|
|
243
|
+
|
|
244
|
+
- `skip` - skip the footer if it already exists
|
|
245
|
+
- `append` - append the footer to the end of the footer list
|
|
246
|
+
- `error` - abort the commit
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="350" src="./docs/assets/logo.svg" alt="commitfmt logo" />
|
|
3
|
+
<br />
|
|
4
|
+
<br />
|
|
5
|
+
Utility for formatting and verifying commit messages.
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml">
|
|
12
|
+
<img src="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml/badge.svg" alt="Quality Assurance" />
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://npmjs.com/package/commitfmt">
|
|
15
|
+
<img src="https://img.shields.io/npm/v/commitfmt.svg?color=red" alt="NPM Version" />
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://pypi.org/project/commitfmt/">
|
|
18
|
+
<img src="https://img.shields.io/pypi/v/commitfmt.svg?color=blue" alt="PyPI Version" />
|
|
19
|
+
</a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
It's not a linter. At least not a complete replacement for [commitlint](https://commitlint.js.org), because commitfmt can't prevent you from writing a body or force you to write a description in uppercase (I don't know why you might want to do that), but it will help keep git history clean and readable.
|
|
23
|
+
|
|
24
|
+
By design, commitfmt runs on the `prepare-commit-msg` hook and formats the message according to git standards and [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) in particular.
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
### Formatting
|
|
29
|
+
|
|
30
|
+
commitfmt by default transforms a message like this:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
feat ( scope , scope ) : add new feature.
|
|
34
|
+
body description
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
into well-formatted message:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
feat(scope, scope): add new feature
|
|
41
|
+
|
|
42
|
+
body description
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Linting
|
|
46
|
+
|
|
47
|
+
commitfmt can check that developers follow the rules set by the project.
|
|
48
|
+
|
|
49
|
+
For example, check that only allowed types and scopes are used. To do this, add the following to the <nobr>[configuration file](#configuration)</nobr>:
|
|
50
|
+
|
|
51
|
+
```toml
|
|
52
|
+
[lint.header]
|
|
53
|
+
# Check allowed commit type
|
|
54
|
+
type-enum = ["chore", "ci", "feat", "fix", "refactor", "style", "test"]
|
|
55
|
+
# Check allowed commit scopes
|
|
56
|
+
scope-enum = ["cc", "config", "git", "linter"]
|
|
57
|
+
|
|
58
|
+
[lint.footer]
|
|
59
|
+
# Check required footers
|
|
60
|
+
exists = ["Issue-ID", "Authored-By"]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Performance
|
|
64
|
+
|
|
65
|
+
commitfmt is very fast because its code is written in Rust with memory consumption and performance in mind.
|
|
66
|
+
|
|
67
|
+
It natively supports following platforms:
|
|
68
|
+
|
|
69
|
+
| OS | Architecture |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| macOS | x86_64, arm64 |
|
|
72
|
+
| Windows | x86_64, i686 |
|
|
73
|
+
| Linux | x86_64, i686, arm64 |
|
|
74
|
+
|
|
75
|
+
## Installation
|
|
76
|
+
|
|
77
|
+
### Script
|
|
78
|
+
|
|
79
|
+
You can use a simple [script](https://github.com/mishamyrt/commitfmt/blob/refs/heads/main/scripts/install.sh) to install commitfmt.
|
|
80
|
+
It will download the latest version of the binary and install it to the system.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Install latest version
|
|
84
|
+
curl -sSfL https://raw.githubusercontent.com/mishamyrt/commitfmt/refs/heads/main/scripts/install.sh | bash
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### pnpm
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pnpm add --save-dev commitfmt
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### npm
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm install --save-dev commitfmt
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### yarn
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
yarn add --dev commitfmt
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### pip
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install commitfmt
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Hook
|
|
112
|
+
|
|
113
|
+
After installing the package, you need to add a hook to the `prepare-commit-msg` event. You can use any hook manager.
|
|
114
|
+
|
|
115
|
+
> **Important:** if you are using a pnpm, yarn or any other package manager, you need to run `pnpm commitfmt`, `yarn commitfmt`, etc. instead of `commitfmt`.
|
|
116
|
+
|
|
117
|
+
### Script
|
|
118
|
+
|
|
119
|
+
You can use a simple script to add a hook.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
echo "#!/bin/sh" > .git/hooks/prepare-commit-msg
|
|
123
|
+
echo "commitfmt" >> .git/hooks/prepare-commit-msg
|
|
124
|
+
chmod +x .git/hooks/prepare-commit-msg
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### [Lefthook](https://github.com/evilmartians/lefthook)
|
|
128
|
+
|
|
129
|
+
Add to your `lefthook.yml` file:
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
prepare-commit-msg:
|
|
133
|
+
- name: format commit message
|
|
134
|
+
run: commitfmt
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### [Husky](https://github.com/typicode/husky)
|
|
138
|
+
|
|
139
|
+
Add to your `.husky` folder `prepare-commit-msg` file with the following content:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
#!/bin/sh
|
|
143
|
+
commitfmt
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Configuration
|
|
147
|
+
|
|
148
|
+
In commitfmt, you cannot customize basic formatting rules such as extra spaces removal.
|
|
149
|
+
|
|
150
|
+
It is an opinionated formatter and the author has established best practices that should not harm anyone.
|
|
151
|
+
|
|
152
|
+
### Linting
|
|
153
|
+
|
|
154
|
+
Most of the linting rules are disabled by default. Default config contains 3 rules as they can be safely auto-fixed:
|
|
155
|
+
|
|
156
|
+
```toml
|
|
157
|
+
[lint.header]
|
|
158
|
+
full-stop = true
|
|
159
|
+
|
|
160
|
+
[lint.body]
|
|
161
|
+
new-line = true
|
|
162
|
+
|
|
163
|
+
[lint.footer]
|
|
164
|
+
breaking-exclamation = true
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
To enable more rules, create a `commitfmt.toml` or (`.commitfmt.toml`) file in the root of your project. Available lint rules can be found in the [rules.md](https://github.com/mishamyrt/commitfmt/blob/main/crates/commitfmt_linter/docs/rules.md) file.
|
|
168
|
+
|
|
169
|
+
If there is a problem with an enabled rule and it cannot be automatically fixed, the commit process will be aborted.
|
|
170
|
+
|
|
171
|
+
#### Unsafe fixes
|
|
172
|
+
|
|
173
|
+
Some rules may be fixed, but in certain contexts this fix may not be what is desired. For example, adding a full stop to the end of body will be useful in most cases, if there is a log at the end of the message, the period may distort it. You can see which rules have unsafe patches in the same `rules.md` file mentioned above.
|
|
174
|
+
|
|
175
|
+
To enable unsafe fixes, add the following to your config file:
|
|
176
|
+
|
|
177
|
+
```toml
|
|
178
|
+
[lint]
|
|
179
|
+
unsafe-fixes = true
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Additional footers
|
|
183
|
+
|
|
184
|
+
commitfmt can add additional footers to the commit message.
|
|
185
|
+
|
|
186
|
+
#### Value template
|
|
187
|
+
|
|
188
|
+
You can use a template to format the value of the footer. Inside of template expression you can use any shell command available at the `PATH`.
|
|
189
|
+
|
|
190
|
+
For example, to add the `Authored-By` footer with the current user name, add the following to your config file:
|
|
191
|
+
|
|
192
|
+
```toml
|
|
193
|
+
[additional-footers]
|
|
194
|
+
key = "Authored-By"
|
|
195
|
+
value-template = "{{ echo $USER }}"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### Branch value pattern
|
|
199
|
+
|
|
200
|
+
You can also add the ticket number from the task tracker to the footer if it is in the branch name:
|
|
201
|
+
|
|
202
|
+
```toml
|
|
203
|
+
[additional-footers]
|
|
204
|
+
key = "Ticket-ID"
|
|
205
|
+
branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
For example, if your branch name is `feature/CC-123/add-new-feature` or `feature/CC-123`, the `Ticket-ID` footer will be added to the commit message with the value `CC-123`.
|
|
209
|
+
|
|
210
|
+
If the ticket number is not found in the branch name, footer will be skipped.
|
|
211
|
+
|
|
212
|
+
#### On conflict
|
|
213
|
+
|
|
214
|
+
If the footer already exists in the commit message, you can specify what to do with it. By default, the footer will be skipped.
|
|
215
|
+
|
|
216
|
+
```toml
|
|
217
|
+
[additional-footers]
|
|
218
|
+
key = "Ticket-ID"
|
|
219
|
+
branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
|
|
220
|
+
on-conflict = "skip" # skip, append, error
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Available options:
|
|
224
|
+
|
|
225
|
+
- `skip` - skip the footer if it already exists
|
|
226
|
+
- `append` - append the footer to the end of the footer list
|
|
227
|
+
- `error` - abort the commit
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: commitfmt_windows
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Utility for formatting and verifying the commit message.
|
|
5
|
+
Author-email: Mikhael Khrustik <misha@myrt.co>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: git,hook
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<img width="350" src="./docs/assets/logo.svg" alt="commitfmt logo" />
|
|
22
|
+
<br />
|
|
23
|
+
<br />
|
|
24
|
+
Utility for formatting and verifying commit messages.
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<a href="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml">
|
|
31
|
+
<img src="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml/badge.svg" alt="Quality Assurance" />
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://npmjs.com/package/commitfmt">
|
|
34
|
+
<img src="https://img.shields.io/npm/v/commitfmt.svg?color=red" alt="NPM Version" />
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://pypi.org/project/commitfmt/">
|
|
37
|
+
<img src="https://img.shields.io/pypi/v/commitfmt.svg?color=blue" alt="PyPI Version" />
|
|
38
|
+
</a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
It's not a linter. At least not a complete replacement for [commitlint](https://commitlint.js.org), because commitfmt can't prevent you from writing a body or force you to write a description in uppercase (I don't know why you might want to do that), but it will help keep git history clean and readable.
|
|
42
|
+
|
|
43
|
+
By design, commitfmt runs on the `prepare-commit-msg` hook and formats the message according to git standards and [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) in particular.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
### Formatting
|
|
48
|
+
|
|
49
|
+
commitfmt by default transforms a message like this:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
feat ( scope , scope ) : add new feature.
|
|
53
|
+
body description
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
into well-formatted message:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
feat(scope, scope): add new feature
|
|
60
|
+
|
|
61
|
+
body description
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Linting
|
|
65
|
+
|
|
66
|
+
commitfmt can check that developers follow the rules set by the project.
|
|
67
|
+
|
|
68
|
+
For example, check that only allowed types and scopes are used. To do this, add the following to the <nobr>[configuration file](#configuration)</nobr>:
|
|
69
|
+
|
|
70
|
+
```toml
|
|
71
|
+
[lint.header]
|
|
72
|
+
# Check allowed commit type
|
|
73
|
+
type-enum = ["chore", "ci", "feat", "fix", "refactor", "style", "test"]
|
|
74
|
+
# Check allowed commit scopes
|
|
75
|
+
scope-enum = ["cc", "config", "git", "linter"]
|
|
76
|
+
|
|
77
|
+
[lint.footer]
|
|
78
|
+
# Check required footers
|
|
79
|
+
exists = ["Issue-ID", "Authored-By"]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Performance
|
|
83
|
+
|
|
84
|
+
commitfmt is very fast because its code is written in Rust with memory consumption and performance in mind.
|
|
85
|
+
|
|
86
|
+
It natively supports following platforms:
|
|
87
|
+
|
|
88
|
+
| OS | Architecture |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| macOS | x86_64, arm64 |
|
|
91
|
+
| Windows | x86_64, i686 |
|
|
92
|
+
| Linux | x86_64, i686, arm64 |
|
|
93
|
+
|
|
94
|
+
## Installation
|
|
95
|
+
|
|
96
|
+
### Script
|
|
97
|
+
|
|
98
|
+
You can use a simple [script](https://github.com/mishamyrt/commitfmt/blob/refs/heads/main/scripts/install.sh) to install commitfmt.
|
|
99
|
+
It will download the latest version of the binary and install it to the system.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Install latest version
|
|
103
|
+
curl -sSfL https://raw.githubusercontent.com/mishamyrt/commitfmt/refs/heads/main/scripts/install.sh | bash
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### pnpm
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pnpm add --save-dev commitfmt
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### npm
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm install --save-dev commitfmt
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### yarn
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
yarn add --dev commitfmt
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### pip
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pip install commitfmt
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Hook
|
|
131
|
+
|
|
132
|
+
After installing the package, you need to add a hook to the `prepare-commit-msg` event. You can use any hook manager.
|
|
133
|
+
|
|
134
|
+
> **Important:** if you are using a pnpm, yarn or any other package manager, you need to run `pnpm commitfmt`, `yarn commitfmt`, etc. instead of `commitfmt`.
|
|
135
|
+
|
|
136
|
+
### Script
|
|
137
|
+
|
|
138
|
+
You can use a simple script to add a hook.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
echo "#!/bin/sh" > .git/hooks/prepare-commit-msg
|
|
142
|
+
echo "commitfmt" >> .git/hooks/prepare-commit-msg
|
|
143
|
+
chmod +x .git/hooks/prepare-commit-msg
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### [Lefthook](https://github.com/evilmartians/lefthook)
|
|
147
|
+
|
|
148
|
+
Add to your `lefthook.yml` file:
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
prepare-commit-msg:
|
|
152
|
+
- name: format commit message
|
|
153
|
+
run: commitfmt
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### [Husky](https://github.com/typicode/husky)
|
|
157
|
+
|
|
158
|
+
Add to your `.husky` folder `prepare-commit-msg` file with the following content:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
#!/bin/sh
|
|
162
|
+
commitfmt
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Configuration
|
|
166
|
+
|
|
167
|
+
In commitfmt, you cannot customize basic formatting rules such as extra spaces removal.
|
|
168
|
+
|
|
169
|
+
It is an opinionated formatter and the author has established best practices that should not harm anyone.
|
|
170
|
+
|
|
171
|
+
### Linting
|
|
172
|
+
|
|
173
|
+
Most of the linting rules are disabled by default. Default config contains 3 rules as they can be safely auto-fixed:
|
|
174
|
+
|
|
175
|
+
```toml
|
|
176
|
+
[lint.header]
|
|
177
|
+
full-stop = true
|
|
178
|
+
|
|
179
|
+
[lint.body]
|
|
180
|
+
new-line = true
|
|
181
|
+
|
|
182
|
+
[lint.footer]
|
|
183
|
+
breaking-exclamation = true
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
To enable more rules, create a `commitfmt.toml` or (`.commitfmt.toml`) file in the root of your project. Available lint rules can be found in the [rules.md](https://github.com/mishamyrt/commitfmt/blob/main/crates/commitfmt_linter/docs/rules.md) file.
|
|
187
|
+
|
|
188
|
+
If there is a problem with an enabled rule and it cannot be automatically fixed, the commit process will be aborted.
|
|
189
|
+
|
|
190
|
+
#### Unsafe fixes
|
|
191
|
+
|
|
192
|
+
Some rules may be fixed, but in certain contexts this fix may not be what is desired. For example, adding a full stop to the end of body will be useful in most cases, if there is a log at the end of the message, the period may distort it. You can see which rules have unsafe patches in the same `rules.md` file mentioned above.
|
|
193
|
+
|
|
194
|
+
To enable unsafe fixes, add the following to your config file:
|
|
195
|
+
|
|
196
|
+
```toml
|
|
197
|
+
[lint]
|
|
198
|
+
unsafe-fixes = true
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Additional footers
|
|
202
|
+
|
|
203
|
+
commitfmt can add additional footers to the commit message.
|
|
204
|
+
|
|
205
|
+
#### Value template
|
|
206
|
+
|
|
207
|
+
You can use a template to format the value of the footer. Inside of template expression you can use any shell command available at the `PATH`.
|
|
208
|
+
|
|
209
|
+
For example, to add the `Authored-By` footer with the current user name, add the following to your config file:
|
|
210
|
+
|
|
211
|
+
```toml
|
|
212
|
+
[additional-footers]
|
|
213
|
+
key = "Authored-By"
|
|
214
|
+
value-template = "{{ echo $USER }}"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### Branch value pattern
|
|
218
|
+
|
|
219
|
+
You can also add the ticket number from the task tracker to the footer if it is in the branch name:
|
|
220
|
+
|
|
221
|
+
```toml
|
|
222
|
+
[additional-footers]
|
|
223
|
+
key = "Ticket-ID"
|
|
224
|
+
branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
For example, if your branch name is `feature/CC-123/add-new-feature` or `feature/CC-123`, the `Ticket-ID` footer will be added to the commit message with the value `CC-123`.
|
|
228
|
+
|
|
229
|
+
If the ticket number is not found in the branch name, footer will be skipped.
|
|
230
|
+
|
|
231
|
+
#### On conflict
|
|
232
|
+
|
|
233
|
+
If the footer already exists in the commit message, you can specify what to do with it. By default, the footer will be skipped.
|
|
234
|
+
|
|
235
|
+
```toml
|
|
236
|
+
[additional-footers]
|
|
237
|
+
key = "Ticket-ID"
|
|
238
|
+
branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
|
|
239
|
+
on-conflict = "skip" # skip, append, error
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Available options:
|
|
243
|
+
|
|
244
|
+
- `skip` - skip the footer if it already exists
|
|
245
|
+
- `append` - append the footer to the end of the footer list
|
|
246
|
+
- `error` - abort the commit
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: commitfmt_windows
|
|
3
|
-
Version: 0.0.2a1
|
|
4
|
-
Summary: Utility for formatting and verifying the commit message.
|
|
5
|
-
Author-email: Mikhael Khrustik <misha@myrt.co>
|
|
6
|
-
License: MIT
|
|
7
|
-
Keywords: git,hook
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
-
Classifier: Intended Audience :: Developers
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
-
Requires-Python: >=3.9
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
|
|
20
|
-
# commitfmt python wrapper
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# commitfmt python wrapper
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: commitfmt_windows
|
|
3
|
-
Version: 0.0.2a1
|
|
4
|
-
Summary: Utility for formatting and verifying the commit message.
|
|
5
|
-
Author-email: Mikhael Khrustik <misha@myrt.co>
|
|
6
|
-
License: MIT
|
|
7
|
-
Keywords: git,hook
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
-
Classifier: Intended Audience :: Developers
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
-
Requires-Python: >=3.9
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
|
|
20
|
-
# commitfmt python wrapper
|
|
File without changes
|
{commitfmt_windows-0.0.2a1 → commitfmt_windows-0.1.1}/commitfmt_windows.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{commitfmt_windows-0.0.2a1 → commitfmt_windows-0.1.1}/commitfmt_windows.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|