(git: &GitRepository)
| 2852 | } |
| 2853 | |
| 2854 | fn current_attached_git_branch(git: &GitRepository) -> CliResult<String> { |
| 2855 | match observe_head(git).map_err(observation_error)? { |
| 2856 | HeadObservation::Attached { symref, .. } => symref |
| 2857 | .strip_prefix("refs/heads/") |
| 2858 | .map(str::to_string) |
| 2859 | .ok_or_else(|| git_error(format!("Git HEAD symref '{symref}' is not a local branch"))), |
| 2860 | HeadObservation::Detached { .. } => { |
| 2861 | Err(git_error("Git HEAD must be attached to a local branch")) |
| 2862 | } |
| 2863 | HeadObservation::Unborn { symref } => { |
| 2864 | Err(git_error(format!("Git HEAD is unborn at '{symref}'"))) |
| 2865 | } |
| 2866 | HeadObservation::MissingTarget { symref } => Err(git_error(format!( |
| 2867 | "Git HEAD target '{symref}' does not exist" |
| 2868 | ))), |
| 2869 | } |
| 2870 | } |
| 2871 | |
| 2872 | /// The branch name used for reconcile direction classification. |
| 2873 | /// |
no test coverage detected