commitfmt 0.1.2rc3__tar.gz → 0.2.0__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.
@@ -0,0 +1,294 @@
1
+ Metadata-Version: 2.4
2
+ Name: commitfmt
3
+ Version: 0.2.0
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
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: commitfmt_windows==0.1.5; sys_platform == "win32"
19
+ Requires-Dist: commitfmt_openbsd==0.1.5; sys_platform == "openbsd"
20
+ Requires-Dist: commitfmt_freebsd==0.1.5; sys_platform == "freebsd"
21
+ Requires-Dist: commitfmt_darwin==0.1.5; sys_platform == "darwin"
22
+ Requires-Dist: commitfmt_linux==0.1.5; sys_platform == "linux"
23
+
24
+ <p align="center">
25
+ <img width="350" src="./docs/assets/logo.svg" alt="commitfmt logo" />
26
+ <br />
27
+ <br />
28
+ Utility for formatting and verifying commit messages.
29
+ </p>
30
+
31
+ ---
32
+
33
+ <p align="center">
34
+ <a href="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml">
35
+ <img src="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml/badge.svg" alt="Quality Assurance" />
36
+ </a>
37
+ <a href="https://npmjs.com/package/commitfmt">
38
+ <img src="https://img.shields.io/npm/v/commitfmt.svg?color=red" alt="NPM Version" />
39
+ </a>
40
+ <a href="https://pypi.org/project/commitfmt/">
41
+ <img src="https://img.shields.io/pypi/v/commitfmt.svg?color=blue" alt="PyPI Version" />
42
+ </a>
43
+ </p>
44
+
45
+ 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.
46
+
47
+ 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.
48
+
49
+ ## Features
50
+
51
+ ### Formatting
52
+
53
+ commitfmt by default transforms a message like this:
54
+
55
+ ```
56
+ feat ( scope , scope ) : add new feature.
57
+ body description
58
+ ```
59
+
60
+ into well-formatted message:
61
+
62
+ ```
63
+ feat(scope, scope): add new feature
64
+
65
+ body description
66
+ ```
67
+
68
+ ### Linting
69
+
70
+ commitfmt can check that developers follow the rules set by the project.
71
+
72
+ For example, check that only allowed types and scopes are used. To do this, add the following to the <nobr>[configuration file](#configuration)</nobr>:
73
+
74
+ ```toml
75
+ [lint.header]
76
+ # Check allowed commit type
77
+ type-enum = ["chore", "ci", "feat", "fix", "refactor", "style", "test"]
78
+ # Check allowed commit scopes
79
+ scope-enum = ["cc", "config", "git", "linter"]
80
+
81
+ [lint.footer]
82
+ # Check required footers
83
+ exists = ["Issue-ID", "Authored-By"]
84
+ ```
85
+
86
+ ### Performance
87
+
88
+ commitfmt is very fast because its code is written in Rust with memory consumption and performance in mind.
89
+
90
+ It natively supports following platforms:
91
+
92
+ | OS | Architecture |
93
+ | --- | --- |
94
+ | macOS | x86_64, arm64 |
95
+ | Windows | x86_64, i686 |
96
+ | Linux | x86_64, i686, arm64 |
97
+
98
+ ## Installation
99
+
100
+ ### Script
101
+
102
+ You can use a simple [script](https://github.com/mishamyrt/commitfmt/blob/refs/heads/main/scripts/install.sh) to install commitfmt.
103
+ It will download the latest version of the binary and install it to the system.
104
+
105
+ ```bash
106
+ # Install latest version
107
+ curl -sSfL https://raw.githubusercontent.com/mishamyrt/commitfmt/refs/heads/main/scripts/install.sh | bash
108
+ ```
109
+
110
+ ### pnpm
111
+
112
+ ```bash
113
+ pnpm add --save-dev commitfmt
114
+ ```
115
+
116
+ ### npm
117
+
118
+ ```bash
119
+ npm install --save-dev commitfmt
120
+ ```
121
+
122
+ ### yarn
123
+
124
+ ```bash
125
+ yarn add --dev commitfmt
126
+ ```
127
+
128
+ ### pip
129
+
130
+ ```bash
131
+ pip install commitfmt
132
+ ```
133
+
134
+ ## Hook
135
+
136
+ After installing the package, you need to add a hook to the `prepare-commit-msg` event. You can use any hook manager.
137
+
138
+ > **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`.
139
+
140
+ ### Script
141
+
142
+ You can use a simple script to add a hook.
143
+
144
+ ```bash
145
+ echo "#!/bin/sh" > .git/hooks/prepare-commit-msg
146
+ echo "commitfmt" >> .git/hooks/prepare-commit-msg
147
+ chmod +x .git/hooks/prepare-commit-msg
148
+ ```
149
+
150
+ ### [Lefthook](https://github.com/evilmartians/lefthook)
151
+
152
+ Add to your `lefthook.yml` file:
153
+
154
+ ```yaml
155
+ prepare-commit-msg:
156
+ - name: format commit message
157
+ run: commitfmt
158
+ ```
159
+
160
+ ### [Husky](https://github.com/typicode/husky)
161
+
162
+ Add to your `.husky` folder `prepare-commit-msg` file with the following content:
163
+
164
+ ```bash
165
+ #!/bin/sh
166
+ commitfmt
167
+ ```
168
+
169
+ ## Configuration
170
+
171
+ In commitfmt, you cannot customize basic formatting rules such as extra spaces removal.
172
+
173
+ It is an opinionated formatter and the author has established best practices that should not harm anyone.
174
+
175
+ ### Linting
176
+
177
+ Most of the linting rules are disabled by default. Default config contains 3 rules as they can be safely auto-fixed:
178
+
179
+ ```toml
180
+ [lint.header]
181
+ full-stop = true
182
+
183
+ [lint.body]
184
+ new-line = true
185
+
186
+ [lint.footer]
187
+ breaking-exclamation = true
188
+ ```
189
+
190
+ 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.
191
+
192
+ If there is a problem with an enabled rule and it cannot be automatically fixed, the commit process will be aborted.
193
+
194
+ #### Unsafe fixes
195
+
196
+ 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.
197
+
198
+ To enable unsafe fixes, add the following to your config file:
199
+
200
+ ```toml
201
+ [lint]
202
+ unsafe-fixes = true
203
+ ```
204
+
205
+ ### Extending
206
+
207
+ You can extend the configuration of the parent project by adding the `extends` key to your config file:
208
+
209
+ ```toml
210
+ extends = "node_modules/commitfmt-config-standard/commitfmt.toml"
211
+ ```
212
+
213
+ Extension is only possible for the current configuration. If the current configuration extends another configuration, which in turn extends a third configuration, commitfmt will throw an error when trying to load such a configuration.
214
+
215
+ ### Additional footers
216
+
217
+ commitfmt can add additional footers to the commit message.
218
+
219
+ #### Value template
220
+
221
+ 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`.
222
+
223
+ For example, to add the `Authored-By` footer with the current user name, add the following to your config file:
224
+
225
+ ```toml
226
+ [additional-footers]
227
+ key = "Authored-By"
228
+ value-template = "{{ echo $USER }}"
229
+ ```
230
+
231
+ #### Branch value pattern
232
+
233
+ You can also add the ticket number from the task tracker to the footer if it is in the branch name:
234
+
235
+ ```toml
236
+ [additional-footers]
237
+ key = "Ticket-ID"
238
+ branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
239
+ ```
240
+
241
+ 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`.
242
+
243
+ If the ticket number is not found in the branch name, footer will be skipped.
244
+
245
+ You can use [rustexp](https://rustexp.lpil.uk) to test your pattern.
246
+
247
+ ##### Recipes
248
+
249
+ Examples of patterns for branch names in git flow format:
250
+
251
+ - Jira/YouTrack: `(?:.*)/([A-Z0-9-]+)/?(?:.*)`
252
+ - `feature/CFMT-123`
253
+ - `feature/CFMT-123/add-new-feature`
254
+ - GitHub: `(?:.*)/#?([0-9-]+)/?(?:.*)`
255
+ - `feature/#123`
256
+ - `feature/123`
257
+ - `feature/#123/add-new-feature`
258
+
259
+ #### On conflict
260
+
261
+ If the footer already exists in the commit message, you can specify what to do with it. By default, the footer will be skipped.
262
+
263
+ ```toml
264
+ [additional-footers]
265
+ key = "Ticket-ID"
266
+ branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
267
+ on-conflict = "skip" # skip, append, error
268
+ ```
269
+
270
+ Available options:
271
+
272
+ - `skip` - skip the footer if it already exists
273
+ - `append` - append the footer to the end of the footer list
274
+ - `error` - abort the commit
275
+
276
+ ## Testing
277
+
278
+ To test the configuration and the work of commitfmt, run the following command:
279
+
280
+ ```bash
281
+ echo "chore ( test ) : test commit" | commitfmt
282
+ # or
283
+ cat commit_text.txt | commitfmt
284
+ ```
285
+
286
+ ## History testing
287
+
288
+ To test the history of commits, run the following command:
289
+
290
+ ```bash
291
+ commitfmt --from HEAD~20
292
+ # or
293
+ commitfmt --from 1234567890 --to 1234567890
294
+ ```
@@ -0,0 +1,271 @@
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
+ ### Extending
183
+
184
+ You can extend the configuration of the parent project by adding the `extends` key to your config file:
185
+
186
+ ```toml
187
+ extends = "node_modules/commitfmt-config-standard/commitfmt.toml"
188
+ ```
189
+
190
+ Extension is only possible for the current configuration. If the current configuration extends another configuration, which in turn extends a third configuration, commitfmt will throw an error when trying to load such a configuration.
191
+
192
+ ### Additional footers
193
+
194
+ commitfmt can add additional footers to the commit message.
195
+
196
+ #### Value template
197
+
198
+ 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`.
199
+
200
+ For example, to add the `Authored-By` footer with the current user name, add the following to your config file:
201
+
202
+ ```toml
203
+ [additional-footers]
204
+ key = "Authored-By"
205
+ value-template = "{{ echo $USER }}"
206
+ ```
207
+
208
+ #### Branch value pattern
209
+
210
+ You can also add the ticket number from the task tracker to the footer if it is in the branch name:
211
+
212
+ ```toml
213
+ [additional-footers]
214
+ key = "Ticket-ID"
215
+ branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
216
+ ```
217
+
218
+ 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`.
219
+
220
+ If the ticket number is not found in the branch name, footer will be skipped.
221
+
222
+ You can use [rustexp](https://rustexp.lpil.uk) to test your pattern.
223
+
224
+ ##### Recipes
225
+
226
+ Examples of patterns for branch names in git flow format:
227
+
228
+ - Jira/YouTrack: `(?:.*)/([A-Z0-9-]+)/?(?:.*)`
229
+ - `feature/CFMT-123`
230
+ - `feature/CFMT-123/add-new-feature`
231
+ - GitHub: `(?:.*)/#?([0-9-]+)/?(?:.*)`
232
+ - `feature/#123`
233
+ - `feature/123`
234
+ - `feature/#123/add-new-feature`
235
+
236
+ #### On conflict
237
+
238
+ If the footer already exists in the commit message, you can specify what to do with it. By default, the footer will be skipped.
239
+
240
+ ```toml
241
+ [additional-footers]
242
+ key = "Ticket-ID"
243
+ branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
244
+ on-conflict = "skip" # skip, append, error
245
+ ```
246
+
247
+ Available options:
248
+
249
+ - `skip` - skip the footer if it already exists
250
+ - `append` - append the footer to the end of the footer list
251
+ - `error` - abort the commit
252
+
253
+ ## Testing
254
+
255
+ To test the configuration and the work of commitfmt, run the following command:
256
+
257
+ ```bash
258
+ echo "chore ( test ) : test commit" | commitfmt
259
+ # or
260
+ cat commit_text.txt | commitfmt
261
+ ```
262
+
263
+ ## History testing
264
+
265
+ To test the history of commits, run the following command:
266
+
267
+ ```bash
268
+ commitfmt --from HEAD~20
269
+ # or
270
+ commitfmt --from 1234567890 --to 1234567890
271
+ ```
@@ -0,0 +1,294 @@
1
+ Metadata-Version: 2.4
2
+ Name: commitfmt
3
+ Version: 0.2.0
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
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: commitfmt_windows==0.1.5; sys_platform == "win32"
19
+ Requires-Dist: commitfmt_openbsd==0.1.5; sys_platform == "openbsd"
20
+ Requires-Dist: commitfmt_freebsd==0.1.5; sys_platform == "freebsd"
21
+ Requires-Dist: commitfmt_darwin==0.1.5; sys_platform == "darwin"
22
+ Requires-Dist: commitfmt_linux==0.1.5; sys_platform == "linux"
23
+
24
+ <p align="center">
25
+ <img width="350" src="./docs/assets/logo.svg" alt="commitfmt logo" />
26
+ <br />
27
+ <br />
28
+ Utility for formatting and verifying commit messages.
29
+ </p>
30
+
31
+ ---
32
+
33
+ <p align="center">
34
+ <a href="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml">
35
+ <img src="https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml/badge.svg" alt="Quality Assurance" />
36
+ </a>
37
+ <a href="https://npmjs.com/package/commitfmt">
38
+ <img src="https://img.shields.io/npm/v/commitfmt.svg?color=red" alt="NPM Version" />
39
+ </a>
40
+ <a href="https://pypi.org/project/commitfmt/">
41
+ <img src="https://img.shields.io/pypi/v/commitfmt.svg?color=blue" alt="PyPI Version" />
42
+ </a>
43
+ </p>
44
+
45
+ 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.
46
+
47
+ 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.
48
+
49
+ ## Features
50
+
51
+ ### Formatting
52
+
53
+ commitfmt by default transforms a message like this:
54
+
55
+ ```
56
+ feat ( scope , scope ) : add new feature.
57
+ body description
58
+ ```
59
+
60
+ into well-formatted message:
61
+
62
+ ```
63
+ feat(scope, scope): add new feature
64
+
65
+ body description
66
+ ```
67
+
68
+ ### Linting
69
+
70
+ commitfmt can check that developers follow the rules set by the project.
71
+
72
+ For example, check that only allowed types and scopes are used. To do this, add the following to the <nobr>[configuration file](#configuration)</nobr>:
73
+
74
+ ```toml
75
+ [lint.header]
76
+ # Check allowed commit type
77
+ type-enum = ["chore", "ci", "feat", "fix", "refactor", "style", "test"]
78
+ # Check allowed commit scopes
79
+ scope-enum = ["cc", "config", "git", "linter"]
80
+
81
+ [lint.footer]
82
+ # Check required footers
83
+ exists = ["Issue-ID", "Authored-By"]
84
+ ```
85
+
86
+ ### Performance
87
+
88
+ commitfmt is very fast because its code is written in Rust with memory consumption and performance in mind.
89
+
90
+ It natively supports following platforms:
91
+
92
+ | OS | Architecture |
93
+ | --- | --- |
94
+ | macOS | x86_64, arm64 |
95
+ | Windows | x86_64, i686 |
96
+ | Linux | x86_64, i686, arm64 |
97
+
98
+ ## Installation
99
+
100
+ ### Script
101
+
102
+ You can use a simple [script](https://github.com/mishamyrt/commitfmt/blob/refs/heads/main/scripts/install.sh) to install commitfmt.
103
+ It will download the latest version of the binary and install it to the system.
104
+
105
+ ```bash
106
+ # Install latest version
107
+ curl -sSfL https://raw.githubusercontent.com/mishamyrt/commitfmt/refs/heads/main/scripts/install.sh | bash
108
+ ```
109
+
110
+ ### pnpm
111
+
112
+ ```bash
113
+ pnpm add --save-dev commitfmt
114
+ ```
115
+
116
+ ### npm
117
+
118
+ ```bash
119
+ npm install --save-dev commitfmt
120
+ ```
121
+
122
+ ### yarn
123
+
124
+ ```bash
125
+ yarn add --dev commitfmt
126
+ ```
127
+
128
+ ### pip
129
+
130
+ ```bash
131
+ pip install commitfmt
132
+ ```
133
+
134
+ ## Hook
135
+
136
+ After installing the package, you need to add a hook to the `prepare-commit-msg` event. You can use any hook manager.
137
+
138
+ > **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`.
139
+
140
+ ### Script
141
+
142
+ You can use a simple script to add a hook.
143
+
144
+ ```bash
145
+ echo "#!/bin/sh" > .git/hooks/prepare-commit-msg
146
+ echo "commitfmt" >> .git/hooks/prepare-commit-msg
147
+ chmod +x .git/hooks/prepare-commit-msg
148
+ ```
149
+
150
+ ### [Lefthook](https://github.com/evilmartians/lefthook)
151
+
152
+ Add to your `lefthook.yml` file:
153
+
154
+ ```yaml
155
+ prepare-commit-msg:
156
+ - name: format commit message
157
+ run: commitfmt
158
+ ```
159
+
160
+ ### [Husky](https://github.com/typicode/husky)
161
+
162
+ Add to your `.husky` folder `prepare-commit-msg` file with the following content:
163
+
164
+ ```bash
165
+ #!/bin/sh
166
+ commitfmt
167
+ ```
168
+
169
+ ## Configuration
170
+
171
+ In commitfmt, you cannot customize basic formatting rules such as extra spaces removal.
172
+
173
+ It is an opinionated formatter and the author has established best practices that should not harm anyone.
174
+
175
+ ### Linting
176
+
177
+ Most of the linting rules are disabled by default. Default config contains 3 rules as they can be safely auto-fixed:
178
+
179
+ ```toml
180
+ [lint.header]
181
+ full-stop = true
182
+
183
+ [lint.body]
184
+ new-line = true
185
+
186
+ [lint.footer]
187
+ breaking-exclamation = true
188
+ ```
189
+
190
+ 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.
191
+
192
+ If there is a problem with an enabled rule and it cannot be automatically fixed, the commit process will be aborted.
193
+
194
+ #### Unsafe fixes
195
+
196
+ 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.
197
+
198
+ To enable unsafe fixes, add the following to your config file:
199
+
200
+ ```toml
201
+ [lint]
202
+ unsafe-fixes = true
203
+ ```
204
+
205
+ ### Extending
206
+
207
+ You can extend the configuration of the parent project by adding the `extends` key to your config file:
208
+
209
+ ```toml
210
+ extends = "node_modules/commitfmt-config-standard/commitfmt.toml"
211
+ ```
212
+
213
+ Extension is only possible for the current configuration. If the current configuration extends another configuration, which in turn extends a third configuration, commitfmt will throw an error when trying to load such a configuration.
214
+
215
+ ### Additional footers
216
+
217
+ commitfmt can add additional footers to the commit message.
218
+
219
+ #### Value template
220
+
221
+ 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`.
222
+
223
+ For example, to add the `Authored-By` footer with the current user name, add the following to your config file:
224
+
225
+ ```toml
226
+ [additional-footers]
227
+ key = "Authored-By"
228
+ value-template = "{{ echo $USER }}"
229
+ ```
230
+
231
+ #### Branch value pattern
232
+
233
+ You can also add the ticket number from the task tracker to the footer if it is in the branch name:
234
+
235
+ ```toml
236
+ [additional-footers]
237
+ key = "Ticket-ID"
238
+ branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
239
+ ```
240
+
241
+ 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`.
242
+
243
+ If the ticket number is not found in the branch name, footer will be skipped.
244
+
245
+ You can use [rustexp](https://rustexp.lpil.uk) to test your pattern.
246
+
247
+ ##### Recipes
248
+
249
+ Examples of patterns for branch names in git flow format:
250
+
251
+ - Jira/YouTrack: `(?:.*)/([A-Z0-9-]+)/?(?:.*)`
252
+ - `feature/CFMT-123`
253
+ - `feature/CFMT-123/add-new-feature`
254
+ - GitHub: `(?:.*)/#?([0-9-]+)/?(?:.*)`
255
+ - `feature/#123`
256
+ - `feature/123`
257
+ - `feature/#123/add-new-feature`
258
+
259
+ #### On conflict
260
+
261
+ If the footer already exists in the commit message, you can specify what to do with it. By default, the footer will be skipped.
262
+
263
+ ```toml
264
+ [additional-footers]
265
+ key = "Ticket-ID"
266
+ branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
267
+ on-conflict = "skip" # skip, append, error
268
+ ```
269
+
270
+ Available options:
271
+
272
+ - `skip` - skip the footer if it already exists
273
+ - `append` - append the footer to the end of the footer list
274
+ - `error` - abort the commit
275
+
276
+ ## Testing
277
+
278
+ To test the configuration and the work of commitfmt, run the following command:
279
+
280
+ ```bash
281
+ echo "chore ( test ) : test commit" | commitfmt
282
+ # or
283
+ cat commit_text.txt | commitfmt
284
+ ```
285
+
286
+ ## History testing
287
+
288
+ To test the history of commits, run the following command:
289
+
290
+ ```bash
291
+ commitfmt --from HEAD~20
292
+ # or
293
+ commitfmt --from 1234567890 --to 1234567890
294
+ ```
@@ -4,7 +4,7 @@ authors = [
4
4
  {name = "Mikhael Khrustik", email = "misha@myrt.co"},
5
5
  ]
6
6
  description = "Utility for formatting and verifying the commit message."
7
- version = "0.1.2-rc.3"
7
+ version = "0.2.0"
8
8
  readme = "README.md"
9
9
  requires-python = ">=3.9"
10
10
  keywords = ["git", "hook"]
@@ -1,89 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: commitfmt
3
- Version: 0.1.2rc3
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
- Requires-Python: >=3.9
17
- Description-Content-Type: text/markdown
18
- Requires-Dist: commitfmt_windows==0.1.5; sys_platform == "win32"
19
- Requires-Dist: commitfmt_openbsd==0.1.5; sys_platform == "openbsd"
20
- Requires-Dist: commitfmt_freebsd==0.1.5; sys_platform == "freebsd"
21
- Requires-Dist: commitfmt_darwin==0.1.5; sys_platform == "darwin"
22
- Requires-Dist: commitfmt_linux==0.1.5; sys_platform == "linux"
23
-
24
- # commitfmt [![Quality Assurance](https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml/badge.svg)](https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml)
25
-
26
- Utility for formatting and verifying the commit message.
27
-
28
- 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 the story high quality.
29
-
30
- 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.
31
-
32
- A message like this:
33
-
34
- ```
35
- feat ( scope , scope ) : add new feature.
36
- body description
37
- ```
38
-
39
- Will be formatted to:
40
-
41
- ```
42
- feat(scope, scope): add new feature
43
-
44
- body description
45
- ```
46
-
47
- Additionally, you can customize checks, such as limiting the list of available types and scopes. To do this, create a [configuration file](#configuration).
48
-
49
- ## Installation
50
-
51
- ### pnpm
52
-
53
- ```bash
54
- pnpm add --save-dev commitfmt
55
- ```
56
-
57
- ### npm
58
-
59
- ```bash
60
- npm install --save-dev commitfmt
61
- ```
62
-
63
- ### yarn
64
-
65
- ```bash
66
- yarn add --dev commitfmt
67
- ```
68
-
69
- ### pip
70
-
71
- ```bash
72
- pip install commitfmt
73
- ```
74
-
75
- ## Configuration
76
-
77
- ### TOML
78
-
79
- Create a `commitfmt.toml` or (`.commitfmt.toml`) file in the root of your project.
80
-
81
- ```toml
82
- [lint.body]
83
- full-stop = false
84
-
85
- [lint.header]
86
- scope-case = "lower"
87
- scope-enum = ["cc", "config", "git", "linter"]
88
- type-enum = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test"]
89
- ```
@@ -1,66 +0,0 @@
1
- # commitfmt [![Quality Assurance](https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml/badge.svg)](https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml)
2
-
3
- Utility for formatting and verifying the commit message.
4
-
5
- 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 the story high quality.
6
-
7
- 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.
8
-
9
- A message like this:
10
-
11
- ```
12
- feat ( scope , scope ) : add new feature.
13
- body description
14
- ```
15
-
16
- Will be formatted to:
17
-
18
- ```
19
- feat(scope, scope): add new feature
20
-
21
- body description
22
- ```
23
-
24
- Additionally, you can customize checks, such as limiting the list of available types and scopes. To do this, create a [configuration file](#configuration).
25
-
26
- ## Installation
27
-
28
- ### pnpm
29
-
30
- ```bash
31
- pnpm add --save-dev commitfmt
32
- ```
33
-
34
- ### npm
35
-
36
- ```bash
37
- npm install --save-dev commitfmt
38
- ```
39
-
40
- ### yarn
41
-
42
- ```bash
43
- yarn add --dev commitfmt
44
- ```
45
-
46
- ### pip
47
-
48
- ```bash
49
- pip install commitfmt
50
- ```
51
-
52
- ## Configuration
53
-
54
- ### TOML
55
-
56
- Create a `commitfmt.toml` or (`.commitfmt.toml`) file in the root of your project.
57
-
58
- ```toml
59
- [lint.body]
60
- full-stop = false
61
-
62
- [lint.header]
63
- scope-case = "lower"
64
- scope-enum = ["cc", "config", "git", "linter"]
65
- type-enum = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test"]
66
- ```
@@ -1,89 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: commitfmt
3
- Version: 0.1.2rc3
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
- Requires-Python: >=3.9
17
- Description-Content-Type: text/markdown
18
- Requires-Dist: commitfmt_windows==0.1.5; sys_platform == "win32"
19
- Requires-Dist: commitfmt_openbsd==0.1.5; sys_platform == "openbsd"
20
- Requires-Dist: commitfmt_freebsd==0.1.5; sys_platform == "freebsd"
21
- Requires-Dist: commitfmt_darwin==0.1.5; sys_platform == "darwin"
22
- Requires-Dist: commitfmt_linux==0.1.5; sys_platform == "linux"
23
-
24
- # commitfmt [![Quality Assurance](https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml/badge.svg)](https://github.com/mishamyrt/commitfmt/actions/workflows/qa.yaml)
25
-
26
- Utility for formatting and verifying the commit message.
27
-
28
- 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 the story high quality.
29
-
30
- 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.
31
-
32
- A message like this:
33
-
34
- ```
35
- feat ( scope , scope ) : add new feature.
36
- body description
37
- ```
38
-
39
- Will be formatted to:
40
-
41
- ```
42
- feat(scope, scope): add new feature
43
-
44
- body description
45
- ```
46
-
47
- Additionally, you can customize checks, such as limiting the list of available types and scopes. To do this, create a [configuration file](#configuration).
48
-
49
- ## Installation
50
-
51
- ### pnpm
52
-
53
- ```bash
54
- pnpm add --save-dev commitfmt
55
- ```
56
-
57
- ### npm
58
-
59
- ```bash
60
- npm install --save-dev commitfmt
61
- ```
62
-
63
- ### yarn
64
-
65
- ```bash
66
- yarn add --dev commitfmt
67
- ```
68
-
69
- ### pip
70
-
71
- ```bash
72
- pip install commitfmt
73
- ```
74
-
75
- ## Configuration
76
-
77
- ### TOML
78
-
79
- Create a `commitfmt.toml` or (`.commitfmt.toml`) file in the root of your project.
80
-
81
- ```toml
82
- [lint.body]
83
- full-stop = false
84
-
85
- [lint.header]
86
- scope-case = "lower"
87
- scope-enum = ["cc", "config", "git", "linter"]
88
- type-enum = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test"]
89
- ```
File without changes