devops.git.remote

Module for querying and pushing references on the origin remote.

Functions

git(*arguments)

Run a Git command and return its stripped standard output.

ls_remote(*patterns[, options])

List references on origin that match the given patterns.

remote_tag_target(tag)

Return the commit a tag on origin points to.

remote_tags(config)

Return all release tags on origin that match the configured prefix.

Exceptions

GitRemoteError(message)

Exception raised when a Git command fails.

exception devops.git.remote.GitRemoteError(message)[source]

Bases: Exception

Exception raised when a Git command fails.

Parameters:

message (str)

Return type:

None

devops.git.remote.git(*arguments)[source]

Run a Git command and return its stripped standard output.

Parameters:

*arguments (str) – The arguments passed to git.

Returns:

str – The stripped standard output of the command.

Raises:

GitRemoteError – If Git cannot be run or exits with an error.

Return type:

str

devops.git.remote.ls_remote(*patterns, options=())[source]

List references on origin that match the given patterns.

Parameters:
  • *patterns (str) – Reference patterns, for example refs/tags/v1.0.0.

  • options (tuple[str, ...]) – Options for git ls-remote, for example ("--tags",).

Returns:

dict[str, str] – A mapping of reference name to commit or tag object SHA.

Return type:

dict[str, str]

devops.git.remote.remote_tags(config)[source]

Return all release tags on origin that match the configured prefix.

Tags that are not <prefix>major.minor.patch, such as pre-releases, are ignored.

Parameters:

config (GitConfig) – The Git configuration with the expected tag prefix.

Returns:

list[GitTag] – The release tags found on origin.

Return type:

list[GitTag]

devops.git.remote.remote_tag_target(tag)[source]

Return the commit a tag on origin points to.

Parameters:

tag (str) – The tag name.

Returns:

str | None – The commit SHA, or None if the tag does not exist on origin.

Return type:

str | None