@@ -215,50 +215,42 @@ Inherit from `BaseCommitizen`, and you must define `questions` and `message`. Th
215215from commitizen.cz.base import BaseCommitizen
216216from commitizen.defaults import Questions
217217
218+
218219class JiraCz(BaseCommitizen):
219220 # Questions = Iterable[MutableMapping[str, Any]]
220221 # It expects a list with dictionaries.
221222 def questions(self) -> Questions:
222223 """Questions regarding the commit message."""
223224 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:"},
234227 ]
235228 return questions
236229
237230 def message(self, answers: dict) -> str:
238231 """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" ])
240233
241234 def example(self) -> str:
242235 """Provide an example to help understand the style (OPTIONAL)
243236
244237 Used by ` cz example`.
245238 " " "
246- return ' Problem with user (#321)'
239+ return " Problem with user (#321)"
247240
248241 def schema(self) -> str :
249242 " " " Show the schema used (OPTIONAL)
250243
251244 Used by `cz schema`.
252245 " " "
253- return ' <title> (<issue>)'
246+ return " <title> (<issue>)"
254247
255248 def info(self) -> str :
256249 " " " Explanation of the commit rules. (OPTIONAL)
257250
258251 Used by `cz info`.
259252 " " "
260- return 'We use this because is useful'
261-
253+ return "We use this because is useful"
262254` ` `
263255
264256The 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.
267259from setuptools import setup
268260
269261setup(
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"]},
281269)
282270` ` `
283271
@@ -338,23 +326,30 @@ from commitizen.cz.base import BaseCommitizen
338326import chat
339327import compliance
340328
329+
341330class StrangeCommitizen(BaseCommitizen):
342331 changelog_pattern = r"^(break|new|fix|hotfix)"
343332 commit_parser = r"^(?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\( (?P<scope>[^()\r\n ]*)\) |\( )?(?P<breaking>!)?:\s (?P<message>.*)?"
344333 change_type_map = {
345334 "feat": "Features",
346335 "fix": "Bug Fixes",
347336 "refactor": "Code Refactor",
348- " perf" : " Performance improvements"
337+ "perf": "Performance improvements",
349338 }
350339
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:
352343 rev = commit.rev
353344 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})"
355348 return parsed_message
356349
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:
358353 """Executed at the end of the changelog generation
359354
360355 full_changelog: it's the output about to being written into the file
@@ -368,7 +363,7 @@ class StrangeCommitizen(BaseCommitizen):
368363 chat.room("#committers").notify(partial_changelog)
369364 if full_changelog:
370365 compliance.send(full_changelog)
371- full_changelog.replace(' fix ' , ' **fix** ' )
366+ full_changelog.replace(" fix ", " **fix** " )
372367 return full_changelog
373368` ` `
374369
@@ -381,6 +376,7 @@ If you want `commitizen` to catch your exception and print the message, you'll h
381376` ` ` python
382377from commitizen.cz.exception import CzException
383378
379+
384380class NoSubjectProvidedException(CzException):
385381 ...
386382` ` `
@@ -402,9 +398,11 @@ If you were having a `CzPlugin` class in a `cz_plugin.py` module like this:
402398` ` ` python
403399from commitizen.cz.base import BaseCommitizen
404400
401+
405402class PluginCz(BaseCommitizen):
406403 ...
407404
405+
408406discover_this = PluginCz
409407` ` `
410408
@@ -413,6 +411,7 @@ Then remove the `discover_this` line:
413411` ` ` python
414412from commitizen.cz.base import BaseCommitizen
415413
414+
416415class PluginCz(BaseCommitizen):
417416 ...
418417` ` `
@@ -423,16 +422,11 @@ and expose the class as entrypoint in you setuptools:
423422from setuptools import setup
424423
425424setup(
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+ ...,
436430)
437431` ` `
438432
0 commit comments