diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
commit | 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch) | |
tree | bdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/gix/src/reference/log.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff) | |
download | rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip |
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/reference/log.rs')
-rw-r--r-- | vendor/gix/src/reference/log.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/gix/src/reference/log.rs b/vendor/gix/src/reference/log.rs new file mode 100644 index 000000000..b516e6499 --- /dev/null +++ b/vendor/gix/src/reference/log.rs @@ -0,0 +1,36 @@ +//! +use gix_object::commit::MessageRef; +use gix_ref::file::ReferenceExt; + +use crate::{ + bstr::{BStr, BString, ByteVec}, + Reference, +}; + +impl<'repo> Reference<'repo> { + /// Return a platform for obtaining iterators over reference logs. + pub fn log_iter(&self) -> gix_ref::file::log::iter::Platform<'_, '_> { + self.inner.log_iter(&self.repo.refs) + } +} + +/// Generate a message typical for git commit logs based on the given `operation`, commit `message` and `num_parents` of the commit. +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", + }) +} |