/// LFS operations reuse the crate-level `GitError`; this module re-exports it /// and documents how each variant must map onto the Git LFS HTTP API status /// codes (consumed by the future HTTP layer under `/{space}/{repo}.git/info/lfs`). pub use crate::share::errors::GitError; /// HTTP status for the LFS API: /// - not found → 404 (unknown repo / missing object / LFS disabled) /// - forbidden → 403 (unlock without ownership and without `force`) /// - conflict → 409 (duplicate lock / already exists) /// - invalid arg → 400 (bad oid, size over cap, empty lock path) /// - everything else → 500 pub fn http_status(err: &GitError) -> u16 { match err { GitError::NotFound => 404, GitError::Forbidden => 403, GitError::Conflict(_) => 409, GitError::InvalidArgument(_) => 400, GitError::Cache(_) | GitError::Git(_) | GitError::Internal(_) => 500, } } #[cfg(test)] mod tests { use super::*; #[test] fn maps_variants_to_http_codes() { assert_eq!(http_status(&GitError::NotFound), 404); assert_eq!(http_status(&GitError::Forbidden), 403); assert_eq!(http_status(&GitError::Conflict("dup".to_string())), 409); assert_eq!( http_status(&GitError::InvalidArgument("bad".to_string())), 400 ); assert_eq!(http_status(&GitError::Internal("boom".to_string())), 500); } }