conventional_commits#

A simple regex parser to parse conventional commit message.

Usage example:

import fixa.conventional_commits as conv_commits

conv_commits.tokenize
conv_commits.ConventionalCommit
conv_commits.ConventionalCommitParser
conv_commits.SemanticCommitEnum
conv_commits.default_parser
conv_commits.is_certain_semantic_commit
conv_commits.is_feat_commit
conv_commits.is_fix_commit
conv_commits.is_test_commit
conv_commits.is_utest_commit
conv_commits.is_itest_commit
conv_commits.is_ltest_commit
conv_commits.is_doc_commit
conv_commits.is_build_commit
conv_commits.is_publish_commit
conv_commits.is_release_commit

Reference:

aws_ops_alpha.vendor.conventional_commits.tokenize(text: str, delimiters: str = '!@#$%^&*()_+-=~`[{]}\\|;:\'",<.>/? \t\n') List[str][source]#

Example:

>>> tokenize("a, b (c): d - e")
["a", "b", "c", "d", "e"]
class aws_ops_alpha.vendor.conventional_commits.ConventionalCommit(types: List[str], description: Optional[str] = None, scope: Optional[str] = None, breaking: Optional[str] = None)[source]#

Data container class for conventional commits message.

render() str[source]#

Render the conventional commit message.

class aws_ops_alpha.vendor.conventional_commits.ConventionalCommitParser(types: List[str])[source]#

The customizable parser class. It tries to parse from ``type1, type2 (scope): {description}

Usage example:

>>> parser = ConventionalCommitParser(types=["feat", "fix", "build"])
>>> parser.parse_message("feat, build(STORY-001): add validator")
ConventionalCommit(types=['feat', 'build'], description='add validator', scope='STORY-001', breaking=None)
Parameters:

types – the list of conventional commit type you want to monitor

extract_subject(msg: str) str[source]#

Extract the subject line.

>>> ConventionalCommitParser().extract_subject("feat, build(STORY-001): add validator\nWe have done the following")
'feat, build(STORY-001): add validator'
extract_commit(subject: str) ConventionalCommit[source]#

Extract conventional commit object from the subject.

parse_message(commit_message: str) Optional[ConventionalCommit][source]#

Parse the commit message, return None if it is not a conventional commit.

class aws_ops_alpha.vendor.conventional_commits.SemanticCommitEnum(value)[source]#

Semantic commit message can help CI to determine what you want to do.

It is a good way to allow developer controls the CI behavior with small effort.

aws_ops_alpha.vendor.conventional_commits.is_certain_semantic_commit(commit_message: str, stub: ~typing.Union[str, ~typing.List[str]], parser: ~aws_ops_alpha.vendor.conventional_commits.ConventionalCommitParser = <aws_ops_alpha.vendor.conventional_commits.ConventionalCommitParser object>) bool[source]#

Identify whether the commit message is certain type of semantic commit.

Below is an example to check if the commit message has the keyword “fix”:

>>> is_certain_semantic_commit(
...     commit_message="fix: the function cannot handle this edge case",
...     stub="fix",
... )
True
Parameters:
  • commit_message – the commit message.

  • stub – commit type stub or list of commit type stub.

  • parser – a ConventionalCommitParser object.

Returns:

a boolean value