API reference
GitBugRepo
- class ezgb.GitBugRepo(repo_path)[source]
High-level interface to a git-bug repository.
Reads bug data directly from git objects for speed. Writes go through the
git bugCLI to maintain Lamport clock and DAG consistency.Usage:
repo = GitBugRepo('/path/to/repo') for bug in repo.list_bugs(status=Status.OPEN): print(bug.title)
- Parameters:
repo_path (str)
- list_bugs(*, status=None, label=None, since=None)[source]
List all bugs, optionally filtered by status, label, and/or modification time.
since accepts a unix timestamp (
int), adatetime, or a string in ISO-8601 /YYYYMMDDHHMMSSformat. Only bugs whose tip commit is newer than this value are returned.
- iter_bugs(*, status=None, label=None, since=None)[source]
Lazily iterate over bugs, yielding one at a time.
Accepts the same filters as
list_bugs()but avoids building all snapshots up front, which saves memory on large repositories.
- list_bug_summaries(*, status=None, label=None, since=None)[source]
List lightweight bug summaries, optionally filtered.
Uses the git-bug CLI cache when available (~100ms for hundreds of bugs). Falls back to native git object reads when the CLI is not installed or the cache is empty.
- Parameters:
status (Status | None)
label (str | None)
since (str | datetime | int | None)
- Return type:
list[BugSummary]
- iter_bug_summaries(*, status=None, label=None, since=None)[source]
Lazily iterate over bug summaries.
Accepts the same filters as
list_bug_summaries().- Parameters:
status (Status | None)
label (str | None)
since (str | datetime | int | None)
- Return type:
Iterator[BugSummary]
- get_bug(bid)[source]
Get a single bug by ID (full or abbreviated).
- Parameters:
bid (str)
- Return type:
- get_attachment(blob_hash)[source]
Read a file attachment by its blob hash.
Blob hashes are found in
Comment.attachment_ids.- Parameters:
blob_hash (str)
- Return type:
bytes
- search(query)[source]
Search bugs using the git-bug CLI query language.
Delegates to
git bug -f json <query>and reconstructs Bug objects from the results.- Parameters:
query (str)
- Return type:
list[Bug]
- resolve_bug_id(bid)[source]
Resolve an abbreviated bug ID to the full 64-char ID.
- Parameters:
bid (str)
- Return type:
str
- create_bug(title, body)[source]
Create a new bug and return its snapshot.
- Parameters:
title (str)
body (str)
- Return type:
- add_comment(bid, text)[source]
Add a comment to a bug and return the new Comment.
- Parameters:
bid (str)
text (str)
- Return type:
- edit_comment(bid, comment_id, text)[source]
Edit a comment’s text.
- Parameters:
bid (str)
comment_id (str)
text (str)
- Return type:
None
- set_status(bid, status)[source]
Set a bug’s status to open or closed.
- Parameters:
bid (str)
status (Status)
- Return type:
None
- set_title(bid, title)[source]
Edit a bug’s title.
- Parameters:
bid (str)
title (str)
- Return type:
None
- add_label(bid, label)[source]
Add a label to a bug.
- Parameters:
bid (str)
label (str)
- Return type:
None
- remove_label(bid, label)[source]
Remove a label from a bug.
- Parameters:
bid (str)
label (str)
- Return type:
None
- remove_bug(bid)[source]
Permanently delete a bug. This is irreversible.
- Parameters:
bid (str)
- Return type:
None
- push(remote='origin')[source]
Push bugs and identities to a remote.
Returns
(returncode, stdout, stderr).- Parameters:
remote (str)
- Return type:
tuple[int, str, str]
Data classes
Bug
BugSummary
- class ezgb.BugSummary(id, title, status, creator_id, created_at, labels, comment_count, author_name='', edited_at=datetime.datetime(1, 1, 1, 0, 0, tzinfo=datetime.timezone.utc))[source]
Lightweight bug snapshot for list views.
Contains only the fields needed for display in listings. Identity resolution is deferred – creator_id holds the raw identity hash string rather than a resolved Identity object.
Both the git-bug CLI cache and native git-object reads populate author_name (the creator’s resolved display name) and edited_at (the last-activity time). author_name may fall back to the raw identity hash if the identity cannot be resolved.
- Parameters:
id (str)
title (str)
status (Status)
creator_id (str)
created_at (datetime)
labels (frozenset[str])
comment_count (int)
author_name (str)
edited_at (datetime)
- id: str
- title: str
- creator_id: str
- created_at: datetime
- labels: frozenset[str]
- comment_count: int
- author_name: str = ''
- edited_at: datetime = datetime.datetime(1, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
Comment
- class ezgb.Comment(id, author, text, created_at, count, attachment_ids=<factory>)[source]
A comment on a bug.
- Parameters:
id (str)
author (Identity)
text (str)
created_at (datetime)
count (int)
attachment_ids (list[str])
- id: str
- text: str
- created_at: datetime
- count: int
- attachment_ids: list[str]
Identity
Enums
Status
Exceptions
All exceptions inherit from EzgbError, so you can catch
that base class if you want to handle any ezgb error in one place.
- class ezgb.BugNotFoundError[source]
Bases:
EzgbErrorA bug ID could not be resolved or has no operation packs.