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

Function current_git_branch_or_view

atomic-cli/src/commands/git/shim.rs:2833–2847  ·  view source on GitHub ↗

The branch name used for reconcile direction classification. An attached HEAD keeps its branch; a detached HEAD keeps the workspace view (§7.5): the symbolic branch did not change, so only commit/tree movement counts as a Git-side change and routes to the §7.5 import.

(git: &GitRepository, view: &str)

Source from the content-addressed store, hash-verified

2831/// view (§7.5): the symbolic branch did not change, so only commit/tree
2832/// movement counts as a Git-side change and routes to the §7.5 import.
2833fn current_git_branch_or_view(git: &GitRepository, view: &str) -> CliResult<String> {
2834 match observe_head(git).map_err(observation_error)? {
2835 HeadObservation::Attached { symref, .. } => symref
2836 .strip_prefix("refs/heads/")
2837 .map(str::to_string)
2838 .ok_or_else(|| git_error(format!("Git HEAD symref '{symref}' is not a local branch"))),
2839 HeadObservation::Detached { .. } => Ok(view.to_string()),
2840 HeadObservation::Unborn { symref } => {
2841 Err(git_error(format!("Git HEAD is unborn at '{symref}'")))
2842 }
2843 HeadObservation::MissingTarget { symref } => Err(git_error(format!(
2844 "Git HEAD target '{symref}' does not exist"
2845 ))),
2846 }
2847}
2848
2849pub(crate) fn require_clean_git_worktree(git: &GitRepository) -> CliResult<()> {
2850 let index = git

Callers 1

Calls 2

observe_headFunction · 0.85
git_errorFunction · 0.70

Tested by

no test coverage detected