From a645273433fe3a716dd9c43ad9276da066af6127 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 16 Feb 2024 20:41:59 +0000 Subject: refactor: remove reliance on 'commit' tag as part of nip34 compliance --- src/git.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/git.rs') diff --git a/src/git.rs b/src/git.rs index 113a63c..51b27fa 100644 --- a/src/git.rs +++ b/src/git.rs @@ -6,7 +6,7 @@ use anyhow::{bail, Context, Result}; use git2::{DiffOptions, Oid, Revwalk}; use nostr::prelude::{sha1::Hash as Sha1Hash, Hash}; -use crate::sub_commands::list::tag_value; +use crate::sub_commands::list::{get_commit_id_from_patch, tag_value}; pub struct Repo { git_repo: git2::Repository, @@ -363,7 +363,7 @@ impl RepoActions for Repo { .into_iter() .filter(|e| { !self - .does_commit_exist(&tag_value(e, "commit").unwrap()) + .does_commit_exist(&get_commit_id_from_patch(e).unwrap()) .unwrap() }) .collect(); @@ -517,7 +517,10 @@ fn apply_patch(git_repo: &Repo, patch: &nostr::Event) -> Result<()> { git2::ResetType::Mixed, None, )?; - if gpg_commit_id.to_string().eq(&tag_value(patch, "commit")?) { + if gpg_commit_id + .to_string() + .eq(&get_commit_id_from_patch(patch)?) + { return Ok(()); } } else { @@ -575,12 +578,12 @@ fn validate_patch_applied(git_repo: &Repo, patch: &nostr::Event) -> Result<()> { if !updated_commit_oid .to_string() - .eq(&tag_value(patch, "commit")?) + .eq(&get_commit_id_from_patch(patch)?) { bail!( "when applied the patch commit id ({}) doesn't match the one specified in the event tag ({})", updated_commit_oid.to_string(), - tag_value(patch, "commit")?, + get_commit_id_from_patch(patch)?, ) } } -- cgit v1.2.3