Git reference¶
Git ¶
Example usage:
author_name ¶
author_name: str
Get the git author name from dda config, env var, or by querying the global git config. Note that the global git config should itself read the env var if it exists - we manually read the env var as a performance optimization.
author_email ¶
author_email: str
Get the git author email from dda config, env var, or by querying the global git config. Note that the global git config should itself read the env var if it exists - we manually read the env var as a performance optimization.
get_changes ¶
get_changes(
ref: str = "HEAD",
/,
*,
start: str | None = None,
merge_base: bool = False,
working_tree: bool = False,
remote_name: str = "origin",
) -> ChangeSet
Use git
to compute a ChangeSet between two refs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref | str | The reference to compare. | 'HEAD' |
start | str | None | The reference to compare against, defaulting to the parent commit of | None |
merge_base | bool | Whether to compare against the merge base of | False |
working_tree | bool | Whether to include working tree changes. | False |
remote_name | str | The configured name of the remote. This is only used if | 'origin' |
Returns:
Type | Description |
---|---|
ChangeSet | A ChangeSet representing the differences between the refs. |
Examples:
- Get changes between HEAD and its parent commit
- Get changes between HEAD and the main branch
- Get changes between two references
- Get changes between HEAD and the feat1 branch starting from the merge base
- Get changes between HEAD and remote's HEAD (tip of the default branch) starting from the merge base
- Get only the working tree changes
get_commit ¶
Get a Commit object from the Git repository in the current working directory for the given reference (default: HEAD).
get_remote ¶
Get the details of the given remote for the Git repository in the current working directory.
add ¶
Add the given paths to the index. Will fail if any path is not under cwd.
commit ¶
Commit the changes in the index.
Commit ¶
GitPersonDetails ¶
ChangeSet ¶
Represents a set of changes to files in a git repository. This can both be a change between two commits, or the changes in the working directory.
When considering the changes to the working directory, the untracked files are considered as added files.
from_iter ¶
from_iter(data: Iterable[ChangedFile]) -> Self
Create a ChangeSet from an iterable of FileChanges.
ChangedFile ¶
Represents changes to a single file in a git repository.