# git-indexer
A Rust library for extracting git repository information (branches, commits, and file diffs).
## Installation
Add this to your `Cargo.toml`:
```toml
[dependencies]
git-indexer = "0.1.0"
```
## Usage
Extract git information from a repository:
```rust
use git_indexer::extraction::extract;
use std::path::Path;
fn main() -> git_indexer::Result<()> {
let git_info = extract(Path::new("/path/to/repo"))?;
println!("Branches: {}", git_info.branches.len());
println!("Commits: {}", git_info.commits.len());
for commit in &git_info.commits {
println!("{}: {}", &commit.id[..8], commit.message);
}
Ok(())
}
```
## What It Extracts
### Branches (`BranchInfo`)
- Branch name (local and remote)
- Current HEAD indicator
- Commit SHA the branch points to
### Commits (`CommitInfo`)
- Commit SHA
- Message (title)
- Author (name and email)
- Timestamp
- Parent commit SHAs
- File changes
### File Changes (`FileChange`)
- File path
- Change type (Added, Deleted, Modified, Renamed, Copied)
- Diff hunks with line-by-line changes
## Technical Details
- Pure Rust git implementation via `gix`
- Efficient diff generation with `imara-diff` (Histogram algorithm)
- Binary file detection (skips diff for binary files)
- File size limit: 10MB per file
## License
MIT License - see [LICENSE](LICENSE) for details.