Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/command/stash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ impl Command for StashPop {
return Ok(None);
}
stash_refs.sort();
let last = stash_refs.last().unwrap().clone();
let commit_hash = refs.get_ref(&last)?.unwrap();
let last = stash_refs
.pop()
.ok_or_else(|| VctrlError::Other("no stash entries".into()))?;
let commit_hash = refs
.get_ref(&last)?
.ok_or_else(|| VctrlError::NotFound(format!("stash ref '{}' missing", last)))?;
let commit = store.get_commit(&commit_hash)?;
refs.delete_ref(&last)?;
Ok(Some(commit.tree))
Expand Down
13 changes: 3 additions & 10 deletions src/command/verify_commit.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use crate::codec::Encoder;
use crate::command::Command;
use crate::crypto::Verifier;
use crate::domain::hash::Hash;
use crate::domain::object::Object;
use crate::error::VctrlError;
use crate::hashing::Hasher;
use crate::storage::traits::{ObjectStore, RefStore};
use ed25519_dalek::{Signature, VerifyingKey};

pub struct VerifyCommit {
pub commit_hash: Hash,
pub verifying_key: VerifyingKey,
pub verifier: Box<dyn Verifier>,
pub encoder: Box<dyn Encoder>,
pub hasher: Box<dyn Hasher>,
}
Expand Down Expand Up @@ -47,13 +47,6 @@ impl Command for VerifyCommit {
self.encoder.encode_commit(&pre_sig_commit, &mut buf)?;
let pre_sig_hash = self.hasher.hash_commit_encoded(&buf);

let signature = Signature::try_from(sig_bytes.as_slice())
.map_err(|_| VctrlError::Other("invalid signature format".into()))?;

self.verifying_key
.verify_strict(pre_sig_hash.as_bytes(), &signature)
.map_err(|_| VctrlError::Other("signature verification failed".into()))?;

Ok(true)
self.verifier.verify(pre_sig_hash.as_bytes(), &sig_bytes)
}
}
Loading