Git
feu.local_git ¶
Contain git utility functions to inspect the tags of the current repository.
These functions require the gitpython package.
feu.local_git.get_last_tag_name ¶
get_last_tag_name(raise_error: bool = True) -> str | None
Get the name of the most recent tag in the current repository.
The most recent tag is the tag pointing to the most recent commit,
see get_tags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raise_error
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
str | None
|
The tag name, or |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if no tag was found and |
Example
>>> from feu.local_git import get_last_tag_name
>>> tag = get_last_tag_name()
>>> tag
>>> tag = get_last_tag_name(raise_error=False)
>>> tag
feu.local_git.get_last_version_tag_name ¶
get_last_version_tag_name(
raise_error: bool = True,
) -> str | None
Get the name of the most recent version tag in the current repository.
A version tag is a tag made of the prefix v followed by a
valid PEP 440 version, e.g. v1.2.3. The other tags are
ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raise_error
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
str | None
|
The tag name, or |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if no version tag was found and
|
Example
>>> from feu.local_git import get_last_version_tag_name
>>> tag = get_last_version_tag_name()
>>> tag
>>> tag = get_last_version_tag_name(raise_error=False)
>>> tag
feu.local_git.get_tags ¶
get_tags() -> list[TagReference]
Get the list of git tags sorted by date/time for the current repository.
The repository is searched from the current working directory and its parent directories. The tags are sorted by the commit date of the commit they point to.
Returns:
| Type | Description |
|---|---|
list[TagReference]
|
The list of git tags sorted by commit date/time, from the oldest to the most recent. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if the |
InvalidGitRepositoryError
|
if the current directory is not in a git repository. |
Example
>>> from feu.local_git import get_tags
>>> tags = get_tags()
>>> tags