Merge remote-tracking branch 'origin/update-doc'

* origin/update-doc:
  update docs and add test for commit signature

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
This commit is contained in:
Fintan Halpenny
2023-02-09 09:48:52 +00:00
4 changed files with 26 additions and 4 deletions
+1
View File
@@ -21,6 +21,7 @@
use crate::{commit, diff, fs, glob, namespace, refs, repo};
use thiserror::Error;
/// The crate level error type that wraps up module level error types.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
+1 -1
View File
@@ -36,7 +36,7 @@
pub use git_ref_format;
/// Represents an object id in Git. Re-exported from `radicle-git-ext`.
pub use radicle_git_ext::Oid;
pub type Oid = radicle_git_ext::Oid;
pub mod blob;
pub mod diff;
+6 -3
View File
@@ -375,19 +375,22 @@ impl Repository {
///
/// # Arguments
///
/// `commit_oid` - The object ID of the commit
/// `field` - the name of the header field containing the signature block;
/// pass `None` to extract the default 'gpgsig'
pub fn extract_signature(
&self,
commit_oid: &Oid,
commit: impl ToCommit,
field: Option<&str>,
) -> Result<Option<Signature>, Error> {
// Match is necessary here because according to the documentation for
// git_commit_extract_signature at
// https://libgit2.org/libgit2/#HEAD/group/commit/git_commit_extract_signature
// the return value for a commit without a signature will be GIT_ENOTFOUND
match self.inner.extract_signature(commit_oid, field) {
let commit = commit
.to_commit(self)
.map_err(|e| Error::ToCommit(e.into()))?;
match self.inner.extract_signature(&commit.id, field) {
Err(error) => {
if error.code() == git2::ErrorCode::NotFound {
Ok(None)