Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# semantic_release.commit_parser.token module

class semantic_release.commit_parser.token.ParseError(commit: Commit, error: str)

  Bases: `NamedTuple`

  A read-only named tuple object representing an error that occurred while parsing a commit message.

  commit: Commit

    The original commit object (a class defined by GitPython) that was parsed

  error: str

    A string with a description for why the commit parsing failed.

  property hexsha: str

    A hex representation of the hash value of the commit.

    This is a pass through property for convience to access the `hexsha` attribute of the `commit`.

  is_merge_commit() → bool
  property message: str

    A string representation of the commit message.

    This is a pass through property for convience to access the `message` attribute of the `commit` object.

    If the message is of type `bytes` then it will be decoded to a `UTF-8` string.

  raise_error() → NoReturn

    A convience method to raise a CommitParseError with the error message.

  property short_hash: str

    A short representation of the hash value (in hex) of the commit.

class semantic_release.commit_parser.token.ParsedCommit(bump: LevelBump, type: str, scope: str, descriptions: list[str], breaking_descriptions: list[str], commit: Commit, release_notices: tuple[str, ...] = (), linked_issues: tuple[str, ...] = (), linked_merge_request: str = '', include_in_changelog: bool = True)

  Bases: `NamedTuple`

  A read-only named tuple object representing the result of parsing a commit message.

  breaking_descriptions: list[str]

    A list of paragraphs which are deemed to identify and describe breaking changes by the parser.

    An example would be a paragraph which begins with the text `BREAKING CHANGE:` in the commit message but the parser gennerally strips the prefix and includes the rest of the paragraph in this list.

  bump: LevelBump

    A LevelBump enum value indicating what type of change this commit introduces.

  commit: Commit

    The original commit object (a class defined by GitPython) that was parsed

  descriptions: list[str]

    A list of paragraphs from the commit message.

    Paragraphs are generally delimited by a double-newline since git commit messages are sometimes manually wordwrapped with a single newline, but this is up to the parser to implement.

  static from_parsed_message_result(commit: Commit, parsed_message_result: ParsedMessageResult) → ParsedCommit

    A convience method to create a ParsedCommit object from a ParsedMessageResult object and a Commit object.

  property hexsha: str

    A hex representation of the hash value of the commit.

    This is a pass through property for convience to access the `hexsha` attribute of the `commit`.

  include_in_changelog: bool

    A boolean value indicating whether this commit should be included in the changelog.

    This enables parsers to flag commits which are not user-facing or are otherwise not relevant to the changelog to be filtered out by PSR’s internal algorithms.

  is_merge_commit() → bool
  linked_issues: tuple[str, ...]

    A tuple of issue numbers as strings, if the commit is contains issue references.

    If there are no issue references, this should be an empty tuple. Although, we generally refer to them as “issue numbers”, it generally should be a string to adhere to the prefixes used by the VCS (ex. `#` for GitHub, GitLab, etc.) or issue tracker (ex. JIRA uses `AAA-###`).

  linked_merge_request: str

    A pull request or merge request definition, if the commit is labeled with a pull/merge request number.

    This is a string value which includes any special character prefix used by the VCS (e.g. `#` for GitHub, `!` for GitLab).

  property linked_pull_request: str

    An alias to the linked_merge_request attribute.

  property message: str

    A string representation of the commit message.

    This is a pass through property for convience to access the `message` attribute of the `commit` object.

    If the message is of type `bytes` then it will be decoded to a `UTF-8` string.

  release_notices: tuple[str, ...]

    A tuple of release notices, which are additional information about the changes that affect the user.

    An example would be a paragraph which begins with the text `NOTICE:` in the commit message but the parser generally strips the prefix and includes the rest of the paragraph in this list.

  scope: str

    The scope, as a string, parsed from the commit.

    Generally an optional field based on the commit message style which means it very likely can be an empty string. Commit styles which do not have a meaningful concept of “scope” usually fill this field with an empty string.

  property short_hash: str

    A short representation of the hash value (in hex) of the commit.

  type: str

    The type of the commit as a string, per the commit message style.

    This is up to the parser to implement; for example, the EmojiCommitParser parser fills this field with the emoji representing the most significant change for the commit.

class semantic_release.commit_parser.token.ParsedMessageResult(bump: LevelBump, type: str, category: str, scope: str, descriptions: tuple[str, ...], breaking_descriptions: tuple[str, ...] = (), release_notices: tuple[str, ...] = (), linked_issues: tuple[str, ...] = (), linked_merge_request: str = '', include_in_changelog: bool = True)

  Bases: `NamedTuple`

  A read-only named tuple object representing the result from parsing a commit message.

  Essentially this is a data structure which holds the parsed information from a commit message without the actual commit object itself. Very helpful for unit testing.

  Most of the fields will replicate the fields of a `ParsedCommit`

  breaking_descriptions: tuple[str, ...]

    Alias for field number 5

  bump: LevelBump

    Alias for field number 0

  category: str

    Alias for field number 2

  descriptions: tuple[str, ...]

    Alias for field number 4

  include_in_changelog: bool

    Alias for field number 9

  linked_issues: tuple[str, ...]

    Alias for field number 7

  linked_merge_request: str

    Alias for field number 8

  release_notices: tuple[str, ...]

    Alias for field number 6

  scope: str

    Alias for field number 3

  type: str

    Alias for field number 1