collin/anvil · a064a2b0
Add the missing last_commit_time that ui.rs already calls
Collin Richards · 2026-08-18 14:56 UTC · a064a2b0a02764789161f01801417d998a5b99ae · parent 8dce3447 · browse files
modifiedcrates/anvil-git/src/browse.rs+10 −0
| ⋯ 263 unchanged lines | |||
| 264 | 264 | Ok(id.to_string()) | |
| 265 | 265 | } | |
| 266 | 266 | ||
| 267 | + | /// The commit time (Unix seconds) of `HEAD`, or `None` for an empty repository | |
| 268 | + | /// (unborn `HEAD`). | |
| 269 | + | pub fn last_commit_time(repo_path: &Path) -> Result<Option<i64>> { | |
| 270 | + | let repo = gix::open(repo_path).map_err(read)?; | |
| 271 | + | match repo.head_commit() { | |
| 272 | + | Ok(commit) => Ok(Some(commit.time().map_err(read)?.seconds)), | |
| 273 | + | Err(_) => Ok(None), | |
| 274 | + | } | |
| 275 | + | } | |
| 276 | + | ||
| 267 | 277 | /// Walk commit history starting at `rev`, newest first, up to `limit` commits. | |
| 268 | 278 | pub fn commit_log(repo_path: &Path, rev: &str, limit: usize) -> Result<Vec<CommitInfo>> { | |
| 269 | 279 | let repo = gix::open(repo_path).map_err(read)?; | |
| ⋯ 293 unchanged lines | |||