Skip to main content

generate_worktree_path

Function generate_worktree_path 

Source
pub fn generate_worktree_path(
    pattern: &str,
    branch_name: &str,
) -> Result<PathBuf>
Expand description

Generate the full path for a worktree.

Creates the worktree as a sibling directory of the main repository.

§Arguments

  • pattern - The path pattern (e.g., “{repo}-wt-{branch}”)
  • branch_name - The branch name (will be slugified)

§Returns

  • Ok(PathBuf) - The full path where the worktree should be created
  • Err - If not in a git repository

§Example

use autom8::worktree::generate_worktree_path;

// If main repo is at /home/user/myproject, returns:
// /home/user/myproject-wt-feature-login
let path = generate_worktree_path("{repo}-wt-{branch}", "feature/login").unwrap();