pub trait GitClient: Send + Sync {
Show 42 methods
// Required methods
fn detect_git_info(&self, dir: PathBuf) -> GitFuture<Option<String>>;
fn find_git_repo_root(&self, dir: PathBuf) -> GitFuture<Option<PathBuf>>;
fn create_worktree(
&self,
repo_path: PathBuf,
worktree_path: PathBuf,
branch_name: String,
start_ref: String,
) -> GitFuture<Result<(), GitError>>;
fn remove_worktree(
&self,
worktree_path: PathBuf,
) -> GitFuture<Result<(), GitError>>;
fn squash_merge_diff(
&self,
repo_path: PathBuf,
source_branch: String,
target_branch: String,
) -> GitFuture<Result<String, GitError>>;
fn squash_merge(
&self,
repo_path: PathBuf,
source_branch: String,
target_branch: String,
commit_message: String,
) -> GitFuture<Result<SquashMergeOutcome, GitError>>;
fn rebase(
&self,
repo_path: PathBuf,
target_branch: String,
) -> GitFuture<Result<(), GitError>>;
fn rebase_start(
&self,
repo_path: PathBuf,
target_branch: String,
) -> GitFuture<Result<RebaseStepResult, GitError>>;
fn rebase_onto_start(
&self,
repo_path: PathBuf,
new_base: String,
old_base: String,
) -> GitFuture<Result<RebaseStepResult, GitError>>;
fn rebase_continue(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<RebaseStepResult, GitError>>;
fn abort_rebase(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<(), GitError>>;
fn is_rebase_in_progress(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<bool, GitError>>;
fn in_progress_operation(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Option<InProgressGitOperation>, GitError>>;
fn has_unmerged_paths(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<bool, GitError>>;
fn list_staged_conflict_marker_files(
&self,
repo_path: PathBuf,
paths: Vec<String>,
) -> GitFuture<Result<Vec<String>, GitError>>;
fn list_conflicted_files(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Vec<String>, GitError>>;
fn commit_all(
&self,
repo_path: PathBuf,
message: String,
no_verify: bool,
) -> GitFuture<Result<(), GitError>>;
fn commit_all_preserving_single_commit(
&self,
repo_path: PathBuf,
base_branch: String,
commit_message: String,
message_strategy: SingleCommitMessageStrategy,
no_verify: bool,
) -> GitFuture<Result<(), GitError>>;
fn stage_all(&self, repo_path: PathBuf) -> GitFuture<Result<(), GitError>>;
fn head_short_hash(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>;
fn head_hash(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>;
fn ref_hash(
&self,
repo_path: PathBuf,
reference: String,
) -> GitFuture<Result<String, GitError>>;
fn head_commit_message(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Option<String>, GitError>>;
fn delete_branch(
&self,
repo_path: PathBuf,
branch_name: String,
) -> GitFuture<Result<(), GitError>>;
fn diff(
&self,
repo_path: PathBuf,
base_branch: String,
) -> GitFuture<Result<String, GitError>>;
fn is_worktree_clean(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<bool, GitError>>;
fn worktree_status(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>;
fn tracked_worktree_status(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>;
fn has_commits_since(
&self,
repo_path: PathBuf,
base_branch: String,
) -> GitFuture<Result<bool, GitError>>;
fn pull_rebase(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<PullRebaseResult, GitError>>;
fn push_current_branch(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>;
fn push_current_branch_to_remote_branch(
&self,
repo_path: PathBuf,
remote_branch_name: String,
) -> GitFuture<Result<String, GitError>>;
fn remote_branch_exists(
&self,
repo_path: PathBuf,
remote_branch_name: String,
) -> GitFuture<Result<bool, GitError>>;
fn current_upstream_reference(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>;
fn fetch_remote(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<(), GitError>>;
fn get_ahead_behind(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<(u32, u32), GitError>>;
fn get_ref_ahead_behind(
&self,
repo_path: PathBuf,
left_ref: String,
right_ref: String,
) -> GitFuture<Result<(u32, u32), GitError>>;
fn branch_tracking_statuses(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<BranchTrackingMap, GitError>>;
fn list_upstream_commit_titles(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Vec<String>, GitError>>;
fn list_local_commit_titles(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Vec<String>, GitError>>;
fn repo_url(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>;
fn main_repo_root(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<PathBuf, GitError>>;
}Expand description
Low-level async git boundary used by app orchestration code.
Production uses RealGitClient, while tests can inject
MockGitClient to avoid flaky multi-command process workflows.
Required Methods§
Sourcefn detect_git_info(&self, dir: PathBuf) -> GitFuture<Option<String>>
fn detect_git_info(&self, dir: PathBuf) -> GitFuture<Option<String>>
Detects the current branch name for the repository containing dir.
Returns None when dir is not inside a git repository or no branch
can be determined.
Sourcefn find_git_repo_root(&self, dir: PathBuf) -> GitFuture<Option<PathBuf>>
fn find_git_repo_root(&self, dir: PathBuf) -> GitFuture<Option<PathBuf>>
Resolves the repository root directory that contains dir.
Returns None when dir is not in a git repository.
Sourcefn create_worktree(
&self,
repo_path: PathBuf,
worktree_path: PathBuf,
branch_name: String,
start_ref: String,
) -> GitFuture<Result<(), GitError>>
fn create_worktree( &self, repo_path: PathBuf, worktree_path: PathBuf, branch_name: String, start_ref: String, ) -> GitFuture<Result<(), GitError>>
Creates a new worktree at worktree_path on branch_name from
start_ref inside repo_path.
§Errors
Returns an error when any underlying git command fails, when branches cannot be resolved, or when the target worktree path cannot be created.
Sourcefn remove_worktree(
&self,
worktree_path: PathBuf,
) -> GitFuture<Result<(), GitError>>
fn remove_worktree( &self, worktree_path: PathBuf, ) -> GitFuture<Result<(), GitError>>
Removes the existing worktree at worktree_path.
§Errors
Returns an error when the path is not a registered worktree or git cannot remove it.
Sourcefn squash_merge_diff(
&self,
repo_path: PathBuf,
source_branch: String,
target_branch: String,
) -> GitFuture<Result<String, GitError>>
fn squash_merge_diff( &self, repo_path: PathBuf, source_branch: String, target_branch: String, ) -> GitFuture<Result<String, GitError>>
Returns the staged squash-merge preview diff from source_branch into
target_branch within repo_path.
§Errors
Returns an error when either branch is missing or diff generation fails.
Sourcefn squash_merge(
&self,
repo_path: PathBuf,
source_branch: String,
target_branch: String,
commit_message: String,
) -> GitFuture<Result<SquashMergeOutcome, GitError>>
fn squash_merge( &self, repo_path: PathBuf, source_branch: String, target_branch: String, commit_message: String, ) -> GitFuture<Result<SquashMergeOutcome, GitError>>
Performs a squash merge of source_branch into target_branch inside
repo_path using commit_message.
§Errors
Returns an error when checkout, merge, or commit operations fail.
Sourcefn rebase(
&self,
repo_path: PathBuf,
target_branch: String,
) -> GitFuture<Result<(), GitError>>
fn rebase( &self, repo_path: PathBuf, target_branch: String, ) -> GitFuture<Result<(), GitError>>
Runs git rebase <target_branch> in repo_path.
§Errors
Returns an error when rebase setup fails or git reports a fatal error.
Sourcefn rebase_start(
&self,
repo_path: PathBuf,
target_branch: String,
) -> GitFuture<Result<RebaseStepResult, GitError>>
fn rebase_start( &self, repo_path: PathBuf, target_branch: String, ) -> GitFuture<Result<RebaseStepResult, GitError>>
Starts a rebase onto target_branch and reports whether it completed
immediately or stopped for conflicts.
§Errors
Returns an error when rebase cannot be started.
Sourcefn rebase_onto_start(
&self,
repo_path: PathBuf,
new_base: String,
old_base: String,
) -> GitFuture<Result<RebaseStepResult, GitError>>
fn rebase_onto_start( &self, repo_path: PathBuf, new_base: String, old_base: String, ) -> GitFuture<Result<RebaseStepResult, GitError>>
Starts git rebase --onto new_base old_base in repo_path.
§Errors
Returns an error when rebase cannot be started.
Sourcefn rebase_continue(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<RebaseStepResult, GitError>>
fn rebase_continue( &self, repo_path: PathBuf, ) -> GitFuture<Result<RebaseStepResult, GitError>>
Continues an in-progress rebase in repo_path.
§Errors
Returns an error when there is no rebase to continue or git fails.
Sourcefn abort_rebase(&self, repo_path: PathBuf) -> GitFuture<Result<(), GitError>>
fn abort_rebase(&self, repo_path: PathBuf) -> GitFuture<Result<(), GitError>>
Aborts an in-progress rebase in repo_path.
§Errors
Returns an error when abort fails or no rebase state exists.
Sourcefn is_rebase_in_progress(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<bool, GitError>>
fn is_rebase_in_progress( &self, repo_path: PathBuf, ) -> GitFuture<Result<bool, GitError>>
Returns whether rebase metadata exists in repo_path.
§Errors
Returns an error when git state cannot be inspected.
Sourcefn in_progress_operation(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Option<InProgressGitOperation>, GitError>>
fn in_progress_operation( &self, repo_path: PathBuf, ) -> GitFuture<Result<Option<InProgressGitOperation>, GitError>>
Returns detected in-progress git operation metadata in repo_path.
§Errors
Returns an error when git state cannot be inspected.
Sourcefn has_unmerged_paths(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<bool, GitError>>
fn has_unmerged_paths( &self, repo_path: PathBuf, ) -> GitFuture<Result<bool, GitError>>
Returns whether unmerged index entries remain in repo_path.
§Errors
Returns an error when index status cannot be read.
Sourcefn list_staged_conflict_marker_files(
&self,
repo_path: PathBuf,
paths: Vec<String>,
) -> GitFuture<Result<Vec<String>, GitError>>
fn list_staged_conflict_marker_files( &self, repo_path: PathBuf, paths: Vec<String>, ) -> GitFuture<Result<Vec<String>, GitError>>
Filters paths to files that are staged and still contain conflict
markers in repo_path.
§Errors
Returns an error when staged content cannot be inspected.
Sourcefn list_conflicted_files(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Vec<String>, GitError>>
fn list_conflicted_files( &self, repo_path: PathBuf, ) -> GitFuture<Result<Vec<String>, GitError>>
Lists files currently marked conflicted in the index for repo_path.
§Errors
Returns an error when conflict state cannot be queried.
Sourcefn commit_all(
&self,
repo_path: PathBuf,
message: String,
no_verify: bool,
) -> GitFuture<Result<(), GitError>>
fn commit_all( &self, repo_path: PathBuf, message: String, no_verify: bool, ) -> GitFuture<Result<(), GitError>>
Stages and commits all changes in repo_path using message.
Set no_verify to skip commit hooks.
§Errors
Returns an error when staging or commit creation fails.
Sourcefn commit_all_preserving_single_commit(
&self,
repo_path: PathBuf,
base_branch: String,
commit_message: String,
message_strategy: SingleCommitMessageStrategy,
no_verify: bool,
) -> GitFuture<Result<(), GitError>>
fn commit_all_preserving_single_commit( &self, repo_path: PathBuf, base_branch: String, commit_message: String, message_strategy: SingleCommitMessageStrategy, no_verify: bool, ) -> GitFuture<Result<(), GitError>>
Commits all changes while preserving one evolving session commit in
repo_path.
Uses commit_message for new or amended commit content. Set
no_verify to skip commit hooks.
§Errors
Returns an error when staging, amend/create, or branch inspection fails.
Sourcefn ref_hash(
&self,
repo_path: PathBuf,
reference: String,
) -> GitFuture<Result<String, GitError>>
fn ref_hash( &self, repo_path: PathBuf, reference: String, ) -> GitFuture<Result<String, GitError>>
Returns the full commit hash for a branch, tag, or commit-ish ref.
§Errors
Returns an error when the reference cannot be resolved to a commit.
Sourcefn head_commit_message(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Option<String>, GitError>>
fn head_commit_message( &self, repo_path: PathBuf, ) -> GitFuture<Result<Option<String>, GitError>>
Returns the full HEAD commit message for repo_path, or None when
no commits exist.
§Errors
Returns an error when HEAD cannot be inspected.
Sourcefn delete_branch(
&self,
repo_path: PathBuf,
branch_name: String,
) -> GitFuture<Result<(), GitError>>
fn delete_branch( &self, repo_path: PathBuf, branch_name: String, ) -> GitFuture<Result<(), GitError>>
Deletes branch_name in repo_path.
§Errors
Returns an error when the branch is missing, checked out, or deletion is rejected by git.
Sourcefn diff(
&self,
repo_path: PathBuf,
base_branch: String,
) -> GitFuture<Result<String, GitError>>
fn diff( &self, repo_path: PathBuf, base_branch: String, ) -> GitFuture<Result<String, GitError>>
Returns a patch diff from base_branch to current HEAD in
repo_path.
§Errors
Returns an error when refs are invalid or diff generation fails.
Sourcefn is_worktree_clean(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<bool, GitError>>
fn is_worktree_clean( &self, repo_path: PathBuf, ) -> GitFuture<Result<bool, GitError>>
Returns whether the worktree in repo_path has no local changes.
§Errors
Returns an error when status inspection fails.
Sourcefn worktree_status(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>
fn worktree_status( &self, repo_path: PathBuf, ) -> GitFuture<Result<String, GitError>>
Returns raw porcelain status for the worktree in repo_path.
§Errors
Returns an error when status inspection fails.
Sourcefn tracked_worktree_status(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>
fn tracked_worktree_status( &self, repo_path: PathBuf, ) -> GitFuture<Result<String, GitError>>
Returns raw porcelain status for tracked files in repo_path.
§Errors
Returns an error when tracked-file status inspection fails.
Sourcefn has_commits_since(
&self,
repo_path: PathBuf,
base_branch: String,
) -> GitFuture<Result<bool, GitError>>
fn has_commits_since( &self, repo_path: PathBuf, base_branch: String, ) -> GitFuture<Result<bool, GitError>>
Returns whether HEAD contains commits not reachable from
base_branch.
§Errors
Returns an error when commit ancestry cannot be queried.
Sourcefn pull_rebase(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<PullRebaseResult, GitError>>
fn pull_rebase( &self, repo_path: PathBuf, ) -> GitFuture<Result<PullRebaseResult, GitError>>
Sourcefn push_current_branch(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>
fn push_current_branch( &self, repo_path: PathBuf, ) -> GitFuture<Result<String, GitError>>
Pushes the currently checked out branch for repo_path with
--force-with-lease and returns the configured upstream reference
after the successful push.
§Errors
Returns an error when remote push fails.
Sourcefn push_current_branch_to_remote_branch(
&self,
repo_path: PathBuf,
remote_branch_name: String,
) -> GitFuture<Result<String, GitError>>
fn push_current_branch_to_remote_branch( &self, repo_path: PathBuf, remote_branch_name: String, ) -> GitFuture<Result<String, GitError>>
Pushes the current branch for repo_path to one explicit remote branch
name with --force-with-lease and returns the configured upstream
reference after the push.
§Errors
Returns an error when remote push fails.
Sourcefn remote_branch_exists(
&self,
repo_path: PathBuf,
remote_branch_name: String,
) -> GitFuture<Result<bool, GitError>>
fn remote_branch_exists( &self, repo_path: PathBuf, remote_branch_name: String, ) -> GitFuture<Result<bool, GitError>>
Checks whether remote_branch_name already exists on the remote for
the repository at repo_path.
§Errors
Returns an error when the remote lookup command fails.
Sourcefn current_upstream_reference(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<String, GitError>>
fn current_upstream_reference( &self, repo_path: PathBuf, ) -> GitFuture<Result<String, GitError>>
Resolves the current upstream reference for repo_path.
§Errors
Returns an error when upstream tracking information is unavailable.
Sourcefn get_ahead_behind(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<(u32, u32), GitError>>
fn get_ahead_behind( &self, repo_path: PathBuf, ) -> GitFuture<Result<(u32, u32), GitError>>
Reads ahead/behind commit counts for repo_path.
§Errors
Returns an error when upstream tracking information is unavailable.
Sourcefn get_ref_ahead_behind(
&self,
repo_path: PathBuf,
left_ref: String,
right_ref: String,
) -> GitFuture<Result<(u32, u32), GitError>>
fn get_ref_ahead_behind( &self, repo_path: PathBuf, left_ref: String, right_ref: String, ) -> GitFuture<Result<(u32, u32), GitError>>
Reads ahead/behind commit counts between two explicit refs.
The returned tuple is (ahead, behind) from the perspective of
left_ref.
§Errors
Returns an error when either ref cannot be resolved.
Sourcefn branch_tracking_statuses(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<BranchTrackingMap, GitError>>
fn branch_tracking_statuses( &self, repo_path: PathBuf, ) -> GitFuture<Result<BranchTrackingMap, GitError>>
Reads ahead/behind snapshots for all local branches that track an upstream.
The returned map is keyed by local branch name and stores None when
a branch has no tracked upstream or its upstream is gone.
§Errors
Returns an error when branch tracking information cannot be queried.
Sourcefn list_upstream_commit_titles(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Vec<String>, GitError>>
fn list_upstream_commit_titles( &self, repo_path: PathBuf, ) -> GitFuture<Result<Vec<String>, GitError>>
Returns commit subjects that exist in upstream but not in local
HEAD.
§Errors
Returns an error when upstream tracking data or commit history cannot be read.
Sourcefn list_local_commit_titles(
&self,
repo_path: PathBuf,
) -> GitFuture<Result<Vec<String>, GitError>>
fn list_local_commit_titles( &self, repo_path: PathBuf, ) -> GitFuture<Result<Vec<String>, GitError>>
Returns commit subjects that exist in local HEAD but not in upstream.
§Errors
Returns an error when upstream tracking data or commit history cannot be read.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".