MCPcopy Index your code
hub / github.com/AI45Lab/Code / list_branches

Function list_branches

core/src/git.rs:499–516  ·  view source on GitHub ↗

List all local branches.

(repo_path: &Path)

Source from the content-addressed store, hash-verified

497
498/// List all local branches.
499pub fn list_branches(repo_path: &Path) -> Result<Vec<BranchInfo>> {
500 let (_, stdout, _) = run_git(repo_path, &["branch"])?;
501
502 let branches: Vec<BranchInfo> = stdout
503 .lines()
504 .filter_map(|line| {
505 let line = line.trim();
506 if line.is_empty() {
507 return None;
508 }
509 let is_current = line.starts_with('*');
510 let name = line.trim_start_matches(['*', ' ']).to_string();
511 Some(BranchInfo { name, is_current })
512 })
513 .collect();
514
515 Ok(branches)
516}
517
518/// Create a new branch.
519pub fn create_branch(repo_path: &Path, name: &str, base: &str) -> Result<()> {

Callers 1

list_branchesMethod · 0.85

Calls 2

run_gitFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected