Skip to content

Commit

Permalink
feat: add Commit::signature() to yield the PGP sigature of a commit…
Browse files Browse the repository at this point in the history
…, if present.
  • Loading branch information
Byron committed Aug 8, 2023
1 parent fb95ead commit 5c13459
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gix/src/object/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ impl<'repo> Commit<'repo> {
max_candidates: 10,
}
}

/// Extracts the PGP signature and the data that was used to create the signature, or `None` if it wasn't signed.
// TODO: make it possible to verify the signature, probably by wrapping `SignedData`. It's quite some work to do it properly.
pub fn signature(
&self,
) -> Result<Option<(std::borrow::Cow<'_, BStr>, gix_object::commit::SignedData<'_>)>, gix_object::decode::Error>
{
gix_object::CommitRefIter::signature(&self.data)
}
}

impl<'r> std::fmt::Debug for Commit<'r> {
Expand Down

0 comments on commit 5c13459

Please sign in to comment.