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
use bstr::{BString, ByteSlice, ByteVec};
use git_object::Commit;
use crate::commit;
pub fn message(operation: &str, commit: &Commit) -> BString {
let mut out = BString::from(operation);
if let Some(commit_type) = commit_type_by_parents(commit.parents.len()) {
out.push_str(b" (");
out.extend_from_slice(commit_type.as_bytes());
out.push_byte(b')');
}
out.push_str(b": ");
out.extend_from_slice(&commit::summary(commit.message.as_bstr()));
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",
})
}