GitClient

class forkbit_sdk.GitClient[source]

Bases: object

Client for git operations on the current project.

Available as BasePlugin.git. Only usable if the project directory contains a .git folder — otherwise all methods raise GitError.

Example:

tags = self.git.list_tags()
self.git.create_tag("v1.0.0", message="Release 1.0.0")
self.git.push()
__init__(repo=None)[source]
status()[source]

Return the working tree status.

Returns:

Dict mapping file paths to their status flags.

Raises:

GitError – If git is not available.

Return type:

dict

current_branch()[source]

Return the name of the currently checked-out branch.

Raises:

GitError – If git is not available.

Return type:

str

create_tag(name, message='')[source]

Create an annotated git tag.

Parameters:
  • name (str) – Tag name (e.g. "v1.0.0").

  • message (str) – Optional tag message. If empty, a lightweight tag is created.

Raises:

GitError – If git is not available.

Return type:

None

list_tags()[source]

Return all tags in the repository.

Returns:

List of tag names, sorted alphabetically.

Raises:

GitError – If git is not available.

Return type:

list[str]

push(remote='origin')[source]

Push commits and tags to a remote.

Parameters:

remote (str) – Remote name (default: "origin").

Raises:

GitError – If git is not available or the push fails.

Return type:

None

pull()[source]

Pull changes from the tracking remote.

Raises:

GitError – If git is not available or the pull fails.

Return type:

None

commit(message, paths=None)[source]

Create a commit.

Parameters:
  • message (str) – Commit message.

  • paths (list[str] | None) – Files to stage. If None, commits all staged changes.

Returns:

The commit hash.

Raises:

GitError – If git is not available or the commit fails.

Return type:

str

exception forkbit_sdk.GitError[source]

Bases: Exception

Raised when a git operation fails or git is not available.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)