Skip to main content

squash_merge

Function squash_merge 

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

  1. Verifies the repository is already on the target branch
  2. Performs git merge --squash from the source branch
  3. 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 on target_branch
  • source_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.