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:2854–2870  ·  view source on GitHub ↗
(git: &GitRepository)

Source from the content-addressed store, hash-verified

2852}
2853
2854fn 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///

Callers 1

Calls 2

observe_headFunction · 0.85
git_errorFunction · 0.70

Tested by

no test coverage detected