Parent
[>]
1//! Git repository helpers used across route handlers. 2//! 3//! Provides convenience functions for common `gix` operations such as opening a 4//! repository, formatting commit dates, validating paths, and iterating 5//! references. The [`GitResultExt`] extension trait lets handlers convert gix 6//! errors into [`Error::GitCorrupt`] with a single `.corrupt()` call. 7 8use Path; 9 10use ByteSlice; 11use Timestamp; 12use ; 13 14use crate; 15 16/// Information about a tag for list views. 17 22 23/// Information about a branch for list views. 24 30 31/// Summary of a commit for log views. 32 38 39/// Annotation data for an annotated tag. 40 45 46/// Basic commit identity info (sha + author + date). 47 52 53/// Paginated commit log for a branch. 54 59 60/// A single entry in blame output. 61 68 69/// A single commit entry for the full ancestry graph view. 70 76 77/// Opens a repository at `root/{name}` or returns [`Error::RepoNotFound`]. 78 81 82/// Rejects paths containing non-normal [`Component`]s (e.g. `..`) to prevent 83/// directory traversal. 84 93 94/// Returns the commit's author timestamp as Unix seconds. 95 98 99/// Formats a commit's author date as a `YYYY-MM-DD` string in the commit's 100/// local timezone, returning `None` if the time cannot be parsed. 101 105 106/// Formats a commit's committer date as a `YYYY-MM-DD` string in the 107/// commit's local timezone, returning `None` if the time cannot be parsed. 108 113 114/// Converts a Unix timestamp + timezone offset into a `YYYY-MM-DD` string. 115 121 122/// Extension trait adding `.corrupt()` to `Result<T, E>` where `E: Display`. 123/// 124/// Converts an error into [`Error::GitCorrupt`] by calling `.to_string()` on 125/// the inner error value. This removes the need for repetitive 126/// `.map_err(|e| Error::GitCorrupt(e.to_string()))` chains. 127/// 128/// # Usage 129/// 130/// ```ignore 131/// use crate::git::GitResultExt as _; 132/// let repo = git_repo.references().corrupt()?; 133/// ``` 134 137 138 143 144/// Silently flattens a `Result<impl IntoIterator<Item = Result<T, E2>>, E1>` into 145/// an `Iterator<Item = T>`. 146/// 147/// Both the outer and inner `Result` layers are consumed via `.into_iter()` and 148/// `.flatten()`, so errors at either level are silently skipped. This matches 149/// the common git-ref iteration pattern where a single corrupt ref should not 150/// crash the page. 151 157 158/// Returns the total number of commits reachable from any ref in the 159/// repository. 160/// 161/// Collects all ref tips (branches, tags, remote-tracking refs, and detached 162/// HEAD), then walks the complete reachable commit graph using gix's 163/// commit-graph-aware traversal. This is consistent regardless of 164/// commit-graph availability. 165 199 200/// Loads all tags from a repository, sorted newest-first. 201/// Errors during iteration are silently skipped. 202 219 220/// Loads a single tag's annotation and its target commit. 221 251 252/// Loads all local branches from a repository, sorted with the default branch 253/// first, then by most recent commit. Errors during iteration are silently skipped. 254 277 278/// Loads a paginated log of commits reachable from the tip of a branch. 279 334 335/// Color palette for commit highlighting (matches commit.rs graph colors). 336const COLORS: & = &; 340 341 342 348 349/// Loads blame annotations for a file at `{sha}:{path}`. 350 387 388/// Loads up to `limit` commits starting from `after` (inclusive) or from 389/// HEAD when `after` is `None`. Returns an empty vec if the repo has no commits. 390 429 430 431