From d6faad17e814d252a72e3aca39a4b3898382bab9 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 25 Sep 2024 14:37:17 +0100 Subject: chore: bump rust-nostr v0.35 bump all rust-nostr packages --- src/bin/git_remote_nostr/fetch.rs | 6 +++--- src/bin/git_remote_nostr/list.rs | 2 +- src/bin/git_remote_nostr/push.rs | 38 +++++++++++++++++++------------------- src/bin/git_remote_nostr/utils.rs | 14 +++++++------- src/bin/ngit/sub_commands/list.rs | 14 +++++++------- src/bin/ngit/sub_commands/pull.rs | 9 +++------ src/bin/ngit/sub_commands/push.rs | 11 ++++------- src/bin/ngit/sub_commands/send.rs | 4 ++-- 8 files changed, 46 insertions(+), 52 deletions(-) (limited to 'src/bin') diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index ff55d6f..a972a2f 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs @@ -112,9 +112,9 @@ pub fn make_commits_for_proposal( .context(format!( "cannot create commit for patch {}", nip19::Nip19Event { - event_id: patch.id(), - author: Some(patch.author()), - kind: Some(patch.kind()), + event_id: patch.id, + author: Some(patch.pubkey), + kind: Some(patch.kind), relays: if let Some(relay) = repo_ref.relays.first() { vec![relay.to_string()] } else { diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs index 378a124..2f2977e 100644 --- a/src/bin/git_remote_nostr/list.rs +++ b/src/bin/git_remote_nostr/list.rs @@ -149,7 +149,7 @@ async fn get_open_proposals_state( if let Ok(cl) = event_to_cover_letter(&proposal) { if let Ok(mut branch_name) = cl.get_branch_name() { branch_name = if let Some(public_key) = current_user { - if proposal.author().eq(&public_key) { + if proposal.pubkey.eq(&public_key) { cl.branch_name.to_string() } else { branch_name diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 0f4e792..db86c04 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -184,7 +184,7 @@ pub async fn run_push( if let Some((_, (proposal, patches))) = find_proposal_and_patches_by_branch_name(to, &all_proposals, ¤t_user) { - if [repo_ref.maintainers.clone(), vec![proposal.author()]] + if [repo_ref.maintainers.clone(), vec![proposal.pubkey]] .concat() .contains(&user_ref.public_key) { @@ -200,7 +200,7 @@ pub async fn run_push( &ahead, &signer, repo_ref, - &Some(proposal.id().to_string()), + &Some(proposal.id.to_string()), &[], ) .await? @@ -223,7 +223,7 @@ pub async fn run_push( root_event_id } else { // tip patch is the root proposal - tip_patch.id() + tip_patch.id }; let mut parent_patch = tip_patch.clone(); ahead.reverse(); @@ -235,7 +235,7 @@ pub async fn run_push( Some(thread_id), &signer, repo_ref, - Some(parent_patch.id()), + Some(parent_patch.id), Some(( (patches.len() + i + 1).try_into().unwrap(), (patches.len() + ahead.len()).try_into().unwrap(), @@ -901,8 +901,8 @@ async fn get_merged_status_events( .await?; if let Some(commit_event) = commit_events.iter().find(|e| { e.tags.iter().any(|t| { - t.as_vec()[0].eq("commit") - && t.as_vec()[1].eq(&parent.id().to_string()) + t.as_slice()[0].eq("commit") + && t.as_slice()[1].eq(&parent.id().to_string()) }) }) { let (proposal_id, revision_id) = @@ -930,7 +930,7 @@ async fn get_merged_status_events( None }, &commit_hash, - commit_event.id(), + commit_event.id, ) .await?, ); @@ -956,9 +956,9 @@ async fn create_merge_status( .iter() .copied() .collect::>(); - public_keys.insert(proposal.author()); + public_keys.insert(proposal.pubkey); if let Some(revision) = revision { - public_keys.insert(revision.author()); + public_keys.insert(revision.pubkey); } sign_event( EventBuilder::new( @@ -971,7 +971,7 @@ async fn create_merge_status( vec!["git proposal merged / applied".to_string()], ), Tag::from_standardized(nostr::TagStandard::Event { - event_id: proposal.id(), + event_id: proposal.id, relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::new), marker: Some(Marker::Root), public_key: None, @@ -985,7 +985,7 @@ async fn create_merge_status( ], if let Some(revision) = revision { vec![Tag::from_standardized(nostr::TagStandard::Event { - event_id: revision.id(), + event_id: revision.id, relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::new), marker: Some(Marker::Root), public_key: None, @@ -1023,7 +1023,7 @@ async fn get_proposal_and_revision_root_from_patch( git_repo: &Repo, patch: &Event, ) -> Result<(EventId, Option)> { - let proposal_or_revision = if patch.tags.iter().any(|t| t.as_vec()[1].eq("root")) { + let proposal_or_revision = if patch.tags.iter().any(|t| t.as_slice()[1].eq("root")) { patch.clone() } else { let proposal_or_revision_id = EventId::parse( @@ -1032,9 +1032,9 @@ async fn get_proposal_and_revision_root_from_patch( } else if let Some(t) = patch.tags.iter().find(|t| t.is_reply()) { t.clone() } else { - Tag::event(patch.id()) + Tag::event(patch.id) } - .as_vec()[1] + .as_slice()[1] .clone(), )?; @@ -1048,14 +1048,14 @@ async fn get_proposal_and_revision_root_from_patch( .clone() }; - if !proposal_or_revision.kind().eq(&Kind::GitPatch) { + if !proposal_or_revision.kind.eq(&Kind::GitPatch) { bail!("thread root is not a git patch"); } if proposal_or_revision .tags .iter() - .any(|t| t.as_vec()[1].eq("revision-root")) + .any(|t| t.as_slice()[1].eq("revision-root")) { Ok(( EventId::parse( @@ -1064,13 +1064,13 @@ async fn get_proposal_and_revision_root_from_patch( .iter() .find(|t| t.is_reply()) .unwrap() - .as_vec()[1] + .as_slice()[1] .clone(), )?, - Some(proposal_or_revision.id()), + Some(proposal_or_revision.id), )) } else { - Ok((proposal_or_revision.id(), None)) + Ok((proposal_or_revision.id, None)) } } diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index 3ae1bab..a8bbd6f 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs @@ -113,7 +113,7 @@ pub async fn get_open_proposals( vec![ nostr::Filter::default() .kinds(status_kinds().clone()) - .events(proposals.iter().map(nostr::Event::id)), + .events(proposals.iter().map(|e| e.id)), ], ) .await?; @@ -127,15 +127,15 @@ pub async fn get_open_proposals( let status = if let Some(e) = statuses .iter() .filter(|e| { - status_kinds().contains(&e.kind()) - && e.tags() + status_kinds().contains(&e.kind) + && e.tags .iter() - .any(|t| t.as_vec()[1].eq(&proposal.id.to_string())) + .any(|t| t.as_slice()[1].eq(&proposal.id.to_string())) }) .collect::>() .first() { - e.kind() + e.kind } else { Kind::GitStatusOpen }; @@ -148,7 +148,7 @@ pub async fn get_open_proposals( get_most_recent_patch_with_ancestors(commits_events.clone()) { open_proposals - .insert(proposal.id(), (proposal, most_recent_proposal_patch_chain)); + .insert(proposal.id, (proposal, most_recent_proposal_patch_chain)); } } } @@ -178,7 +178,7 @@ pub async fn get_all_proposals( if let Ok(most_recent_proposal_patch_chain) = get_most_recent_patch_with_ancestors(commits_events.clone()) { - all_proposals.insert(proposal.id(), (proposal, most_recent_proposal_patch_chain)); + all_proposals.insert(proposal.id, (proposal, most_recent_proposal_patch_chain)); } } } diff --git a/src/bin/ngit/sub_commands/list.rs b/src/bin/ngit/sub_commands/list.rs index 0755e3b..351896a 100644 --- a/src/bin/ngit/sub_commands/list.rs +++ b/src/bin/ngit/sub_commands/list.rs @@ -52,7 +52,7 @@ pub async fn launch() -> Result<()> { vec![ nostr::Filter::default() .kinds(status_kinds().clone()) - .events(proposals_and_revisions.iter().map(nostr::Event::id)), + .events(proposals_and_revisions.iter().map(|e| e.id)), ], ) .await?; @@ -76,15 +76,15 @@ pub async fn launch() -> Result<()> { let status = if let Some(e) = statuses .iter() .filter(|e| { - status_kinds().contains(&e.kind()) - && e.tags() + status_kinds().contains(&e.kind) + && e.tags .iter() - .any(|t| t.as_vec()[1].eq(&proposal.id.to_string())) + .any(|t| t.as_slice()[1].eq(&proposal.id.to_string())) }) .collect::>() .first() { - e.kind() + e.kind } else { Kind::GitStatusOpen }; @@ -184,7 +184,7 @@ pub async fn launch() -> Result<()> { let commits_events: Vec = get_all_proposal_patch_events_from_cache( git_repo_path, &repo_ref, - &proposals_for_status[selected_index].id(), + &proposals_for_status[selected_index].id, ) .await?; @@ -704,7 +704,7 @@ fn save_patches_to_dir(mut patches: Vec, git_repo: &Repo) -> Resul .truncate(true) .open(path) .context("open new patch file with write and truncate options")?; - file.write_all(patch.content().as_bytes())?; + file.write_all(patch.content.as_bytes())?; file.write_all("\n\n".as_bytes())?; file.flush()?; } diff --git a/src/bin/ngit/sub_commands/pull.rs b/src/bin/ngit/sub_commands/pull.rs index 9a3d911..d79b7b1 100644 --- a/src/bin/ngit/sub_commands/pull.rs +++ b/src/bin/ngit/sub_commands/pull.rs @@ -53,12 +53,9 @@ pub async fn launch() -> Result<()> { .context("cannot find proposal that matches the current branch name")? .clone(); - let commit_events = get_all_proposal_patch_events_from_cache( - git_repo_path, - &repo_ref, - &proposal_root_event.id(), - ) - .await?; + let commit_events = + get_all_proposal_patch_events_from_cache(git_repo_path, &repo_ref, &proposal_root_event.id) + .await?; let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commit_events.clone()) diff --git a/src/bin/ngit/sub_commands/push.rs b/src/bin/ngit/sub_commands/push.rs index 66edfb4..a77f356 100644 --- a/src/bin/ngit/sub_commands/push.rs +++ b/src/bin/ngit/sub_commands/push.rs @@ -73,12 +73,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { .context("cannot find proposal that matches the current branch name")? .clone(); - let commit_events = get_all_proposal_patch_events_from_cache( - git_repo_path, - &repo_ref, - &proposal_root_event.id(), - ) - .await?; + let commit_events = + get_all_proposal_patch_events_from_cache(git_repo_path, &repo_ref, &proposal_root_event.id) + .await?; let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commit_events) .context("cannot get most recent patch for proposal")?; @@ -191,7 +188,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { Some(proposal_root_event.id), &signer, &repo_ref, - patch_events.last().map(nostr::Event::id), + patch_events.last().map(|e| e.id), None, None, &None, diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index a807305..fe2952f 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs @@ -240,9 +240,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re if root_proposal_id.is_none() { if let Some(event) = events.first() { let event_bech32 = if let Some(relay) = repo_ref.relays.first() { - Nip19Event::new(event.id(), vec![relay]).to_bech32()? + Nip19Event::new(event.id, vec![relay]).to_bech32()? } else { - event.id().to_bech32()? + event.id.to_bech32()? }; println!( "{}", -- cgit v1.2.3