utils
Class info¶
🛈 DocStrings¶
Module containing helper functions for local repository operations.
create_branch_model
¶
create_branch_model(branch: Reference, is_default: bool = False) -> Branch
Create Branch model from GitPython branch reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
branch
|
Reference
|
GitPython branch reference |
required |
is_default
|
bool
|
Whether this is the default branch |
False
|
Returns:
| Type | Description |
|---|---|
Branch
|
Branch model instance |
Source code in src/githarbor/providers/local_provider/utils.py
create_commit_model
¶
create_commit_model(commit: Commit) -> Commit
Create Commit model from GitPython commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit
|
Commit
|
GitPython commit object |
required |
Returns:
| Type | Description |
|---|---|
Commit
|
Commit model instance |
Source code in src/githarbor/providers/local_provider/utils.py
create_tag_model
¶
create_tag_model(tag: TagReference | TagObject, commit: Commit) -> Tag
Create Tag model from GitPython tag reference or annotated tag object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
TagReference | TagObject
|
GitPython TagReference or TagObject |
required |
commit
|
Commit
|
Associated commit |
required |
Returns:
| Type | Description |
|---|---|
Tag
|
Tag model instance |
Source code in src/githarbor/providers/local_provider/utils.py
create_user_model
¶
create_user_model(git_actor: Actor) -> User
Create User model from GitPython actor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
git_actor
|
Actor
|
GitPython actor object |
required |
Returns:
| Type | Description |
|---|---|
User
|
User model instance or None if no actor |
Source code in src/githarbor/providers/local_provider/utils.py
filter_commits
¶
filter_commits(
commits: Iterator[Commit],
since: datetime | None = None,
until: datetime | None = None,
author: str | None = None,
path: str | None = None,
max_results: int | None = None,
) -> list[Commit]
Filter commits based on criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commits
|
Iterator[Commit]
|
Iterator of commits |
required |
since
|
datetime | None
|
Include commits after this date |
None
|
until
|
datetime | None
|
Include commits before this date |
None
|
author
|
str | None
|
Filter by author name/email |
None
|
path
|
str | None
|
Filter by file path |
None
|
max_results
|
int | None
|
Maximum number of commits to return |
None
|
Returns:
| Type | Description |
|---|---|
list[Commit]
|
List of filtered commits |
Source code in src/githarbor/providers/local_provider/utils.py
get_commit_stats
¶
Extract statistics from a commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit
|
Commit
|
GitPython commit object |
required |
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
Dictionary with commit statistics |
Source code in src/githarbor/providers/local_provider/utils.py
handle_git_errors
¶
Decorator to handle Git operation exceptions consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error_msg_template
|
str
|
Message template with format placeholders |
required |
Example
@handle_git_errors("Could not fetch branch {branch_name}") def get_branch(self, branch_name: str) -> Branch: ...