MCPcopy Create free account
hub / github.com/dashed/git-chain / get_current_branch_name

Method get_current_branch_name

src/git_chain/core.rs:53–70  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

51 }
52
53 pub fn get_current_branch_name(&self) -> Result<String, Error> {
54 let head = match self.repo.head() {
55 Ok(head) => Some(head),
56 Err(ref e)
57 if e.code() == ErrorCode::UnbornBranch || e.code() == ErrorCode::NotFound =>
58 {
59 None
60 }
61 Err(e) => return Err(e),
62 };
63
64 let head = head.as_ref().and_then(|h| h.shorthand());
65
66 match head {
67 Some(branch_name) => Ok(branch_name.to_string()),
68 None => Err(Error::from_str("Unable to get current branch name.")),
69 }
70 }
71
72 pub fn get_local_git_config(&self) -> Result<Config, Error> {
73 self.repo.config()?.open_level(ConfigLevel::Local)

Callers 6

display_statusMethod · 0.80
runFunction · 0.80
rebaseMethod · 0.80
backupMethod · 0.80
run_statusMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected