[gitalisk][repository] Implement proper listBranches functionality in Gitalisk
Problem to Solve
The CoreGitaliskRepository list_branches() method currently returns a hardcoded ["main"] vector instead of actually listing repository branches. We will need the ability to get a list of branches for a repository.
Proposal
- Replace hardcoded
list_branches()implementation in CoreGitaliskRepository with actual git branch listing - Use
git branchcommand to retrieve local branches from repository - Handle repositories with no branches (newly initialized repos)
- Add option to include remote branches if needed
- Ensure proper error handling for invalid repositories
- Update existing tests and add comprehensive branch listing test coverage
Further Details
Current Implementation:
rust
pub fn list_branches(&self) -> Result<Vec<String>, std::io::Error> { let branch_names: Vec<String> = vec!["main".to_string()]; Ok(branch_names) }
Acceptance Criteria:
- Method returns actual local branches present in repository
- Handles repositories with zero branches
- Handles repositories with non-standard default branch names
- Proper error handling for invalid or corrupted repositories
- Test coverage for various branch scenarios (single branch, multiple branches, no branches)
Implementation Notes:
- Use
git branch --format='%(refname:short)'for clean branch name output - Consider whether remote branches should be included or handled separately
- Could maybe use a option that can be passed to include remote branches
Links / References
- Epic: Replace Repository Service with Gitalisk (gitlab-org/rust&14)