Unified · Split
| @@ -48,3 +48,30 @@ impl<'a> Display for Outcome<'a> { · 47 unmodified lines | ||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | pub type Error = (); |
| 51 | + | |
| 52 | +pub(crate) mod function { | |
| 53 | + use super::{Error, Outcome}; | |
| 54 | + use git_hash::{oid, ObjectId}; | |
| 55 | + use git_object::bstr::BStr; | |
| 56 | + use std::borrow::Cow; | |
| 57 | + use std::collections::HashMap; | |
| 58 | + | |
| 59 | + #[allow(clippy::result_unit_err)] | |
| 60 | + pub fn describe<'a>( | |
| 61 | + commit: &oid, | |
| 62 | + hex_len: usize, | |
| 63 | + name_set: &HashMap<ObjectId, Cow<'a, BStr>>, | |
| 64 | + ) -> Result<Option<Outcome<'a>>, Error> { | |
| 65 | + if let Some(name) = name_set.get(commit) { | |
| 66 | + return Ok(Some(Outcome { | |
| 67 | + name: name.to_owned(), | |
| 68 | + id: commit.to_owned(), | |
| 69 | + hex_len, | |
| 70 | + depth: 0, | |
| 71 | + long: false, | |
| 72 | + dirty_suffix: None, | |
| 73 | + })); | |
| 74 | + } | |
| 75 | + todo!("actually search for it") | |
| 76 | + } | |
| 77 | +} | |
| @@ -1,27 +1,4 @@ | ||
| 1 | 1 | #![forbid(unsafe_code, rust_2018_idioms)] |
| 2 | 2 | |
| 3 | −use git_hash::{oid, ObjectId}; | |
| 4 | −use git_object::bstr::BStr; | |
| 5 | −use std::borrow::Cow; | |
| 6 | −use std::collections::HashMap; | |
| 7 | − | |
| 8 | 3 | pub mod describe; |
| 9 | − | |
| 10 | −#[allow(clippy::result_unit_err)] | |
| 11 | −pub fn describe<'a>( | |
| 12 | − commit: &oid, | |
| 13 | − hex_len: usize, | |
| 14 | − name_set: &HashMap<ObjectId, Cow<'a, BStr>>, | |
| 15 | −) -> Result<Option<describe::Outcome<'a>>, describe::Error> { | |
| 16 | − if let Some(name) = name_set.get(commit) { | |
| 17 | − return Ok(Some(describe::Outcome { | |
| 18 | − name: name.to_owned(), | |
| 19 | − id: commit.to_owned(), | |
| 20 | − hex_len, | |
| 21 | − depth: 0, | |
| 22 | − long: false, | |
| 23 | − dirty_suffix: None, | |
| 24 | − })); | |
| 25 | − } | |
| 26 | − todo!("actually search for it") | |
| 27 | −} | |
| 4 | +pub use describe::function::describe; | |