pub async fn squash_merge(
repo_path: PathBuf,
source_branch: String,
target_branch: String,
commit_message: String,
) -> Result<SquashMergeOutcome, GitError>Expand description
Re-exported squash-merge APIs. Performs a squash merge from a source branch to a target branch.
This function:
- Verifies the repository is already on the target branch
- Performs
git merge --squashfrom the source branch - Commits the squashed changes (skipping configured commit hooks)
The caller is responsible for ensuring repo_path is already checked out
on target_branch. Switching branches here would disrupt the user’s
working directory.
§Arguments
repo_path- Path to the git repository root, already ontarget_branchsource_branch- Name of the branch to merge from (e.g.,wt/abc123)target_branch- Name of the branch to merge into (e.g.,main)commit_message- Message for the squash commit
§Returns
A SquashMergeOutcome describing whether a squash commit was created.
§Errors
Returns an error if the repository is on the wrong branch, the merge fails, or the commit fails.