devops.git.tag

Module for Git tag-related constants and functions.

Functions

get_all_tags([config])

Get all Git tags in the repository.

get_latest_tag([config])

Get the latest Git tag in the repository.

Classes

GitTag(major, minor, patch, prefix)

Class representing a Git tag.

Exceptions

GitTagError(message)

Exception raised for Git tag-related errors in devops checks.

exception devops.git.tag.GitTagError(message)[source]

Bases: Exception

Exception raised for Git tag-related errors in devops checks.

Parameters:

message (str)

Return type:

None

class devops.git.tag.GitTag(major, minor, patch, prefix)[source]

Bases: object

Class representing a Git tag.

Parameters:
major: int
minor: int
patch: int
prefix: str
increase_major()[source]

Increase the major version by 1 and reset minor and patch to 0.

Returns:

GitTag – A new GitTag instance with the increased major version.

Return type:

GitTag

increase_minor()[source]

Increase the minor version by 1 and reset patch to 0.

Returns:

GitTag – A new GitTag instance with the increased minor version.

Return type:

GitTag

increase_patch()[source]

Increase the patch version by 1.

Returns:

GitTag – A new GitTag instance with the increased patch version.

Return type:

GitTag

static from_string(tag, config=GitConfig(tag_prefix='', empty_tag_list_allowed=True))[source]

Create a GitTag instance from a string.

Parameters:
  • tag (str) – The Git tag string in the format ‘<prefix><major>.<minor>.<patch>’.

  • config (GitConfig) – The Git configuration containing the expected prefix.

Returns:

GitTag – The GitTag instance created from the string.

Raises:

GitTagError – If the tag string does not start with the expected prefix. If the tag string is not in the correct format.

Return type:

GitTag

devops.git.tag.get_all_tags(config=GitConfig(tag_prefix='', empty_tag_list_allowed=True))[source]

Get all Git tags in the repository.

Parameters:

config (GitConfig) – The Git configuration containing the expected prefix and empty tag list allowance.

Returns:

list[GitTag] – A list of all Git tags.

Raises:

GitTagError – If there is an error retrieving the Git tags and empty_tag_list_allowed is False.

Return type:

list[GitTag]

devops.git.tag.get_latest_tag(config=GitConfig(tag_prefix='', empty_tag_list_allowed=True))[source]

Get the latest Git tag in the repository.

Parameters:

config (GitConfig) – The Git configuration containing the expected prefix and empty tag list allowance.

Returns:

GitTag – The latest Git tag. If no tags exist, returns GitTag(0, 0, 0, prefix).

Return type:

GitTag