Skip to content

projects ¤

Git utilities.

Classes:

  • Project

    A class representing development projects.

  • Status

    Git status data.

Project dataclass ¤

Project(
    LOCKS: dict[Project, Lock] = defaultdict(Lock),
    DEFAULT_BRANCHES: tuple[str, ...] = ("main", "master"),
    path: Path,
)

A class representing development projects.

It is instantiated with a path, and then provides many utility properties and methods.

Methods:

  • checkout

    Checkout branch, restore previous one when exiting.

  • delete

    Delete branch.

  • fetch

    Fetch.

  • lock

    Lock project.

  • pull

    Pull branch.

  • push

    Push branch.

  • unlock

    Unlock project.

  • unpulled

    Number of unpulled commits, per branch.

  • unpushed

    Number of unpushed commits, per branch.

  • unreleased

    List unreleased commits.

Attributes:

  • DEFAULT_BRANCHES (tuple[str, ...]) –

    Name of common default branches. Mainly useful to compute unreleased commits.

  • branch (Head) –

    Currently checked out branch.

  • default_branch (str) –

    Default branch (or main branch), as checked out when cloning.

  • is_dirty (bool) –

    Whether the project is in a "dirty" state (uncommitted modifications).

  • latest_tag (TagReference) –

    Latest tag.

  • name (str) –

    Name of the project.

  • path (Path) –

    Path of the project on the file-system.

  • repo (Repo) –

    GitPython's Repo object.

  • status (Status) –

    Status of the project.

  • status_line (str) –

    Status of the project, as a string.

DEFAULT_BRANCHES class-attribute ¤

DEFAULT_BRANCHES: tuple[str, ...] = ('main', 'master')

Name of common default branches. Mainly useful to compute unreleased commits.

branch property ¤

branch: Head

Currently checked out branch.

default_branch property ¤

default_branch: str

Default branch (or main branch), as checked out when cloning.

is_dirty property ¤

is_dirty: bool

Whether the project is in a "dirty" state (uncommitted modifications).

latest_tag property ¤

latest_tag: TagReference

Latest tag.

name property ¤

name: str

Name of the project.

path instance-attribute ¤

path: Path

Path of the project on the file-system.

repo property ¤

repo: Repo

GitPython's Repo object.

status property ¤

status: Status

Status of the project.

status_line property ¤

status_line: str

Status of the project, as a string.

checkout ¤

checkout(branch: str | None) -> Iterator[None]

Checkout branch, restore previous one when exiting.

delete ¤

delete(branch: str) -> None

Delete branch.

fetch ¤

fetch() -> None

Fetch.

lock ¤

lock() -> bool

Lock project.

pull ¤

pull(branch: str | None = None) -> None

Pull branch.

push ¤

push(branch: str | None = None) -> None

Push branch.

unlock ¤

unlock() -> None

Unlock project.

unpulled ¤

unpulled(remote: str = 'origin') -> dict[str, int]

Number of unpulled commits, per branch.

unpushed ¤

unpushed(remote: str = 'origin') -> dict[str, int]

Number of unpushed commits, per branch.

unreleased ¤

unreleased(branch: str | None = None) -> list[Commit]

List unreleased commits.

Status dataclass ¤

Status(
    added: list[Path],
    deleted: list[Path],
    modified: list[Path],
    renamed: list[Path],
    typechanged: list[Path],
    untracked: list[Path],
)

Git status data.

Attributes:

added instance-attribute ¤

added: list[Path]

Added files.

deleted instance-attribute ¤

deleted: list[Path]

Deleted files.

modified instance-attribute ¤

modified: list[Path]

Modified files.

renamed instance-attribute ¤

renamed: list[Path]

Renamed files.

typechanged instance-attribute ¤

typechanged: list[Path]

Type-changed files.

untracked instance-attribute ¤

untracked: list[Path]

Untracked files.