devices.git:gitDevice

Interface to Git repositories.

Usage

Source

devices.git:gitDevice(repo_path)

A class that provides methods to interact with a Git repository using the pygit2 library.

Parameters

repo_path: str
Path to the Git repository.

Attributes

repo_path: str

Path to the Git repository.

repo: pygit2.Repository

The pygit2 Repository object.

config_params: dict
Dictionary mapping parameter names to method names.

Methods

Name Description
__init__() Initialize a gitDevice with the specified repository path.
get_branch_name() Get the name of the current branch.
get_commit_hash() Get the hash of the current HEAD commit.
get_diff() Get a text representation of the current diff.
get_remote_url() Get the URL of the first remote.
get_status() Get the status of the repository.

__init__()

Initialize a gitDevice with the specified repository path.

Usage

Source

__init__(repo_path)

Parameters

repo_path: str
Path to the Git repository.

Raises

Exception
If the repository cannot be opened.

get_branch_name()

Get the name of the current branch.

Usage

Source

get_branch_name()

Returns

str
The name of the current branch.

get_commit_hash()

Get the hash of the current HEAD commit.

Usage

Source

get_commit_hash()

Returns

str
The hash of the current HEAD commit.

get_diff()

Get a text representation of the current diff.

Usage

Source

get_diff()

Returns

str
A text representation of the changes in the repository.

get_remote_url()

Get the URL of the first remote.

Usage

Source

get_remote_url()

Returns

str or None
The URL of the first remote, or None if no remotes are configured.

get_status()

Get the status of the repository.

Usage

Source

get_status()

Returns

dict
A dictionary with keys representing different status categories (staged, modified, untracked, etc.) and values as lists of file paths.