Skip to content

git_ops

git information access.

CLASS DESCRIPTION
GitTag

Represents a Git tag and its associated data.

TagInfo

Simple storage of tag information.

FUNCTION DESCRIPTION
get_commits_by_tags

Group commits by the tags they belong to.

get_repo

Get the git repo from a specific path or the current working directory.

get_tags

Get all the tags in a repository.

parse_commits

Parse the commits for later processing.

Classes

GitTag dataclass

GitTag(tag_name: str, tag_info: TagInfo, commits: List[Commit])

Represents a Git tag and its associated data.

This class is used to encapsulate details about a Git tag, including its name, additional information, and a list of related commits. It is immutable to ensure the integrity of the stored data, making it safe for concurrent and controlled usage.

ATTRIBUTE DESCRIPTION
tag_name

The name of the Git tag.

TYPE: str

tag_info

Metadata and additional details associated with the Git tag.

TYPE: TagInfo

commits

The list of commits that are associated with this Git tag.

TYPE: List[Commit]

TagInfo dataclass

TagInfo(
    name: str, commit: str, tagger: Union[str, Actor], tagged_datetime: datetime
)

Simple storage of tag information.

ATTRIBUTE DESCRIPTION
date_string

Convenience method to return an ISO8601 date string.

TYPE: str

Attributes

date_string property
date_string: str

Convenience method to return an ISO8601 date string.

Functions

get_commits_by_tags

get_commits_by_tags(
    repository: Repo,
    tag_filter_pattern: str,
    starting_tag: Optional[str] = None,
) -> List[GitTag]

Group commits by the tags they belong to.

PARAMETER DESCRIPTION
repository

The git repository object

TYPE: Repo

tag_filter_pattern

A regular expression pattern that matches valid tags as versions

TYPE: str

starting_tag

Only include tags after this one

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
List[GitTag]

A list of dictionaries with tag information with most recent first

get_repo

get_repo(repo_path: Optional[str] = None) -> Repo

Get the git repo from a specific path or the current working directory.

PARAMETER DESCRIPTION
repo_path

The path to the directory with git repository. If None, the current working directory is used.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Repo

Repository object

get_tags

get_tags(repository: Repo) -> List[TagInfo]

Get all the tags in a repository.

PARAMETER DESCRIPTION
repository

The repository object containing the tags

TYPE: Repo

RETURNS DESCRIPTION
List[TagInfo]

A list of TagInfo objects with the most recent first

parse_commits

parse_commits(
    repository: Repo,
    starting_rev: Optional[str] = None,
    ending_rev: Optional[str] = None,
) -> list

Parse the commits for later processing.

PARAMETER DESCRIPTION
repository

The repository object.

TYPE: Repo

starting_rev

Include all commits after this revision.

TYPE: Optional[str] DEFAULT: None

ending_rev

include all commmits before and including this revision.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
list

A list of CommitInfo objects.