(git: &GitRepository)
| 2808 | } |
| 2809 | |
| 2810 | fn current_attached_git_branch(git: &GitRepository) -> CliResult<String> { |
| 2811 | match observe_head(git).map_err(observation_error)? { |
| 2812 | HeadObservation::Attached { symref, .. } => symref |
| 2813 | .strip_prefix("refs/heads/") |
| 2814 | .map(str::to_string) |
| 2815 | .ok_or_else(|| git_error(format!("Git HEAD symref '{symref}' is not a local branch"))), |
| 2816 | HeadObservation::Detached { .. } => { |
| 2817 | Err(git_error("Git HEAD must be attached to a local branch")) |
| 2818 | } |
| 2819 | HeadObservation::Unborn { symref } => { |
| 2820 | Err(git_error(format!("Git HEAD is unborn at '{symref}'"))) |
| 2821 | } |
| 2822 | HeadObservation::MissingTarget { symref } => Err(git_error(format!( |
| 2823 | "Git HEAD target '{symref}' does not exist" |
| 2824 | ))), |
| 2825 | } |
| 2826 | } |
| 2827 | |
| 2828 | /// The branch name used for reconcile direction classification. |
| 2829 | /// |
no test coverage detected