commitizen 4.12.1__py3-none-any.whl → 4.13.1__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.
- commitizen/__version__.py +1 -1
- commitizen/changelog_formats/__init__.py +7 -0
- commitizen/cli.py +111 -106
- commitizen/commands/bump.py +18 -13
- commitizen/commands/check.py +2 -2
- commitizen/commands/commit.py +13 -9
- commitizen/commands/init.py +24 -4
- commitizen/commands/version.py +9 -0
- commitizen/config/__init__.py +17 -27
- commitizen/config/base_config.py +7 -1
- commitizen/config/json_config.py +7 -2
- commitizen/config/toml_config.py +6 -1
- commitizen/config/yaml_config.py +6 -3
- commitizen/cz/base.py +1 -1
- commitizen/defaults.py +2 -2
- commitizen/tags.py +20 -1
- {commitizen-4.12.1.dist-info → commitizen-4.13.1.dist-info}/METADATA +6 -1
- {commitizen-4.12.1.dist-info → commitizen-4.13.1.dist-info}/RECORD +20 -20
- {commitizen-4.12.1.dist-info → commitizen-4.13.1.dist-info}/WHEEL +1 -1
- {commitizen-4.12.1.dist-info → commitizen-4.13.1.dist-info}/entry_points.txt +0 -0
commitizen/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "4.
|
|
1
|
+
__version__ = "4.13.1"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import warnings
|
|
3
4
|
from importlib import metadata
|
|
4
5
|
from typing import TYPE_CHECKING, ClassVar, Protocol
|
|
5
6
|
|
|
@@ -99,5 +100,11 @@ def _guess_changelog_format(filename: str | None) -> type[ChangelogFormat] | Non
|
|
|
99
100
|
|
|
100
101
|
def __getattr__(name: str) -> Callable[[str], type[ChangelogFormat] | None]:
|
|
101
102
|
if name == "guess_changelog_format":
|
|
103
|
+
warnings.warn(
|
|
104
|
+
"guess_changelog_format is deprecated and will be removed in v5. "
|
|
105
|
+
"Use _guess_changelog_format instead.",
|
|
106
|
+
DeprecationWarning,
|
|
107
|
+
stacklevel=2,
|
|
108
|
+
)
|
|
102
109
|
return _guess_changelog_format
|
|
103
110
|
raise AttributeError(f"module {__name__} has no attribute {name}")
|
commitizen/cli.py
CHANGED
|
@@ -13,6 +13,7 @@ import argcomplete
|
|
|
13
13
|
from decli import cli
|
|
14
14
|
|
|
15
15
|
from commitizen import commands, config, out, version_schemes
|
|
16
|
+
from commitizen.defaults import DEFAULT_SETTINGS
|
|
16
17
|
from commitizen.exceptions import (
|
|
17
18
|
CommitizenException,
|
|
18
19
|
ExitCode,
|
|
@@ -67,7 +68,7 @@ tpl_arguments = (
|
|
|
67
68
|
{
|
|
68
69
|
"name": ["--template", "-t"],
|
|
69
70
|
"help": (
|
|
70
|
-
"
|
|
71
|
+
"Changelog template file name (relative to the current working directory)."
|
|
71
72
|
),
|
|
72
73
|
},
|
|
73
74
|
{
|
|
@@ -75,7 +76,7 @@ tpl_arguments = (
|
|
|
75
76
|
"action": ParseKwargs,
|
|
76
77
|
"dest": "extras",
|
|
77
78
|
"metavar": "EXTRA",
|
|
78
|
-
"help": "
|
|
79
|
+
"help": "Changelog extra variables (in the form 'key=value').",
|
|
79
80
|
},
|
|
80
81
|
)
|
|
81
82
|
|
|
@@ -89,18 +90,18 @@ data = {
|
|
|
89
90
|
"arguments": [
|
|
90
91
|
{
|
|
91
92
|
"name": "--config",
|
|
92
|
-
"help": "
|
|
93
|
+
"help": "The path to the configuration file.",
|
|
93
94
|
},
|
|
94
|
-
{"name": "--debug", "action": "store_true", "help": "
|
|
95
|
+
{"name": "--debug", "action": "store_true", "help": "Use debug mode."},
|
|
95
96
|
{
|
|
96
97
|
"name": ["-n", "--name"],
|
|
97
|
-
"help": "
|
|
98
|
+
"help": "Use the given commitizen (default: cz_conventional_commits).",
|
|
98
99
|
},
|
|
99
100
|
{
|
|
100
101
|
"name": ["-nr", "--no-raise"],
|
|
101
102
|
"type": str,
|
|
102
103
|
"required": False,
|
|
103
|
-
"help": "
|
|
104
|
+
"help": "Comma-separated error codes that won't raise error, e.g., cz -nr 1,2,3 bump. See codes at https://commitizen-tools.github.io/commitizen/exit_codes/",
|
|
104
105
|
},
|
|
105
106
|
],
|
|
106
107
|
"subcommands": {
|
|
@@ -109,157 +110,162 @@ data = {
|
|
|
109
110
|
"commands": [
|
|
110
111
|
{
|
|
111
112
|
"name": ["init"],
|
|
112
|
-
"description": "
|
|
113
|
-
"help": "
|
|
113
|
+
"description": "Initialize commitizen configuration",
|
|
114
|
+
"help": "Initialize commitizen configuration.",
|
|
114
115
|
"func": commands.Init,
|
|
115
116
|
},
|
|
116
117
|
{
|
|
117
118
|
"name": ["commit", "c"],
|
|
118
|
-
"description": "
|
|
119
|
-
"help": "
|
|
119
|
+
"description": "Create new commit",
|
|
120
|
+
"help": "Create new commit.",
|
|
120
121
|
"func": commands.Commit,
|
|
121
122
|
"arguments": [
|
|
122
123
|
{
|
|
123
124
|
"name": ["--retry"],
|
|
124
125
|
"action": "store_true",
|
|
125
|
-
"help": "
|
|
126
|
+
"help": "Retry the last commit.",
|
|
126
127
|
},
|
|
127
128
|
{
|
|
128
129
|
"name": ["--no-retry"],
|
|
129
130
|
"action": "store_true",
|
|
130
131
|
"default": False,
|
|
131
|
-
"help": "
|
|
132
|
+
"help": "Skip retry if --retry or `retry_after_failure` is set to true.",
|
|
132
133
|
},
|
|
133
134
|
{
|
|
134
135
|
"name": "--dry-run",
|
|
135
136
|
"action": "store_true",
|
|
136
|
-
"help": "
|
|
137
|
+
"help": "Perform a dry run, without committing or modifying files.",
|
|
137
138
|
},
|
|
138
139
|
{
|
|
139
140
|
"name": "--write-message-to-file",
|
|
140
141
|
"type": Path,
|
|
141
142
|
"metavar": "FILE_PATH",
|
|
142
|
-
"help": "
|
|
143
|
+
"help": "Write message to FILE_PATH before committing (can be used with --dry-run).",
|
|
143
144
|
},
|
|
144
145
|
{
|
|
145
146
|
"name": ["-s", "--signoff"],
|
|
146
147
|
"action": "store_true",
|
|
147
|
-
"help": "Deprecated, use
|
|
148
|
+
"help": "Deprecated, use `cz commit -- -s` instead.",
|
|
148
149
|
},
|
|
149
150
|
{
|
|
150
151
|
"name": ["-a", "--all"],
|
|
151
152
|
"action": "store_true",
|
|
152
|
-
|
|
153
|
+
# The help text aligns with the description of git commit --all
|
|
154
|
+
"help": "Automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.",
|
|
153
155
|
},
|
|
154
156
|
{
|
|
155
157
|
"name": ["-e", "--edit"],
|
|
156
158
|
"action": "store_true",
|
|
157
159
|
"default": False,
|
|
158
|
-
"help": "
|
|
160
|
+
"help": "Edit the commit message before committing.",
|
|
159
161
|
},
|
|
160
162
|
{
|
|
161
163
|
"name": ["-l", "--message-length-limit"],
|
|
162
164
|
"type": int,
|
|
163
|
-
"help": "length limit of the commit message; 0 for no limit",
|
|
165
|
+
"help": "Set the length limit of the commit message; 0 for no limit.",
|
|
164
166
|
},
|
|
165
167
|
{
|
|
166
168
|
"name": ["--"],
|
|
167
169
|
"action": "store_true",
|
|
168
170
|
"dest": "double_dash",
|
|
169
|
-
"help": "Positional arguments separator (recommended)",
|
|
171
|
+
"help": "Positional arguments separator (recommended).",
|
|
170
172
|
},
|
|
171
173
|
],
|
|
172
174
|
},
|
|
173
175
|
{
|
|
174
176
|
"name": "ls",
|
|
175
|
-
"description": "
|
|
176
|
-
"help": "
|
|
177
|
+
"description": "Show available Commitizens",
|
|
178
|
+
"help": "Show available Commitizens.",
|
|
177
179
|
"func": commands.ListCz,
|
|
178
180
|
},
|
|
179
181
|
{
|
|
180
182
|
"name": "example",
|
|
181
|
-
"description": "
|
|
182
|
-
"help": "
|
|
183
|
+
"description": "Show commit example",
|
|
184
|
+
"help": "Show commit example.",
|
|
183
185
|
"func": commands.Example,
|
|
184
186
|
},
|
|
185
187
|
{
|
|
186
188
|
"name": "info",
|
|
187
|
-
"description": "
|
|
188
|
-
"help": "
|
|
189
|
+
"description": "Show information about the cz",
|
|
190
|
+
"help": "Show information about the cz.",
|
|
189
191
|
"func": commands.Info,
|
|
190
192
|
},
|
|
191
193
|
{
|
|
192
194
|
"name": "schema",
|
|
193
|
-
"description": "
|
|
194
|
-
"help": "
|
|
195
|
+
"description": "Show commit schema",
|
|
196
|
+
"help": "Show commit schema.",
|
|
195
197
|
"func": commands.Schema,
|
|
196
198
|
},
|
|
197
199
|
{
|
|
198
200
|
"name": "bump",
|
|
199
|
-
"description": "
|
|
200
|
-
"help": "
|
|
201
|
+
"description": "Bump semantic version based on the git log",
|
|
202
|
+
"help": "Bump semantic version based on the git log.",
|
|
201
203
|
"func": commands.Bump,
|
|
202
204
|
"arguments": [
|
|
203
205
|
{
|
|
204
206
|
"name": "--dry-run",
|
|
205
207
|
"action": "store_true",
|
|
206
|
-
"help": "
|
|
208
|
+
"help": "Perform a dry run, without committing or modifying files.",
|
|
207
209
|
},
|
|
208
210
|
{
|
|
209
|
-
"name": "--files-only",
|
|
211
|
+
"name": "--files-only", # TODO: rename to --version-files-only
|
|
210
212
|
"action": "store_true",
|
|
211
|
-
"help": "
|
|
213
|
+
"help": "Bump version in the `version_files` specified in the configuration file only(deprecated; use --version-files-only instead).",
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "--version-files-only",
|
|
217
|
+
"action": "store_true",
|
|
218
|
+
"help": "Bump version in the files from the config",
|
|
212
219
|
},
|
|
213
220
|
{
|
|
214
221
|
"name": "--local-version",
|
|
215
222
|
"action": "store_true",
|
|
216
|
-
"help": "
|
|
223
|
+
"help": "Bump version only the local version portion (ignoring the public version).",
|
|
217
224
|
},
|
|
218
225
|
{
|
|
219
226
|
"name": ["--changelog", "-ch"],
|
|
220
227
|
"action": "store_true",
|
|
221
228
|
"default": False,
|
|
222
|
-
"help": "
|
|
229
|
+
"help": "Generate the changelog for the latest version.",
|
|
223
230
|
},
|
|
224
231
|
{
|
|
225
232
|
"name": ["--no-verify"],
|
|
226
233
|
"action": "store_true",
|
|
227
234
|
"default": False,
|
|
228
|
-
|
|
235
|
+
# The help text aligns with the description of git commit --no-verify
|
|
236
|
+
"help": "Bypass the pre-commit and commit-msg hooks.",
|
|
229
237
|
},
|
|
230
238
|
{
|
|
231
239
|
"name": "--yes",
|
|
232
240
|
"action": "store_true",
|
|
233
|
-
"help": "
|
|
241
|
+
"help": "Accept automatically answered questions.",
|
|
234
242
|
},
|
|
235
243
|
{
|
|
236
244
|
"name": "--tag-format",
|
|
237
245
|
"help": (
|
|
238
|
-
"
|
|
239
|
-
"
|
|
240
|
-
"wrap around simple quotes"
|
|
246
|
+
"The format used to tag the commit and read it. "
|
|
247
|
+
"Use it in existing projects, and wrap around simple quotes."
|
|
241
248
|
),
|
|
242
249
|
},
|
|
243
250
|
{
|
|
244
251
|
"name": "--bump-message",
|
|
245
252
|
"help": (
|
|
246
|
-
"
|
|
247
|
-
"useful when working with CI"
|
|
253
|
+
"Template used to create the release commit, useful when working with CI."
|
|
248
254
|
),
|
|
249
255
|
},
|
|
250
256
|
{
|
|
251
257
|
"name": ["--prerelease", "-pr"],
|
|
252
|
-
"help": "
|
|
258
|
+
"help": "Type of prerelease.",
|
|
253
259
|
"choices": ["alpha", "beta", "rc"],
|
|
254
260
|
},
|
|
255
261
|
{
|
|
256
262
|
"name": ["--devrelease", "-d"],
|
|
257
|
-
"help": "
|
|
263
|
+
"help": "Specify non-negative integer for dev release.",
|
|
258
264
|
"type": int,
|
|
259
265
|
},
|
|
260
266
|
{
|
|
261
267
|
"name": ["--increment"],
|
|
262
|
-
"help": "
|
|
268
|
+
"help": "Specify the desired increment.",
|
|
263
269
|
"choices": ["MAJOR", "MINOR", "PATCH"],
|
|
264
270
|
"type": str.upper,
|
|
265
271
|
},
|
|
@@ -268,35 +274,34 @@ data = {
|
|
|
268
274
|
"choices": ["linear", "exact"],
|
|
269
275
|
"default": "linear",
|
|
270
276
|
"help": (
|
|
271
|
-
"
|
|
272
|
-
"'linear' (default)
|
|
273
|
-
"
|
|
277
|
+
"Set the method by which the new version is chosen. "
|
|
278
|
+
"'linear' (default) resolves the next version based on typical linear version progression, "
|
|
279
|
+
"where bumping of a pre-release with lower precedence than the current pre-release "
|
|
274
280
|
"phase maintains the current phase of higher precedence. "
|
|
275
281
|
"'exact' applies the changes that have been specified (or determined from the commit log) "
|
|
276
|
-
"without interpretation,
|
|
282
|
+
"without interpretation, ensuring the increment and pre-release are always honored."
|
|
277
283
|
),
|
|
278
284
|
},
|
|
279
285
|
{
|
|
280
286
|
"name": ["--check-consistency", "-cc"],
|
|
281
287
|
"help": (
|
|
282
|
-
"
|
|
283
|
-
"commitizen configuration and version_files"
|
|
288
|
+
"Check consistency among versions defined in Commitizen configuration file and `version_files`."
|
|
284
289
|
),
|
|
285
290
|
"action": "store_true",
|
|
286
291
|
},
|
|
287
292
|
{
|
|
288
293
|
"name": ["--annotated-tag", "-at"],
|
|
289
|
-
"help": "
|
|
294
|
+
"help": "Create annotated tag instead of lightweight one.",
|
|
290
295
|
"action": "store_true",
|
|
291
296
|
},
|
|
292
297
|
{
|
|
293
298
|
"name": ["--annotated-tag-message", "-atm"],
|
|
294
|
-
"help": "
|
|
299
|
+
"help": "Create annotated tag message.",
|
|
295
300
|
"type": str,
|
|
296
301
|
},
|
|
297
302
|
{
|
|
298
303
|
"name": ["--gpg-sign", "-s"],
|
|
299
|
-
"help": "
|
|
304
|
+
"help": "Sign tag instead of lightweight one.",
|
|
300
305
|
"default": False,
|
|
301
306
|
"action": "store_true",
|
|
302
307
|
},
|
|
@@ -304,46 +309,46 @@ data = {
|
|
|
304
309
|
"name": ["--changelog-to-stdout"],
|
|
305
310
|
"action": "store_true",
|
|
306
311
|
"default": False,
|
|
307
|
-
"help": "Output changelog to
|
|
312
|
+
"help": "Output changelog to stdout.",
|
|
308
313
|
},
|
|
309
314
|
{
|
|
310
315
|
"name": ["--git-output-to-stderr"],
|
|
311
316
|
"action": "store_true",
|
|
312
317
|
"default": False,
|
|
313
|
-
"help": "Redirect git output to stderr",
|
|
318
|
+
"help": "Redirect git output to stderr.",
|
|
314
319
|
},
|
|
315
320
|
{
|
|
316
321
|
"name": ["--retry"],
|
|
317
322
|
"action": "store_true",
|
|
318
323
|
"default": False,
|
|
319
|
-
"help": "
|
|
324
|
+
"help": "Retry commit if it fails for the first time.",
|
|
320
325
|
},
|
|
321
326
|
{
|
|
322
327
|
"name": ["--major-version-zero"],
|
|
323
328
|
"action": "store_true",
|
|
324
329
|
"default": None,
|
|
325
|
-
"help": "
|
|
330
|
+
"help": "Keep major version at zero, even for breaking changes.",
|
|
326
331
|
},
|
|
327
332
|
*deepcopy(tpl_arguments),
|
|
328
333
|
{
|
|
329
334
|
"name": "--file-name",
|
|
330
|
-
"help": "
|
|
335
|
+
"help": "File name of changelog (default: 'CHANGELOG.md').",
|
|
331
336
|
},
|
|
332
337
|
{
|
|
333
338
|
"name": ["--prerelease-offset"],
|
|
334
339
|
"type": int,
|
|
335
340
|
"default": None,
|
|
336
|
-
"help": "
|
|
341
|
+
"help": "Start pre-releases with this offset.",
|
|
337
342
|
},
|
|
338
343
|
{
|
|
339
344
|
"name": ["--version-scheme"],
|
|
340
|
-
"help": "
|
|
345
|
+
"help": "Choose version scheme.",
|
|
341
346
|
"default": None,
|
|
342
347
|
"choices": version_schemes.KNOWN_SCHEMES,
|
|
343
348
|
},
|
|
344
349
|
{
|
|
345
350
|
"name": ["--version-type"],
|
|
346
|
-
"help": "Deprecated, use
|
|
351
|
+
"help": "Deprecated, use `--version-scheme` instead.",
|
|
347
352
|
"default": None,
|
|
348
353
|
"choices": version_schemes.KNOWN_SCHEMES,
|
|
349
354
|
},
|
|
@@ -351,24 +356,24 @@ data = {
|
|
|
351
356
|
"name": "manual_version",
|
|
352
357
|
"type": str,
|
|
353
358
|
"nargs": "?",
|
|
354
|
-
"help": "
|
|
359
|
+
"help": "Bump to the given version (e.g., 1.5.3).",
|
|
355
360
|
"metavar": "MANUAL_VERSION",
|
|
356
361
|
},
|
|
357
362
|
{
|
|
358
363
|
"name": ["--build-metadata"],
|
|
359
|
-
"help": "Add additional build-metadata to the version-number",
|
|
364
|
+
"help": "Add additional build-metadata to the version-number.",
|
|
360
365
|
"default": None,
|
|
361
366
|
},
|
|
362
367
|
{
|
|
363
368
|
"name": ["--get-next"],
|
|
364
369
|
"action": "store_true",
|
|
365
|
-
"help": "Determine the next version and write to stdout",
|
|
370
|
+
"help": "Determine the next version and write to stdout.",
|
|
366
371
|
"default": False,
|
|
367
372
|
},
|
|
368
373
|
{
|
|
369
374
|
"name": ["--allow-no-commit"],
|
|
370
375
|
"default": False,
|
|
371
|
-
"help": "
|
|
376
|
+
"help": "Bump version without eligible commits.",
|
|
372
377
|
"action": "store_true",
|
|
373
378
|
},
|
|
374
379
|
],
|
|
@@ -376,10 +381,10 @@ data = {
|
|
|
376
381
|
{
|
|
377
382
|
"name": ["changelog", "ch"],
|
|
378
383
|
"description": (
|
|
379
|
-
"
|
|
384
|
+
"Generate changelog (note that it will overwrite existing files)"
|
|
380
385
|
),
|
|
381
386
|
"help": (
|
|
382
|
-
"
|
|
387
|
+
"Generate changelog (note that it will overwrite existing files)."
|
|
383
388
|
),
|
|
384
389
|
"func": commands.Changelog,
|
|
385
390
|
"arguments": [
|
|
@@ -387,17 +392,17 @@ data = {
|
|
|
387
392
|
"name": "--dry-run",
|
|
388
393
|
"action": "store_true",
|
|
389
394
|
"default": False,
|
|
390
|
-
"help": "
|
|
395
|
+
"help": "Show changelog to stdout.",
|
|
391
396
|
},
|
|
392
397
|
{
|
|
393
398
|
"name": "--file-name",
|
|
394
|
-
"help": "
|
|
399
|
+
"help": "File name of changelog (default: 'CHANGELOG.md').",
|
|
395
400
|
},
|
|
396
401
|
{
|
|
397
402
|
"name": "--unreleased-version",
|
|
398
403
|
"help": (
|
|
399
|
-
"
|
|
400
|
-
"instead of using unreleased"
|
|
404
|
+
"Set the value for the new version (use the tag value), "
|
|
405
|
+
"instead of using unreleased versions."
|
|
401
406
|
),
|
|
402
407
|
},
|
|
403
408
|
{
|
|
@@ -405,22 +410,22 @@ data = {
|
|
|
405
410
|
"action": "store_true",
|
|
406
411
|
"default": False,
|
|
407
412
|
"help": (
|
|
408
|
-
"
|
|
409
|
-
"useful if the changelog has been manually modified"
|
|
413
|
+
"Generate changelog from the last created version, "
|
|
414
|
+
"useful if the changelog has been manually modified."
|
|
410
415
|
),
|
|
411
416
|
},
|
|
412
417
|
{
|
|
413
418
|
"name": "rev_range",
|
|
414
419
|
"type": str,
|
|
415
420
|
"nargs": "?",
|
|
416
|
-
"help": "
|
|
421
|
+
"help": "Generate changelog for the given version (e.g., 1.5.3) or version range (e.g., 1.5.3..1.7.9).",
|
|
417
422
|
},
|
|
418
423
|
{
|
|
419
424
|
"name": "--start-rev",
|
|
420
425
|
"default": None,
|
|
421
426
|
"help": (
|
|
422
|
-
"
|
|
423
|
-
"If not set, it will generate changelog from the
|
|
427
|
+
"Start rev of the changelog. "
|
|
428
|
+
"If not set, it will generate changelog from the beginning."
|
|
424
429
|
),
|
|
425
430
|
},
|
|
426
431
|
{
|
|
@@ -428,128 +433,128 @@ data = {
|
|
|
428
433
|
"action": "store_true",
|
|
429
434
|
"default": False,
|
|
430
435
|
"help": (
|
|
431
|
-
"
|
|
432
|
-
"If not set, it will include prereleases in the changelog"
|
|
436
|
+
"Collect all changes from prereleases into the next non-prerelease. "
|
|
437
|
+
"If not set, it will include prereleases in the changelog."
|
|
433
438
|
),
|
|
434
439
|
},
|
|
435
440
|
{
|
|
436
441
|
"name": ["--version-scheme"],
|
|
437
|
-
"help": "
|
|
442
|
+
"help": "Choose version scheme.",
|
|
438
443
|
"default": None,
|
|
439
444
|
"choices": version_schemes.KNOWN_SCHEMES,
|
|
440
445
|
},
|
|
441
446
|
{
|
|
442
447
|
"name": "--export-template",
|
|
443
448
|
"default": None,
|
|
444
|
-
"help": "Export the changelog template into this file instead of rendering it",
|
|
449
|
+
"help": "Export the changelog template into this file instead of rendering it.",
|
|
445
450
|
},
|
|
446
451
|
*deepcopy(tpl_arguments),
|
|
447
452
|
{
|
|
448
453
|
"name": "--tag-format",
|
|
449
|
-
"help": "The format of the tag, wrap around simple quotes",
|
|
454
|
+
"help": "The format of the tag, wrap around simple quotes.",
|
|
450
455
|
},
|
|
451
456
|
],
|
|
452
457
|
},
|
|
453
458
|
{
|
|
454
459
|
"name": ["check"],
|
|
455
|
-
"description": "
|
|
456
|
-
"help": "
|
|
460
|
+
"description": "Validate that a commit message matches the commitizen schema",
|
|
461
|
+
"help": "Validate that a commit message matches the commitizen schema.",
|
|
457
462
|
"func": commands.Check,
|
|
458
463
|
"arguments": [
|
|
459
464
|
{
|
|
460
465
|
"name": "--commit-msg-file",
|
|
461
466
|
"help": (
|
|
462
|
-
"
|
|
463
|
-
"
|
|
464
|
-
"Using it in a git hook script: MSG_FILE=$1"
|
|
467
|
+
"Ask for the name of the temporary file that contains the commit message. "
|
|
468
|
+
"Use it in a git hook script: MSG_FILE=$1."
|
|
465
469
|
),
|
|
466
470
|
"exclusive_group": "group1",
|
|
467
471
|
},
|
|
468
472
|
{
|
|
469
473
|
"name": "--rev-range",
|
|
470
|
-
"help": "
|
|
474
|
+
"help": "Validate the commits in the given range of git rev, e.g., master..HEAD.",
|
|
471
475
|
"exclusive_group": "group1",
|
|
472
476
|
},
|
|
473
477
|
{
|
|
474
478
|
"name": ["-d", "--use-default-range"],
|
|
475
479
|
"action": "store_true",
|
|
476
480
|
"default": False,
|
|
477
|
-
"help": "
|
|
481
|
+
"help": "Validate the commits from the default branch to HEAD, e.g., refs/remotes/origin/master..HEAD.",
|
|
478
482
|
"exclusive_group": "group1",
|
|
479
483
|
},
|
|
480
484
|
{
|
|
481
485
|
"name": ["-m", "--message"],
|
|
482
|
-
"help": "
|
|
486
|
+
"help": "Validate the given commit message.",
|
|
483
487
|
"exclusive_group": "group1",
|
|
484
488
|
},
|
|
485
489
|
{
|
|
486
490
|
"name": ["--allow-abort"],
|
|
487
491
|
"action": "store_true",
|
|
488
492
|
"default": False,
|
|
489
|
-
"help": "
|
|
493
|
+
"help": "Allow empty commit messages, which typically abort a commit.",
|
|
490
494
|
},
|
|
491
495
|
{
|
|
492
496
|
"name": ["--allowed-prefixes"],
|
|
493
497
|
"nargs": "*",
|
|
494
|
-
"help": "
|
|
495
|
-
"If the message starts by one of these prefixes, "
|
|
496
|
-
"the message won't be checked against the regex",
|
|
498
|
+
"help": "Skip validation for commit messages that start with the specified prefixes.",
|
|
497
499
|
},
|
|
498
500
|
{
|
|
499
501
|
"name": ["-l", "--message-length-limit"],
|
|
500
502
|
"type": int,
|
|
501
|
-
"help": "length
|
|
503
|
+
"help": "Restrict the length of the **first line** of the commit message; 0 for no limit.",
|
|
502
504
|
},
|
|
503
505
|
],
|
|
504
506
|
},
|
|
505
507
|
{
|
|
506
508
|
"name": ["version"],
|
|
507
509
|
"description": (
|
|
508
|
-
"
|
|
509
|
-
" (default: installed commitizen)"
|
|
510
|
+
"Get the version of the installed commitizen or the current project (default: installed commitizen)"
|
|
510
511
|
),
|
|
511
512
|
"help": (
|
|
512
|
-
"
|
|
513
|
-
" (default: installed commitizen)"
|
|
513
|
+
"Get the version of the installed commitizen or the current project (default: installed commitizen)."
|
|
514
514
|
),
|
|
515
515
|
"func": commands.Version,
|
|
516
516
|
"arguments": [
|
|
517
517
|
{
|
|
518
518
|
"name": ["-r", "--report"],
|
|
519
|
-
"help": "
|
|
519
|
+
"help": "Output the system information for reporting bugs.",
|
|
520
520
|
"action": "store_true",
|
|
521
521
|
"exclusive_group": "group1",
|
|
522
522
|
},
|
|
523
523
|
{
|
|
524
524
|
"name": ["-p", "--project"],
|
|
525
|
-
"help": "
|
|
525
|
+
"help": "Output the version of the current project.",
|
|
526
526
|
"action": "store_true",
|
|
527
527
|
"exclusive_group": "group1",
|
|
528
528
|
},
|
|
529
529
|
{
|
|
530
530
|
"name": ["-c", "--commitizen"],
|
|
531
|
-
"help": "
|
|
531
|
+
"help": "Output the version of the installed commitizen.",
|
|
532
532
|
"action": "store_true",
|
|
533
533
|
"exclusive_group": "group1",
|
|
534
534
|
},
|
|
535
535
|
{
|
|
536
536
|
"name": ["-v", "--verbose"],
|
|
537
537
|
"help": (
|
|
538
|
-
"
|
|
539
|
-
"and the current project"
|
|
538
|
+
"Output the version of both the installed commitizen and the current project."
|
|
540
539
|
),
|
|
541
540
|
"action": "store_true",
|
|
542
541
|
"exclusive_group": "group1",
|
|
543
542
|
},
|
|
544
543
|
{
|
|
545
544
|
"name": ["--major"],
|
|
546
|
-
"help": "
|
|
545
|
+
"help": "Output just the major version. Must be used with --project or --verbose.",
|
|
547
546
|
"action": "store_true",
|
|
548
547
|
"exclusive_group": "group2",
|
|
549
548
|
},
|
|
550
549
|
{
|
|
551
550
|
"name": ["--minor"],
|
|
552
|
-
"help": "
|
|
551
|
+
"help": "Output just the minor version. Must be used with --project or --verbose.",
|
|
552
|
+
"action": "store_true",
|
|
553
|
+
"exclusive_group": "group2",
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
"name": ["--tag"],
|
|
557
|
+
"help": "get the version with tag prefix. Need to be used with --project or --verbose.",
|
|
553
558
|
"action": "store_true",
|
|
554
559
|
"exclusive_group": "group2",
|
|
555
560
|
},
|
|
@@ -673,7 +678,7 @@ def main() -> None:
|
|
|
673
678
|
if args.name:
|
|
674
679
|
conf.update({"name": args.name})
|
|
675
680
|
elif not conf.path:
|
|
676
|
-
conf.update({"name": "
|
|
681
|
+
conf.update({"name": DEFAULT_SETTINGS["name"]})
|
|
677
682
|
|
|
678
683
|
if args.debug:
|
|
679
684
|
logging.getLogger("commitizen").setLevel(logging.DEBUG)
|
commitizen/commands/bump.py
CHANGED
|
@@ -49,6 +49,7 @@ class BumpArgs(Settings, total=False):
|
|
|
49
49
|
dry_run: bool
|
|
50
50
|
file_name: str
|
|
51
51
|
files_only: bool | None
|
|
52
|
+
version_files_only: bool | None
|
|
52
53
|
get_next: bool # TODO: maybe rename to `next_version_to_stdout`
|
|
53
54
|
git_output_to_stderr: bool
|
|
54
55
|
increment_mode: str
|
|
@@ -306,6 +307,7 @@ class Bump:
|
|
|
306
307
|
)
|
|
307
308
|
|
|
308
309
|
updated_files: list[str] = []
|
|
310
|
+
changelog_file_name = None
|
|
309
311
|
dry_run = self.arguments["dry_run"]
|
|
310
312
|
if self.changelog_flag:
|
|
311
313
|
changelog_args = {
|
|
@@ -318,12 +320,11 @@ class Bump:
|
|
|
318
320
|
"during_version_bump": self.arguments["prerelease"] is None,
|
|
319
321
|
}
|
|
320
322
|
if self.changelog_to_stdout:
|
|
321
|
-
changelog_cmd = Changelog(
|
|
322
|
-
self.config,
|
|
323
|
-
{**changelog_args, "dry_run": True}, # type: ignore[typeddict-item]
|
|
324
|
-
)
|
|
325
323
|
try:
|
|
326
|
-
|
|
324
|
+
Changelog(
|
|
325
|
+
self.config,
|
|
326
|
+
{**changelog_args, "dry_run": True}, # type: ignore[typeddict-item]
|
|
327
|
+
)()
|
|
327
328
|
except DryRunExit:
|
|
328
329
|
pass
|
|
329
330
|
|
|
@@ -332,7 +333,8 @@ class Bump:
|
|
|
332
333
|
{**changelog_args, "file_name": self.file_name}, # type: ignore[typeddict-item]
|
|
333
334
|
)
|
|
334
335
|
changelog_cmd()
|
|
335
|
-
|
|
336
|
+
changelog_file_name = changelog_cmd.file_name
|
|
337
|
+
updated_files.append(changelog_file_name)
|
|
336
338
|
|
|
337
339
|
# Do not perform operations over files or git.
|
|
338
340
|
if dry_run:
|
|
@@ -361,12 +363,17 @@ class Bump:
|
|
|
361
363
|
new_tag_version=new_tag_version,
|
|
362
364
|
message=message,
|
|
363
365
|
increment=increment,
|
|
364
|
-
changelog_file_name=
|
|
365
|
-
if self.changelog_flag
|
|
366
|
-
else None,
|
|
366
|
+
changelog_file_name=changelog_file_name,
|
|
367
367
|
)
|
|
368
368
|
|
|
369
|
-
if self.arguments
|
|
369
|
+
if self.arguments.get("files_only"):
|
|
370
|
+
warnings.warn(
|
|
371
|
+
"--files-only is deprecated and will be removed in v5. Use --version-files-only instead.",
|
|
372
|
+
DeprecationWarning,
|
|
373
|
+
)
|
|
374
|
+
raise ExpectedExit()
|
|
375
|
+
|
|
376
|
+
if self.arguments.get("version_files_only"):
|
|
370
377
|
raise ExpectedExit()
|
|
371
378
|
|
|
372
379
|
# FIXME: check if any changes have been staged
|
|
@@ -419,9 +426,7 @@ class Bump:
|
|
|
419
426
|
current_tag_version=new_tag_version,
|
|
420
427
|
message=message,
|
|
421
428
|
increment=increment,
|
|
422
|
-
changelog_file_name=
|
|
423
|
-
if self.changelog_flag
|
|
424
|
-
else None,
|
|
429
|
+
changelog_file_name=changelog_file_name,
|
|
425
430
|
)
|
|
426
431
|
|
|
427
432
|
# TODO: For v3 output this only as diagnostic and remove this if
|
commitizen/commands/check.py
CHANGED
|
@@ -20,7 +20,7 @@ class CheckArgs(TypedDict, total=False):
|
|
|
20
20
|
commit_msg: str
|
|
21
21
|
rev_range: str
|
|
22
22
|
allow_abort: bool
|
|
23
|
-
message_length_limit: int
|
|
23
|
+
message_length_limit: int
|
|
24
24
|
allowed_prefixes: list[str]
|
|
25
25
|
message: str
|
|
26
26
|
use_default_range: bool
|
|
@@ -46,7 +46,7 @@ class Check:
|
|
|
46
46
|
|
|
47
47
|
self.use_default_range = bool(arguments.get("use_default_range"))
|
|
48
48
|
self.max_msg_length = arguments.get(
|
|
49
|
-
"message_length_limit", config.settings.get("message_length_limit",
|
|
49
|
+
"message_length_limit", config.settings.get("message_length_limit", 0)
|
|
50
50
|
)
|
|
51
51
|
|
|
52
52
|
# we need to distinguish between None and [], which is a valid value
|
commitizen/commands/commit.py
CHANGED
|
@@ -36,7 +36,7 @@ class CommitArgs(TypedDict, total=False):
|
|
|
36
36
|
dry_run: bool
|
|
37
37
|
edit: bool
|
|
38
38
|
extra_cli_args: str
|
|
39
|
-
message_length_limit: int
|
|
39
|
+
message_length_limit: int
|
|
40
40
|
no_retry: bool
|
|
41
41
|
signoff: bool
|
|
42
42
|
write_message_to_file: Path | None
|
|
@@ -83,19 +83,23 @@ class Commit:
|
|
|
83
83
|
raise NoAnswersError()
|
|
84
84
|
|
|
85
85
|
message = self.cz.message(answers)
|
|
86
|
-
|
|
87
|
-
"message_length_limit", self.config.settings.get("message_length_limit", 0)
|
|
88
|
-
):
|
|
89
|
-
self._validate_subject_length(message=message, length_limit=limit)
|
|
90
|
-
|
|
86
|
+
self._validate_subject_length(message)
|
|
91
87
|
return message
|
|
92
88
|
|
|
93
|
-
def _validate_subject_length(self,
|
|
89
|
+
def _validate_subject_length(self, message: str) -> None:
|
|
90
|
+
message_length_limit = self.arguments.get(
|
|
91
|
+
"message_length_limit", self.config.settings.get("message_length_limit", 0)
|
|
92
|
+
)
|
|
94
93
|
# By the contract, message_length_limit is set to 0 for no limit
|
|
94
|
+
if (
|
|
95
|
+
message_length_limit is None or message_length_limit <= 0
|
|
96
|
+
): # do nothing for no limit
|
|
97
|
+
return
|
|
98
|
+
|
|
95
99
|
subject = message.partition("\n")[0].strip()
|
|
96
|
-
if len(subject) >
|
|
100
|
+
if len(subject) > message_length_limit:
|
|
97
101
|
raise CommitMessageLengthExceededError(
|
|
98
|
-
f"Length of commit message exceeds limit ({len(subject)}/{
|
|
102
|
+
f"Length of commit message exceeds limit ({len(subject)}/{message_length_limit}), subject: '{subject}'"
|
|
99
103
|
)
|
|
100
104
|
|
|
101
105
|
def manual_edit(self, message: str) -> str:
|
commitizen/commands/init.py
CHANGED
|
@@ -11,7 +11,11 @@ from commitizen.__version__ import __version__
|
|
|
11
11
|
from commitizen.config.factory import create_config
|
|
12
12
|
from commitizen.cz import registry
|
|
13
13
|
from commitizen.defaults import CONFIG_FILES, DEFAULT_SETTINGS
|
|
14
|
-
from commitizen.exceptions import
|
|
14
|
+
from commitizen.exceptions import (
|
|
15
|
+
InitFailedError,
|
|
16
|
+
MissingCzCustomizeConfigError,
|
|
17
|
+
NoAnswersError,
|
|
18
|
+
)
|
|
15
19
|
from commitizen.git import get_latest_tag_name, get_tag_names, smart_open
|
|
16
20
|
from commitizen.version_schemes import KNOWN_SCHEMES, Version, get_version_scheme
|
|
17
21
|
|
|
@@ -166,13 +170,29 @@ class Init:
|
|
|
166
170
|
|
|
167
171
|
def _ask_name(self) -> str:
|
|
168
172
|
name: str = questionary.select(
|
|
169
|
-
"Please choose a cz (commit rule): (default:
|
|
170
|
-
choices=
|
|
171
|
-
default="
|
|
173
|
+
f"Please choose a cz (commit rule): (default: {DEFAULT_SETTINGS['name']})",
|
|
174
|
+
choices=self._construct_name_choice_with_description(),
|
|
175
|
+
default=DEFAULT_SETTINGS["name"],
|
|
172
176
|
style=self.cz.style,
|
|
173
177
|
).unsafe_ask()
|
|
174
178
|
return name
|
|
175
179
|
|
|
180
|
+
def _construct_name_choice_with_description(self) -> list[questionary.Choice]:
|
|
181
|
+
choices = []
|
|
182
|
+
for cz_name, cz_class in registry.items():
|
|
183
|
+
try:
|
|
184
|
+
cz_obj = cz_class(self.config)
|
|
185
|
+
except MissingCzCustomizeConfigError:
|
|
186
|
+
choices.append(questionary.Choice(title=cz_name, value=cz_name))
|
|
187
|
+
continue
|
|
188
|
+
first_example = cz_obj.schema().partition("\n")[0]
|
|
189
|
+
choices.append(
|
|
190
|
+
questionary.Choice(
|
|
191
|
+
title=cz_name, value=cz_name, description=first_example
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
return choices
|
|
195
|
+
|
|
176
196
|
def _ask_tag(self) -> str:
|
|
177
197
|
latest_tag = get_latest_tag_name()
|
|
178
198
|
if not latest_tag:
|
commitizen/commands/version.py
CHANGED
|
@@ -7,6 +7,7 @@ from commitizen.__version__ import __version__
|
|
|
7
7
|
from commitizen.config import BaseConfig
|
|
8
8
|
from commitizen.exceptions import NoVersionSpecifiedError, VersionSchemeUnknown
|
|
9
9
|
from commitizen.providers import get_provider
|
|
10
|
+
from commitizen.tags import TagRules
|
|
10
11
|
from commitizen.version_schemes import get_version_scheme
|
|
11
12
|
|
|
12
13
|
|
|
@@ -17,6 +18,7 @@ class VersionArgs(TypedDict, total=False):
|
|
|
17
18
|
verbose: bool
|
|
18
19
|
major: bool
|
|
19
20
|
minor: bool
|
|
21
|
+
tag: bool
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
class Version:
|
|
@@ -59,6 +61,9 @@ class Version:
|
|
|
59
61
|
version = f"{version_scheme.major}"
|
|
60
62
|
elif self.arguments.get("minor"):
|
|
61
63
|
version = f"{version_scheme.minor}"
|
|
64
|
+
elif self.arguments.get("tag"):
|
|
65
|
+
tag_rules = TagRules.from_settings(self.config.settings)
|
|
66
|
+
version = tag_rules.normalize_tag(version_scheme)
|
|
62
67
|
|
|
63
68
|
out.write(
|
|
64
69
|
f"Project Version: {version}"
|
|
@@ -73,5 +78,9 @@ class Version:
|
|
|
73
78
|
)
|
|
74
79
|
return
|
|
75
80
|
|
|
81
|
+
if self.arguments.get("tag"):
|
|
82
|
+
out.error("Tag can only be used with --project or --verbose.")
|
|
83
|
+
return
|
|
84
|
+
|
|
76
85
|
# If no arguments are provided, just show the installed commitizen version
|
|
77
86
|
out.write(__version__)
|
commitizen/config/__init__.py
CHANGED
|
@@ -9,21 +9,21 @@ from commitizen.exceptions import ConfigFileIsEmpty, ConfigFileNotFound
|
|
|
9
9
|
from .base_config import BaseConfig
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def
|
|
12
|
+
def _resolve_config_candidates() -> list[BaseConfig]:
|
|
13
13
|
git_project_root = git.find_git_project_root()
|
|
14
14
|
cfg_search_paths = [Path(".")]
|
|
15
15
|
|
|
16
|
-
if git_project_root and
|
|
16
|
+
if git_project_root and cfg_search_paths[0].resolve() != git_project_root.resolve():
|
|
17
17
|
cfg_search_paths.append(git_project_root)
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
# Also, the number of possible config files is limited, so the complexity is not a problem.
|
|
21
|
-
candidates: list[Path] = []
|
|
19
|
+
candidates: list[BaseConfig] = []
|
|
22
20
|
for dir in cfg_search_paths:
|
|
23
21
|
for filename in defaults.CONFIG_FILES:
|
|
24
|
-
out_path = dir /
|
|
25
|
-
if out_path.
|
|
26
|
-
|
|
22
|
+
out_path = dir / filename
|
|
23
|
+
if out_path.is_file():
|
|
24
|
+
conf = _create_config_from_path(out_path)
|
|
25
|
+
if conf.contains_commitizen_section():
|
|
26
|
+
candidates.append(conf)
|
|
27
27
|
return candidates
|
|
28
28
|
|
|
29
29
|
|
|
@@ -37,28 +37,18 @@ def _create_config_from_path(path: Path) -> BaseConfig:
|
|
|
37
37
|
def read_cfg(filepath: str | None = None) -> BaseConfig:
|
|
38
38
|
if filepath is not None:
|
|
39
39
|
conf_path = Path(filepath)
|
|
40
|
-
if not conf_path.
|
|
40
|
+
if not conf_path.is_file():
|
|
41
41
|
raise ConfigFileNotFound()
|
|
42
42
|
conf = _create_config_from_path(conf_path)
|
|
43
|
-
if conf.
|
|
43
|
+
if not conf.contains_commitizen_section():
|
|
44
44
|
raise ConfigFileIsEmpty()
|
|
45
45
|
return conf
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
config_candidates = _resolve_config_candidates()
|
|
48
|
+
if len(config_candidates) > 1:
|
|
49
|
+
out.warn(
|
|
50
|
+
f"Multiple config files detected: {', '.join(str(conf.path) for conf in config_candidates)}. "
|
|
51
|
+
f"Using config file: '{config_candidates[0].path}'."
|
|
52
|
+
)
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
config_candidates_exclude_pyproject = [
|
|
51
|
-
path for path in config_candidate_paths if path.name != "pyproject.toml"
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
for config_candidate_path in config_candidate_paths:
|
|
55
|
-
conf = _create_config_from_path(config_candidate_path)
|
|
56
|
-
if not conf.is_empty_config:
|
|
57
|
-
if len(config_candidates_exclude_pyproject) > 1:
|
|
58
|
-
out.warn(
|
|
59
|
-
f"Multiple config files detected: {', '.join(map(str, config_candidates_exclude_pyproject))}. "
|
|
60
|
-
f"Using config file: '{config_candidate_path}'."
|
|
61
|
-
)
|
|
62
|
-
return conf
|
|
63
|
-
|
|
64
|
-
return BaseConfig()
|
|
54
|
+
return config_candidates[0] if config_candidates else BaseConfig()
|
commitizen/config/base_config.py
CHANGED
|
@@ -17,10 +17,16 @@ if TYPE_CHECKING:
|
|
|
17
17
|
|
|
18
18
|
class BaseConfig:
|
|
19
19
|
def __init__(self) -> None:
|
|
20
|
-
self.is_empty_config = False
|
|
21
20
|
self._settings: Settings = DEFAULT_SETTINGS.copy()
|
|
22
21
|
self._path: Path | None = None
|
|
23
22
|
|
|
23
|
+
def contains_commitizen_section(self) -> bool:
|
|
24
|
+
"""Check if the config file contains a commitizen section.
|
|
25
|
+
|
|
26
|
+
The implementation is different for each config file type.
|
|
27
|
+
"""
|
|
28
|
+
raise NotImplementedError()
|
|
29
|
+
|
|
24
30
|
@property
|
|
25
31
|
def settings(self) -> Settings:
|
|
26
32
|
return self._settings
|
commitizen/config/json_config.py
CHANGED
|
@@ -25,6 +25,11 @@ class JsonConfig(BaseConfig):
|
|
|
25
25
|
self.path = path
|
|
26
26
|
self._parse_setting(data)
|
|
27
27
|
|
|
28
|
+
def contains_commitizen_section(self) -> bool:
|
|
29
|
+
with self.path.open("rb") as json_file:
|
|
30
|
+
config_doc = json.load(json_file)
|
|
31
|
+
return config_doc.get("commitizen") is not None
|
|
32
|
+
|
|
28
33
|
def init_empty_config_content(self) -> None:
|
|
29
34
|
with smart_open(
|
|
30
35
|
self.path, "a", encoding=self._settings["encoding"]
|
|
@@ -32,7 +37,7 @@ class JsonConfig(BaseConfig):
|
|
|
32
37
|
json.dump({"commitizen": {}}, json_file)
|
|
33
38
|
|
|
34
39
|
def set_key(self, key: str, value: object) -> Self:
|
|
35
|
-
with
|
|
40
|
+
with self.path.open("rb") as f:
|
|
36
41
|
config_doc = json.load(f)
|
|
37
42
|
|
|
38
43
|
config_doc["commitizen"][key] = value
|
|
@@ -59,4 +64,4 @@ class JsonConfig(BaseConfig):
|
|
|
59
64
|
try:
|
|
60
65
|
self.settings.update(doc["commitizen"])
|
|
61
66
|
except KeyError:
|
|
62
|
-
|
|
67
|
+
pass
|
commitizen/config/toml_config.py
CHANGED
|
@@ -26,6 +26,11 @@ class TomlConfig(BaseConfig):
|
|
|
26
26
|
self.path = path
|
|
27
27
|
self._parse_setting(data)
|
|
28
28
|
|
|
29
|
+
def contains_commitizen_section(self) -> bool:
|
|
30
|
+
with self.path.open("rb") as f:
|
|
31
|
+
config_doc = parse(f.read())
|
|
32
|
+
return config_doc.get("tool", {}).get("commitizen") is not None
|
|
33
|
+
|
|
29
34
|
def init_empty_config_content(self) -> None:
|
|
30
35
|
config_doc = TOMLDocument()
|
|
31
36
|
if os.path.isfile(self.path):
|
|
@@ -67,4 +72,4 @@ class TomlConfig(BaseConfig):
|
|
|
67
72
|
try:
|
|
68
73
|
self.settings.update(doc["tool"]["commitizen"]) # type: ignore[index,typeddict-item] # TODO: fix this
|
|
69
74
|
except exceptions.NonExistentKey:
|
|
70
|
-
|
|
75
|
+
pass
|
commitizen/config/yaml_config.py
CHANGED
|
@@ -32,6 +32,11 @@ class YAMLConfig(BaseConfig):
|
|
|
32
32
|
) as json_file:
|
|
33
33
|
yaml.dump({"commitizen": {}}, json_file, explicit_start=True)
|
|
34
34
|
|
|
35
|
+
def contains_commitizen_section(self) -> bool:
|
|
36
|
+
with self.path.open("rb") as yaml_file:
|
|
37
|
+
config_doc = yaml.load(yaml_file, Loader=yaml.FullLoader)
|
|
38
|
+
return config_doc.get("commitizen") is not None
|
|
39
|
+
|
|
35
40
|
def _parse_setting(self, data: bytes | str) -> None:
|
|
36
41
|
"""We expect to have a section in cz.yaml looking like
|
|
37
42
|
|
|
@@ -40,8 +45,6 @@ class YAMLConfig(BaseConfig):
|
|
|
40
45
|
name: cz_conventional_commits
|
|
41
46
|
```
|
|
42
47
|
"""
|
|
43
|
-
import yaml.scanner
|
|
44
|
-
|
|
45
48
|
try:
|
|
46
49
|
doc = yaml.safe_load(data)
|
|
47
50
|
except yaml.YAMLError as e:
|
|
@@ -50,7 +53,7 @@ class YAMLConfig(BaseConfig):
|
|
|
50
53
|
try:
|
|
51
54
|
self.settings.update(doc["commitizen"])
|
|
52
55
|
except (KeyError, TypeError):
|
|
53
|
-
|
|
56
|
+
pass
|
|
54
57
|
|
|
55
58
|
def set_key(self, key: str, value: object) -> Self:
|
|
56
59
|
with open(self.path, "rb") as yaml_file:
|
commitizen/cz/base.py
CHANGED
|
@@ -130,7 +130,7 @@ class BaseCommitizen(metaclass=ABCMeta):
|
|
|
130
130
|
if any(map(commit_msg.startswith, allowed_prefixes)):
|
|
131
131
|
return ValidationResult(True, [])
|
|
132
132
|
|
|
133
|
-
if max_msg_length is not None:
|
|
133
|
+
if max_msg_length is not None and max_msg_length > 0:
|
|
134
134
|
msg_len = len(commit_msg.partition("\n")[0].strip())
|
|
135
135
|
if msg_len > max_msg_length:
|
|
136
136
|
# TODO: capitalize the first letter of the error message for consistency in v5
|
commitizen/defaults.py
CHANGED
|
@@ -48,7 +48,7 @@ class Settings(TypedDict, total=False):
|
|
|
48
48
|
ignored_tag_formats: Sequence[str]
|
|
49
49
|
legacy_tag_formats: Sequence[str]
|
|
50
50
|
major_version_zero: bool
|
|
51
|
-
message_length_limit: int
|
|
51
|
+
message_length_limit: int
|
|
52
52
|
name: str
|
|
53
53
|
post_bump_hooks: list[str] | None
|
|
54
54
|
pre_bump_hooks: list[str] | None
|
|
@@ -114,7 +114,7 @@ DEFAULT_SETTINGS: Settings = {
|
|
|
114
114
|
"template": None, # default provided by plugin
|
|
115
115
|
"extras": {},
|
|
116
116
|
"breaking_change_exclamation_in_title": False,
|
|
117
|
-
"message_length_limit":
|
|
117
|
+
"message_length_limit": 0, # 0 for no limit
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
MAJOR = "MAJOR"
|
commitizen/tags.py
CHANGED
|
@@ -228,7 +228,7 @@ class TagRules:
|
|
|
228
228
|
version = self.scheme(version) if isinstance(version, str) else version
|
|
229
229
|
tag_format = tag_format or self.tag_format
|
|
230
230
|
|
|
231
|
-
major, minor, patch = version.release
|
|
231
|
+
major, minor, patch = (list(version.release) + [0, 0, 0])[:3]
|
|
232
232
|
prerelease = version.prerelease or ""
|
|
233
233
|
|
|
234
234
|
t = Template(tag_format)
|
|
@@ -245,6 +245,25 @@ class TagRules:
|
|
|
245
245
|
) -> GitTag | None:
|
|
246
246
|
"""Find the first matching tag for a given version."""
|
|
247
247
|
version = self.scheme(version) if isinstance(version, str) else version
|
|
248
|
+
release = version.release
|
|
249
|
+
|
|
250
|
+
# If the requested version is incomplete (e.g., "1.2"), try to find the latest
|
|
251
|
+
# matching tag that shares the provided prefix.
|
|
252
|
+
if len(release) < 3:
|
|
253
|
+
matching_versions: list[tuple[Version, GitTag]] = []
|
|
254
|
+
for tag in tags:
|
|
255
|
+
try:
|
|
256
|
+
tag_version = self.extract_version(tag)
|
|
257
|
+
except InvalidVersion:
|
|
258
|
+
continue
|
|
259
|
+
if tag_version.release[: len(release)] != release:
|
|
260
|
+
continue
|
|
261
|
+
matching_versions.append((tag_version, tag))
|
|
262
|
+
|
|
263
|
+
if matching_versions:
|
|
264
|
+
_, latest_tag = max(matching_versions, key=lambda vt: vt[0])
|
|
265
|
+
return latest_tag
|
|
266
|
+
|
|
248
267
|
possible_tags = set(self.normalize_tag(version, f) for f in self.tag_formats)
|
|
249
268
|
candidates = [t for t in tags if t.name in possible_tags]
|
|
250
269
|
if len(candidates) > 1:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: commitizen
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.13.1
|
|
4
4
|
Summary: Python commitizen client tool
|
|
5
5
|
Keywords: commitizen,conventional,commits,git
|
|
6
6
|
Author: Santiago Fraire
|
|
@@ -369,6 +369,11 @@ After installation, you can verify the completion is working by:
|
|
|
369
369
|
|
|
370
370
|
For more detailed information about argcomplete configuration and troubleshooting, visit the [argcomplete documentation](https://kislyuk.github.io/argcomplete/).
|
|
371
371
|
|
|
372
|
+
## Star History
|
|
373
|
+
|
|
374
|
+
[](https://star-history.com/#commitizen-tools/commitizen)
|
|
375
|
+
|
|
376
|
+
|
|
372
377
|
## Sponsors
|
|
373
378
|
|
|
374
379
|
These are our cool sponsors!
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
commitizen/__init__.py,sha256=oOBG9f3DtTPmFnqXnwvuh1XIw9kqf_-cyrFYlRaZ1fQ,593
|
|
2
2
|
commitizen/__main__.py,sha256=ythPim4R6rgC0zU9siklq1oSbkk2HlbiNpwwoegk8uE,71
|
|
3
|
-
commitizen/__version__.py,sha256=
|
|
3
|
+
commitizen/__version__.py,sha256=eI5KkHEFD5jz0OTYWOVaCxYxX1UbP8_xHAIvX8O5ugE,23
|
|
4
4
|
commitizen/bump.py,sha256=-C09y5sAlVPyWTbEgqZimQMlz6LL248Ht2Pv90Ks6Dg,4692
|
|
5
5
|
commitizen/changelog.py,sha256=ydaFUSHUBPpdNjw_yoPJ1_pr3AAr9rHS-NwP8gQDIUA,11278
|
|
6
|
-
commitizen/changelog_formats/__init__.py,sha256=
|
|
6
|
+
commitizen/changelog_formats/__init__.py,sha256=ZkxdmGybxWTzQZbt5KTJdAdbdKx0-v3aXtNDC-efRQk,3369
|
|
7
7
|
commitizen/changelog_formats/asciidoc.py,sha256=yBhD_dy4TLKuVdU0Ug1WHKhfQfwXz9P7kgoRuivLefk,754
|
|
8
8
|
commitizen/changelog_formats/base.py,sha256=bL26Ykr3G-hSoPYCL5sz3SI3WttdvF55CiCeZDWUUew,4393
|
|
9
9
|
commitizen/changelog_formats/markdown.py,sha256=4eAO9XmNGVQxJsIAY7be_V19gEP4xSKN71ScEv2cRBg,725
|
|
10
10
|
commitizen/changelog_formats/restructuredtext.py,sha256=Dsm6DSxqYWRgybhnRedCN-X8Sg8o1PbzKTPg4hZqOI8,2893
|
|
11
11
|
commitizen/changelog_formats/textile.py,sha256=0GiY3c5P6kFWgtruHbr2HnLTLw8F9HDKkz5IUvF8zsU,656
|
|
12
|
-
commitizen/cli.py,sha256=
|
|
12
|
+
commitizen/cli.py,sha256=pr7q8oKPScuL2Wc21L7jWZ2assGX-zpKiL9TJt8Ox9o,28036
|
|
13
13
|
commitizen/cmd.py,sha256=Qmebgl6cjS6c-x83N0OwG1tXH636bFPn074Ef-3RGAY,1306
|
|
14
14
|
commitizen/commands/__init__.py,sha256=gdk5ehql39YCuUZ03HdXWAJhRUwTe0J4A74S1K5K7Fo,420
|
|
15
|
-
commitizen/commands/bump.py,sha256=
|
|
15
|
+
commitizen/commands/bump.py,sha256=qx9w_X38jpMoZ3rWpujLGhfSnfprn4aYqunPwBN6n0U,16672
|
|
16
16
|
commitizen/commands/changelog.py,sha256=t5eQluMCig4v7YEha6pHOpZQG-Kqp4igB9QgnduQIvE,10532
|
|
17
|
-
commitizen/commands/check.py,sha256=
|
|
18
|
-
commitizen/commands/commit.py,sha256=
|
|
17
|
+
commitizen/commands/check.py,sha256=F5ufrRrUecr6U-vsYyfaWkHtsFb7L3nd0-oN5c5GT1M,5506
|
|
18
|
+
commitizen/commands/commit.py,sha256=PB0SefK_ukZSWpBNuu0ZIE02ZQaniqEnqxbTOvJU2Mg,6497
|
|
19
19
|
commitizen/commands/example.py,sha256=-pWBjDA2I-dtAHickbkeis08xnFSuBxM2YLBm_Hm0sY,389
|
|
20
20
|
commitizen/commands/info.py,sha256=P009ymylWiwr02p-swky7v1QXZTeOf2wT7jdHkZXAgg,375
|
|
21
|
-
commitizen/commands/init.py,sha256=
|
|
21
|
+
commitizen/commands/init.py,sha256=doLc-Y_o89S-64j-c7P4_ID0EiaAkhhe5veZpH8V8Ew,12283
|
|
22
22
|
commitizen/commands/list_cz.py,sha256=0eCGpRLn5v7XLNWiMkA14QN260fyR6gzoDvAM2mq-IM,349
|
|
23
23
|
commitizen/commands/schema.py,sha256=66m_xCjAsUS7_a2Q_dx-CCiHJ6UXG8RJVUeLO_pl2gU,366
|
|
24
|
-
commitizen/commands/version.py,sha256=
|
|
25
|
-
commitizen/config/__init__.py,sha256=
|
|
26
|
-
commitizen/config/base_config.py,sha256=
|
|
24
|
+
commitizen/commands/version.py,sha256=X_Hrjb_48hBGTN3J8dD3_kveLvaPBlnQarw96Koag20,2868
|
|
25
|
+
commitizen/config/__init__.py,sha256=aMfdqszk20Rm9Y5W9G3ZE_FGA5d4tcKK2xdRSgtZ8sI,1806
|
|
26
|
+
commitizen/config/base_config.py,sha256=mWb39DMd5J7yn2Nj-6ZFbUZeR4Tapr06KPvyMXRenhE,1659
|
|
27
27
|
commitizen/config/factory.py,sha256=-6TcsKLGVJ1Tw1nkRVv5aAfS4JvxY6V2QLirNL8Ly8M,839
|
|
28
|
-
commitizen/config/json_config.py,sha256=
|
|
29
|
-
commitizen/config/toml_config.py,sha256=
|
|
30
|
-
commitizen/config/yaml_config.py,sha256=
|
|
28
|
+
commitizen/config/json_config.py,sha256=fyMFxZIvQcKNSJUa56kus9vhXQKoA5MTWl9FZY1KyvU,1948
|
|
29
|
+
commitizen/config/toml_config.py,sha256=aoT6nsTSv2AEQdbKfqNOL7sj78hr9QESdX9BxHgipzY,2395
|
|
30
|
+
commitizen/config/yaml_config.py,sha256=hmH0_DU-lpbtmFJU5cMirNt2WAr3oBuqkMAbIKy5oU8,2043
|
|
31
31
|
commitizen/cz/__init__.py,sha256=45-VfzHalISUDcpkrfGLVvBRoTdAtdTf3-CmuOqBaus,1311
|
|
32
|
-
commitizen/cz/base.py,sha256=
|
|
32
|
+
commitizen/cz/base.py,sha256=w2VeKICv59VBgOxpRB8VaXN5LoJRop_P6mDDkrTsQe0,5540
|
|
33
33
|
commitizen/cz/conventional_commits/__init__.py,sha256=GZHCs25rv1p1dp4BNczL5FU_pPdENazF8yso_Ca2sQQ,70
|
|
34
34
|
commitizen/cz/conventional_commits/conventional_commits.py,sha256=dmT3vsMN0LIzhih4-6-EmJ5HYFM-ZLrIoJwukWbpS0s,7483
|
|
35
35
|
commitizen/cz/conventional_commits/conventional_commits_info.txt,sha256=FqhncEblZC1IYYW7MXhOkA_YOvgO8a1F8-kWSNHVOi8,1285
|
|
@@ -41,7 +41,7 @@ commitizen/cz/jira/__init__.py,sha256=9zcifxnhAjTuPiWXLmh_QhC2Lb7hwyxgtE90QhPP7e
|
|
|
41
41
|
commitizen/cz/jira/jira.py,sha256=IrkU0hewlSiK2tdkgDRV5AHluX-kYHAMnJIBWQA1cxQ,2647
|
|
42
42
|
commitizen/cz/jira/jira_info.txt,sha256=GVLlYhUvWJX-8ej_vVrR-lmcUqOBnb5XzkVQOZOzTqA,1940
|
|
43
43
|
commitizen/cz/utils.py,sha256=lx1xuIl0ZjZtcsvMKBLCz3JfKACwFmgb3F1WoRBRU6o,833
|
|
44
|
-
commitizen/defaults.py,sha256=
|
|
44
|
+
commitizen/defaults.py,sha256=MbLCKF4BP-WcxTj74DeKIf4ptj83ji_A3_y0FbkbsBM,5566
|
|
45
45
|
commitizen/exceptions.py,sha256=tvsugJSGQ7AuHocTEmhGgryrTJZ6e6jhBeTKo8nvaNo,7694
|
|
46
46
|
commitizen/factory.py,sha256=zz6QTr3jsbcTb4oOBWpKt_qgkysM7Q8Kel1lZSjsvkI,612
|
|
47
47
|
commitizen/git.py,sha256=BGqI5mW_N6GdJ3ExPqdik7YQK8ydKMZXts3F1LMriuk,9986
|
|
@@ -60,13 +60,13 @@ commitizen/providers/scm_provider.py,sha256=7c4rGqW99lVwyqZApRgHc-Upm-69mqd8uZ_s
|
|
|
60
60
|
commitizen/providers/uv_provider.py,sha256=MM0Ki2jO7ZvgP7g0TBI_BU86u6DTmUZAz3-f5mRovHM,1288
|
|
61
61
|
commitizen/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
62
62
|
commitizen/question.py,sha256=J6_fzWghr_irzpPUU5JUsIBgDHp4Adryx8XmZAo4Zj4,624
|
|
63
|
-
commitizen/tags.py,sha256=
|
|
63
|
+
commitizen/tags.py,sha256=bt6KDDpq4tB3sp1Cqbs_Qx0EtW8v7Jjmh1RGtMH-Wgw,10249
|
|
64
64
|
commitizen/templates/CHANGELOG.adoc.j2,sha256=LIJZ1vBl2ZFq0hbORMjWi0DJtuYC7S3t8RBuVJ6XZsY,403
|
|
65
65
|
commitizen/templates/CHANGELOG.md.j2,sha256=MggRrhbL3EabwsH8v0oFMM8G296ATBzePaqumBvW2kc,405
|
|
66
66
|
commitizen/templates/CHANGELOG.rst.j2,sha256=XHh4a7S83Z5Vrd_0UaLDA1Bb7A82Px4eHcbHsZGKYF8,515
|
|
67
67
|
commitizen/templates/CHANGELOG.textile.j2,sha256=8JxCcDdgQUmNPxXFEv5IpbP_vcfvYCo5CSicNCZmFCY,404
|
|
68
68
|
commitizen/version_schemes.py,sha256=NDyxMzJGK1NKkTgtJ4BNw_NgKxJhvK0EWWVhfqzzwHI,13460
|
|
69
|
-
commitizen-4.
|
|
70
|
-
commitizen-4.
|
|
71
|
-
commitizen-4.
|
|
72
|
-
commitizen-4.
|
|
69
|
+
commitizen-4.13.1.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
|
|
70
|
+
commitizen-4.13.1.dist-info/entry_points.txt,sha256=EpbOUAABRQCFhf2HFcmrJZLGsbB_MSJ-tFua-NxUCxE,1085
|
|
71
|
+
commitizen-4.13.1.dist-info/METADATA,sha256=IGoTkaDPxQujlMdF_uMmma7zPK804jSqdYXkytflhCE,13532
|
|
72
|
+
commitizen-4.13.1.dist-info/RECORD,,
|
|
File without changes
|