List all local branches.
(repo_path: &Path)
| 497 | |
| 498 | /// List all local branches. |
| 499 | pub 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. |
| 519 | pub fn create_branch(repo_path: &Path, name: &str, base: &str) -> Result<()> { |
no test coverage detected