Skip to main content

GitClient

Trait GitClient 

Source
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§

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn stage_all(&self, repo_path: PathBuf) -> GitFuture<Result<(), GitError>>

Stages all tracked and untracked changes in repo_path.

§Errors

Returns an error when git add fails.

Source

fn head_short_hash( &self, repo_path: PathBuf, ) -> GitFuture<Result<String, GitError>>

Returns the short HEAD hash for repo_path.

§Errors

Returns an error when HEAD cannot be resolved.

Source

fn head_hash(&self, repo_path: PathBuf) -> GitFuture<Result<String, GitError>>

Returns the full HEAD hash for repo_path.

§Errors

Returns an error when HEAD cannot be resolved.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn pull_rebase( &self, repo_path: PathBuf, ) -> GitFuture<Result<PullRebaseResult, GitError>>

Performs a pull --rebase in repo_path.

§Errors

Returns an error when pull/rebase setup fails.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn fetch_remote(&self, repo_path: PathBuf) -> GitFuture<Result<(), GitError>>

Fetches remote refs for repo_path.

§Errors

Returns an error when fetch fails.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn repo_url(&self, repo_path: PathBuf) -> GitFuture<Result<String, GitError>>

Reads the configured origin URL for repo_path.

§Errors

Returns an error when origin is missing or cannot be resolved.

Source

fn main_repo_root( &self, repo_path: PathBuf, ) -> GitFuture<Result<PathBuf, GitError>>

Resolves the main repository root for a repository or worktree path.

§Errors

Returns an error when the main repository cannot be resolved.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§