MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / current_attached_git_branch

Function current_attached_git_branch

atomic-cli/src/commands/git/shim.rs:2810–2826  ·  view source on GitHub ↗
(git: &GitRepository)

Source from the content-addressed store, hash-verified

2808}
2809
2810fn 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///

Callers 1

Calls 2

observe_headFunction · 0.85
git_errorFunction · 0.70

Tested by

no test coverage detected