@@ -215,50 +215,42 @@ Inherit from `BaseCommitizen`, and you must define `questions` and `message`. Th
215
215
from commitizen.cz.base import BaseCommitizen
216
216
from commitizen.defaults import Questions
217
217
218
+
218
219
class JiraCz(BaseCommitizen):
219
220
# Questions = Iterable[MutableMapping[str, Any]]
220
221
# It expects a list with dictionaries.
221
222
def questions(self) -> Questions:
222
223
"""Questions regarding the commit message."""
223
224
questions = [
224
- {
225
- 'type': 'input',
226
- 'name': 'title',
227
- 'message': 'Commit title'
228
- },
229
- {
230
- 'type': 'input',
231
- 'name': 'issue',
232
- 'message': 'Jira Issue number:'
233
- },
225
+ {"type": "input", "name": "title", "message": "Commit title"},
226
+ {"type": "input", "name": "issue", "message": "Jira Issue number:"},
234
227
]
235
228
return questions
236
229
237
230
def message(self, answers: dict) -> str:
238
231
"""Generate the message with the given answers."""
239
- return ' {0} (#{1})' .format(answers[' title' ], answers[' issue' ])
232
+ return " {0} (#{1})" .format(answers[" title" ], answers[" issue" ])
240
233
241
234
def example(self) -> str:
242
235
"""Provide an example to help understand the style (OPTIONAL)
243
236
244
237
Used by ` cz example`.
245
238
" " "
246
- return ' Problem with user (#321)'
239
+ return " Problem with user (#321)"
247
240
248
241
def schema(self) -> str :
249
242
" " " Show the schema used (OPTIONAL)
250
243
251
244
Used by `cz schema`.
252
245
" " "
253
- return ' <title> (<issue>)'
246
+ return " <title> (<issue>)"
254
247
255
248
def info(self) -> str :
256
249
" " " Explanation of the commit rules. (OPTIONAL)
257
250
258
251
Used by `cz info`.
259
252
" " "
260
- return 'We use this because is useful'
261
-
253
+ return "We use this because is useful"
262
254
` ` `
263
255
264
256
The next file required is ` setup.py` modified from flask version.
@@ -267,17 +259,13 @@ The next file required is `setup.py` modified from flask version.
267
259
from setuptools import setup
268
260
269
261
setup(
270
- name='JiraCommitizen',
271
- version='0.1.0',
272
- py_modules=['cz_jira'],
273
- license='MIT',
274
- long_description='this is a long description',
275
- install_requires=['commitizen'],
276
- entry_points = {
277
- 'commitizen.plugin': [
278
- 'cz_jira = cz_jira:JiraCz'
279
- ]
280
- }
262
+ name="JiraCommitizen",
263
+ version="0.1.0",
264
+ py_modules=["cz_jira"],
265
+ license="MIT",
266
+ long_description="this is a long description",
267
+ install_requires=["commitizen"],
268
+ entry_points={"commitizen.plugin": ["cz_jira = cz_jira:JiraCz"]},
281
269
)
282
270
` ` `
283
271
@@ -338,23 +326,30 @@ from commitizen.cz.base import BaseCommitizen
338
326
import chat
339
327
import compliance
340
328
329
+
341
330
class StrangeCommitizen(BaseCommitizen):
342
331
changelog_pattern = r"^(break|new|fix|hotfix)"
343
332
commit_parser = r"^(?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\( (?P<scope>[^()\r\n ]*)\) |\( )?(?P<breaking>!)?:\s (?P<message>.*)?"
344
333
change_type_map = {
345
334
"feat": "Features",
346
335
"fix": "Bug Fixes",
347
336
"refactor": "Code Refactor",
348
- " perf" : " Performance improvements"
337
+ "perf": "Performance improvements",
349
338
}
350
339
351
- def changelog_message_builder_hook (self , parsed_message : dict , commit : git.GitCommit) -> dict :
340
+ def changelog_message_builder_hook(
341
+ self, parsed_message: dict, commit: git.GitCommit
342
+ ) -> dict:
352
343
rev = commit.rev
353
344
m = parsed_message["message"]
354
- parsed_message[" message" ] = f " { m} { rev} [ { commit.author} ]( { commit.author_email} ) "
345
+ parsed_message[
346
+ "message"
347
+ ] = f"{m} {rev} [{commit.author}]({commit.author_email})"
355
348
return parsed_message
356
349
357
- def changelog_hook (self , full_changelog : str , partial_changelog : Optional[str ]) -> str :
350
+ def changelog_hook(
351
+ self, full_changelog: str, partial_changelog: Optional[str]
352
+ ) -> str:
358
353
"""Executed at the end of the changelog generation
359
354
360
355
full_changelog: it's the output about to being written into the file
@@ -368,7 +363,7 @@ class StrangeCommitizen(BaseCommitizen):
368
363
chat.room("#committers").notify(partial_changelog)
369
364
if full_changelog:
370
365
compliance.send(full_changelog)
371
- full_changelog.replace(' fix ' , ' **fix** ' )
366
+ full_changelog.replace(" fix ", " **fix** " )
372
367
return full_changelog
373
368
` ` `
374
369
@@ -381,6 +376,7 @@ If you want `commitizen` to catch your exception and print the message, you'll h
381
376
` ` ` python
382
377
from commitizen.cz.exception import CzException
383
378
379
+
384
380
class NoSubjectProvidedException(CzException):
385
381
...
386
382
` ` `
@@ -402,9 +398,11 @@ If you were having a `CzPlugin` class in a `cz_plugin.py` module like this:
402
398
` ` ` python
403
399
from commitizen.cz.base import BaseCommitizen
404
400
401
+
405
402
class PluginCz(BaseCommitizen):
406
403
...
407
404
405
+
408
406
discover_this = PluginCz
409
407
` ` `
410
408
@@ -413,6 +411,7 @@ Then remove the `discover_this` line:
413
411
` ` ` python
414
412
from commitizen.cz.base import BaseCommitizen
415
413
414
+
416
415
class PluginCz(BaseCommitizen):
417
416
...
418
417
` ` `
@@ -423,16 +422,11 @@ and expose the class as entrypoint in you setuptools:
423
422
from setuptools import setup
424
423
425
424
setup(
426
- name = ' MyPlugin' ,
427
- version = ' 0.1.0' ,
428
- py_modules = [' cz_plugin' ],
429
- ...
430
- entry_points = {
431
- ' commitizen.plugin' : [
432
- ' plugin = cz_plugin:PluginCz'
433
- ]
434
- }
435
- ...
425
+ name="MyPlugin",
426
+ version="0.1.0",
427
+ py_modules=["cz_plugin"],
428
+ entry_points={"commitizen.plugin": ["plugin = cz_plugin:PluginCz"]},
429
+ ...,
436
430
)
437
431
` ` `
438
432
0 commit comments