commitfmt 0.1.5__py3-none-any.whl → 0.3.0__py3-none-any.whl

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,318 @@
1
+ Metadata-Version: 2.4
2
+ Name: commitfmt
3
+ Version: 0.3.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
+ ### Parser Configuration
216
+
217
+ commitfmt can be configured to use custom footer separators and comment symbols for parsing commit messages.
218
+
219
+ #### Footer separators
220
+
221
+ By default, commitfmt uses git's `trailer.separators` configuration to determine which characters separate footer keys from values. You can override this in your config file:
222
+
223
+ ```toml
224
+ footer-separators = ":#"
225
+ ```
226
+
227
+ This allows footers like `Issue-ID: 123` or `Issue-ID #123` to be recognized.
228
+
229
+ #### Comment symbol
230
+
231
+ By default, commitfmt uses git's `core.commentChar` or `core.commentString` configuration to identify comment lines in commit messages. You can override this:
232
+
233
+ ```toml
234
+ comment-symbol = "//"
235
+ ```
236
+
237
+ Lines starting with the comment symbol will be ignored during parsing.
238
+
239
+ ### Additional footers
240
+
241
+ commitfmt can add additional footers to the commit message.
242
+
243
+ #### Value template
244
+
245
+ 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`.
246
+
247
+ For example, to add the `Authored-By` footer with the current user name, add the following to your config file:
248
+
249
+ ```toml
250
+ [additional-footers]
251
+ key = "Authored-By"
252
+ value-template = "{{ echo $USER }}"
253
+ ```
254
+
255
+ #### Branch value pattern
256
+
257
+ You can also add the ticket number from the task tracker to the footer if it is in the branch name:
258
+
259
+ ```toml
260
+ [additional-footers]
261
+ key = "Ticket-ID"
262
+ branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
263
+ ```
264
+
265
+ 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`.
266
+
267
+ If the ticket number is not found in the branch name, footer will be skipped.
268
+
269
+ You can use [rustexp](https://rustexp.lpil.uk) to test your pattern.
270
+
271
+ ##### Recipes
272
+
273
+ Examples of patterns for branch names in git flow format:
274
+
275
+ - Jira/YouTrack: `(?:.*)/([A-Z0-9-]+)/?(?:.*)`
276
+ - `feature/CFMT-123`
277
+ - `feature/CFMT-123/add-new-feature`
278
+ - GitHub: `(?:.*)/#?([0-9-]+)/?(?:.*)`
279
+ - `feature/#123`
280
+ - `feature/123`
281
+ - `feature/#123/add-new-feature`
282
+
283
+ #### On conflict
284
+
285
+ If the footer already exists in the commit message, you can specify what to do with it. By default, the footer will be skipped.
286
+
287
+ ```toml
288
+ [additional-footers]
289
+ key = "Ticket-ID"
290
+ branch-value-pattern = "(?:.*)/([A-Z0-9-]+)/?(?:.*)"
291
+ on-conflict = "skip" # skip, append, error
292
+ ```
293
+
294
+ Available options:
295
+
296
+ - `skip` - skip the footer if it already exists
297
+ - `append` - append the footer to the end of the footer list
298
+ - `error` - abort the commit
299
+
300
+ ## Testing
301
+
302
+ To test the configuration and the work of commitfmt, run the following command:
303
+
304
+ ```bash
305
+ echo "chore ( test ) : test commit" | commitfmt
306
+ # or
307
+ cat commit_text.txt | commitfmt
308
+ ```
309
+
310
+ ## History testing
311
+
312
+ To test the history of commits, run the following command:
313
+
314
+ ```bash
315
+ commitfmt --from HEAD~20
316
+ # or
317
+ commitfmt --from 1234567890 --to 1234567890
318
+ ```
@@ -0,0 +1,8 @@
1
+ commitfmt/__init__.py,sha256=XbqA09CGurplp5_c9PpHKvYDGevnhBjtUoYClkU9TCU,32
2
+ commitfmt/__main__.py,sha256=oYv9CGhyxv4OJDAo8jY-vH3WZ9y6IBt9FAVMIDdGARs,353
3
+ commitfmt/commitfmt.py,sha256=4D-ifjc3kqn_wGGZCUFgp5HKGZ5UmU6qnJahwx7HopI,995
4
+ commitfmt-0.3.0.dist-info/METADATA,sha256=ZRYTWnPUcGY3K_m1ncOwbE3ZKMTO132Uetwbi2sK1BU,9258
5
+ commitfmt-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ commitfmt-0.3.0.dist-info/entry_points.txt,sha256=WbaxVY_kl8rYTrC2jtjP0U5x6gB0Q6CF5V2YKMrXQfc,54
7
+ commitfmt-0.3.0.dist-info/top_level.txt,sha256=YDzuLgcXgStEzOmg2c7IQZIpsye34U2vKCIheKEvyjg,10
8
+ commitfmt-0.3.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.0.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: commitfmt
3
- Version: 0.1.5
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 python wrapper
@@ -1,8 +0,0 @@
1
- commitfmt/__init__.py,sha256=XbqA09CGurplp5_c9PpHKvYDGevnhBjtUoYClkU9TCU,32
2
- commitfmt/__main__.py,sha256=oYv9CGhyxv4OJDAo8jY-vH3WZ9y6IBt9FAVMIDdGARs,353
3
- commitfmt/commitfmt.py,sha256=4D-ifjc3kqn_wGGZCUFgp5HKGZ5UmU6qnJahwx7HopI,995
4
- commitfmt-0.1.5.dist-info/METADATA,sha256=Gh1QGIewXhI2SQCKY1qFE2CsZ0YVQ7YF12N2gRnbL6s,1021
5
- commitfmt-0.1.5.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
6
- commitfmt-0.1.5.dist-info/entry_points.txt,sha256=WbaxVY_kl8rYTrC2jtjP0U5x6gB0Q6CF5V2YKMrXQfc,54
7
- commitfmt-0.1.5.dist-info/top_level.txt,sha256=YDzuLgcXgStEzOmg2c7IQZIpsye34U2vKCIheKEvyjg,10
8
- commitfmt-0.1.5.dist-info/RECORD,,