git-metadata: Add `CommitData::strip_signatures`

To allow for the verification of a commit signature, the signature
needs to be stripped before converting the commit data to bytes.
This commit is contained in:
Fintan Halpenny 2026-02-24 15:14:42 +00:00 committed by Lorenz Leutgeb
parent 60871de89d
commit 58624148d4
2 changed files with 9 additions and 0 deletions

View File

@ -85,6 +85,11 @@ impl<Tree, Parent> CommitData<Tree, Parent> {
self.headers.signatures()
}
pub fn strip_signatures(mut self) -> Self {
self.headers.strip_signatures();
self
}
/// The [`Headers`] found in this commit.
///
/// Note: these do not include `tree`, `parent`, `author`, and `committer`.

View File

@ -70,6 +70,10 @@ impl Headers {
pub fn push(&mut self, name: &str, value: &str) {
self.0.push((name.to_owned(), value.trim().to_owned()));
}
pub(crate) fn strip_signatures(&mut self) {
self.0.retain(|(key, _)| key != "gpgsig");
}
}
#[derive(Debug, thiserror::Error)]