Skip to main content

read_git_branch

Function read_git_branch 

Source
pub fn read_git_branch(project_root: &Path) -> Option<String>
Expand description

Read the current git branch name from a project’s .git/HEAD.

Returns Some(branch_name) if the project is a git repository on a regular branch, None if the project isn’t tracked or HEAD is detached. Cheap (single fs read of a small file) — safe to call once at startup.