mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-11-29 14:10:27 +08:00
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:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user