1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use git_object::commit::MessageRef;
use git_ref::file::ReferenceExt;
use crate::{
bstr::{BStr, BString, ByteVec},
Reference,
};
impl<'repo> Reference<'repo> {
pub fn log_iter(&self) -> git_ref::file::log::iter::Platform<'_, '_> {
self.inner.log_iter(&self.repo.refs)
}
}
pub fn message(operation: &str, message: &BStr, num_parents: usize) -> BString {
let mut out = BString::from(operation);
if let Some(commit_type) = commit_type_by_parents(num_parents) {
out.push_str(b" (");
out.extend_from_slice(commit_type.as_bytes());
out.push_byte(b')');
}
out.push_str(b": ");
out.extend_from_slice(&MessageRef::from_bytes(message).summary());
out
}
pub(crate) fn commit_type_by_parents(count: usize) -> Option<&'static str> {
Some(match count {
0 => "initial",
1 => return None,
_two_or_more => "merge",
})
}