Skip to main content

detect_branch

Function detect_branch 

Source
pub fn detect_branch(path: &Path) -> String
Expand description

Detect the current git branch for the given path.

Uses get_current_branch which resolves worktree .git files correctly, handles detached HEAD (returns short commit hash), and normalizes path components. Falls back to "main" on any error with a debug trace.