diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-25 14:37:17 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-25 14:37:17 +0100 |
| commit | d6faad17e814d252a72e3aca39a4b3898382bab9 (patch) | |
| tree | 16a238703293fe0d9cce04fa83de2af4a88f5433 /src/bin | |
| parent | 4f84dc460c3494286233afe9ca480d3b7c0186b1 (diff) | |
chore: bump rust-nostr v0.35
bump all rust-nostr packages
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/git_remote_nostr/fetch.rs | 6 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/list.rs | 2 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 38 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/utils.rs | 14 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/list.rs | 14 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/pull.rs | 9 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/push.rs | 11 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/send.rs | 4 |
8 files changed, 46 insertions, 52 deletions
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( | |||
| 112 | .context(format!( | 112 | .context(format!( |
| 113 | "cannot create commit for patch {}", | 113 | "cannot create commit for patch {}", |
| 114 | nip19::Nip19Event { | 114 | nip19::Nip19Event { |
| 115 | event_id: patch.id(), | 115 | event_id: patch.id, |
| 116 | author: Some(patch.author()), | 116 | author: Some(patch.pubkey), |
| 117 | kind: Some(patch.kind()), | 117 | kind: Some(patch.kind), |
| 118 | relays: if let Some(relay) = repo_ref.relays.first() { | 118 | relays: if let Some(relay) = repo_ref.relays.first() { |
| 119 | vec![relay.to_string()] | 119 | vec![relay.to_string()] |
| 120 | } else { | 120 | } 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( | |||
| 149 | if let Ok(cl) = event_to_cover_letter(&proposal) { | 149 | if let Ok(cl) = event_to_cover_letter(&proposal) { |
| 150 | if let Ok(mut branch_name) = cl.get_branch_name() { | 150 | if let Ok(mut branch_name) = cl.get_branch_name() { |
| 151 | branch_name = if let Some(public_key) = current_user { | 151 | branch_name = if let Some(public_key) = current_user { |
| 152 | if proposal.author().eq(&public_key) { | 152 | if proposal.pubkey.eq(&public_key) { |
| 153 | cl.branch_name.to_string() | 153 | cl.branch_name.to_string() |
| 154 | } else { | 154 | } else { |
| 155 | branch_name | 155 | 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( | |||
| 184 | if let Some((_, (proposal, patches))) = | 184 | if let Some((_, (proposal, patches))) = |
| 185 | find_proposal_and_patches_by_branch_name(to, &all_proposals, ¤t_user) | 185 | find_proposal_and_patches_by_branch_name(to, &all_proposals, ¤t_user) |
| 186 | { | 186 | { |
| 187 | if [repo_ref.maintainers.clone(), vec![proposal.author()]] | 187 | if [repo_ref.maintainers.clone(), vec![proposal.pubkey]] |
| 188 | .concat() | 188 | .concat() |
| 189 | .contains(&user_ref.public_key) | 189 | .contains(&user_ref.public_key) |
| 190 | { | 190 | { |
| @@ -200,7 +200,7 @@ pub async fn run_push( | |||
| 200 | &ahead, | 200 | &ahead, |
| 201 | &signer, | 201 | &signer, |
| 202 | repo_ref, | 202 | repo_ref, |
| 203 | &Some(proposal.id().to_string()), | 203 | &Some(proposal.id.to_string()), |
| 204 | &[], | 204 | &[], |
| 205 | ) | 205 | ) |
| 206 | .await? | 206 | .await? |
| @@ -223,7 +223,7 @@ pub async fn run_push( | |||
| 223 | root_event_id | 223 | root_event_id |
| 224 | } else { | 224 | } else { |
| 225 | // tip patch is the root proposal | 225 | // tip patch is the root proposal |
| 226 | tip_patch.id() | 226 | tip_patch.id |
| 227 | }; | 227 | }; |
| 228 | let mut parent_patch = tip_patch.clone(); | 228 | let mut parent_patch = tip_patch.clone(); |
| 229 | ahead.reverse(); | 229 | ahead.reverse(); |
| @@ -235,7 +235,7 @@ pub async fn run_push( | |||
| 235 | Some(thread_id), | 235 | Some(thread_id), |
| 236 | &signer, | 236 | &signer, |
| 237 | repo_ref, | 237 | repo_ref, |
| 238 | Some(parent_patch.id()), | 238 | Some(parent_patch.id), |
| 239 | Some(( | 239 | Some(( |
| 240 | (patches.len() + i + 1).try_into().unwrap(), | 240 | (patches.len() + i + 1).try_into().unwrap(), |
| 241 | (patches.len() + ahead.len()).try_into().unwrap(), | 241 | (patches.len() + ahead.len()).try_into().unwrap(), |
| @@ -901,8 +901,8 @@ async fn get_merged_status_events( | |||
| 901 | .await?; | 901 | .await?; |
| 902 | if let Some(commit_event) = commit_events.iter().find(|e| { | 902 | if let Some(commit_event) = commit_events.iter().find(|e| { |
| 903 | e.tags.iter().any(|t| { | 903 | e.tags.iter().any(|t| { |
| 904 | t.as_vec()[0].eq("commit") | 904 | t.as_slice()[0].eq("commit") |
| 905 | && t.as_vec()[1].eq(&parent.id().to_string()) | 905 | && t.as_slice()[1].eq(&parent.id().to_string()) |
| 906 | }) | 906 | }) |
| 907 | }) { | 907 | }) { |
| 908 | let (proposal_id, revision_id) = | 908 | let (proposal_id, revision_id) = |
| @@ -930,7 +930,7 @@ async fn get_merged_status_events( | |||
| 930 | None | 930 | None |
| 931 | }, | 931 | }, |
| 932 | &commit_hash, | 932 | &commit_hash, |
| 933 | commit_event.id(), | 933 | commit_event.id, |
| 934 | ) | 934 | ) |
| 935 | .await?, | 935 | .await?, |
| 936 | ); | 936 | ); |
| @@ -956,9 +956,9 @@ async fn create_merge_status( | |||
| 956 | .iter() | 956 | .iter() |
| 957 | .copied() | 957 | .copied() |
| 958 | .collect::<HashSet<PublicKey>>(); | 958 | .collect::<HashSet<PublicKey>>(); |
| 959 | public_keys.insert(proposal.author()); | 959 | public_keys.insert(proposal.pubkey); |
| 960 | if let Some(revision) = revision { | 960 | if let Some(revision) = revision { |
| 961 | public_keys.insert(revision.author()); | 961 | public_keys.insert(revision.pubkey); |
| 962 | } | 962 | } |
| 963 | sign_event( | 963 | sign_event( |
| 964 | EventBuilder::new( | 964 | EventBuilder::new( |
| @@ -971,7 +971,7 @@ async fn create_merge_status( | |||
| 971 | vec!["git proposal merged / applied".to_string()], | 971 | vec!["git proposal merged / applied".to_string()], |
| 972 | ), | 972 | ), |
| 973 | Tag::from_standardized(nostr::TagStandard::Event { | 973 | Tag::from_standardized(nostr::TagStandard::Event { |
| 974 | event_id: proposal.id(), | 974 | event_id: proposal.id, |
| 975 | relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::new), | 975 | relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::new), |
| 976 | marker: Some(Marker::Root), | 976 | marker: Some(Marker::Root), |
| 977 | public_key: None, | 977 | public_key: None, |
| @@ -985,7 +985,7 @@ async fn create_merge_status( | |||
| 985 | ], | 985 | ], |
| 986 | if let Some(revision) = revision { | 986 | if let Some(revision) = revision { |
| 987 | vec![Tag::from_standardized(nostr::TagStandard::Event { | 987 | vec![Tag::from_standardized(nostr::TagStandard::Event { |
| 988 | event_id: revision.id(), | 988 | event_id: revision.id, |
| 989 | relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::new), | 989 | relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::new), |
| 990 | marker: Some(Marker::Root), | 990 | marker: Some(Marker::Root), |
| 991 | public_key: None, | 991 | public_key: None, |
| @@ -1023,7 +1023,7 @@ async fn get_proposal_and_revision_root_from_patch( | |||
| 1023 | git_repo: &Repo, | 1023 | git_repo: &Repo, |
| 1024 | patch: &Event, | 1024 | patch: &Event, |
| 1025 | ) -> Result<(EventId, Option<EventId>)> { | 1025 | ) -> Result<(EventId, Option<EventId>)> { |
| 1026 | let proposal_or_revision = if patch.tags.iter().any(|t| t.as_vec()[1].eq("root")) { | 1026 | let proposal_or_revision = if patch.tags.iter().any(|t| t.as_slice()[1].eq("root")) { |
| 1027 | patch.clone() | 1027 | patch.clone() |
| 1028 | } else { | 1028 | } else { |
| 1029 | let proposal_or_revision_id = EventId::parse( | 1029 | let proposal_or_revision_id = EventId::parse( |
| @@ -1032,9 +1032,9 @@ async fn get_proposal_and_revision_root_from_patch( | |||
| 1032 | } else if let Some(t) = patch.tags.iter().find(|t| t.is_reply()) { | 1032 | } else if let Some(t) = patch.tags.iter().find(|t| t.is_reply()) { |
| 1033 | t.clone() | 1033 | t.clone() |
| 1034 | } else { | 1034 | } else { |
| 1035 | Tag::event(patch.id()) | 1035 | Tag::event(patch.id) |
| 1036 | } | 1036 | } |
| 1037 | .as_vec()[1] | 1037 | .as_slice()[1] |
| 1038 | .clone(), | 1038 | .clone(), |
| 1039 | )?; | 1039 | )?; |
| 1040 | 1040 | ||
| @@ -1048,14 +1048,14 @@ async fn get_proposal_and_revision_root_from_patch( | |||
| 1048 | .clone() | 1048 | .clone() |
| 1049 | }; | 1049 | }; |
| 1050 | 1050 | ||
| 1051 | if !proposal_or_revision.kind().eq(&Kind::GitPatch) { | 1051 | if !proposal_or_revision.kind.eq(&Kind::GitPatch) { |
| 1052 | bail!("thread root is not a git patch"); | 1052 | bail!("thread root is not a git patch"); |
| 1053 | } | 1053 | } |
| 1054 | 1054 | ||
| 1055 | if proposal_or_revision | 1055 | if proposal_or_revision |
| 1056 | .tags | 1056 | .tags |
| 1057 | .iter() | 1057 | .iter() |
| 1058 | .any(|t| t.as_vec()[1].eq("revision-root")) | 1058 | .any(|t| t.as_slice()[1].eq("revision-root")) |
| 1059 | { | 1059 | { |
| 1060 | Ok(( | 1060 | Ok(( |
| 1061 | EventId::parse( | 1061 | EventId::parse( |
| @@ -1064,13 +1064,13 @@ async fn get_proposal_and_revision_root_from_patch( | |||
| 1064 | .iter() | 1064 | .iter() |
| 1065 | .find(|t| t.is_reply()) | 1065 | .find(|t| t.is_reply()) |
| 1066 | .unwrap() | 1066 | .unwrap() |
| 1067 | .as_vec()[1] | 1067 | .as_slice()[1] |
| 1068 | .clone(), | 1068 | .clone(), |
| 1069 | )?, | 1069 | )?, |
| 1070 | Some(proposal_or_revision.id()), | 1070 | Some(proposal_or_revision.id), |
| 1071 | )) | 1071 | )) |
| 1072 | } else { | 1072 | } else { |
| 1073 | Ok((proposal_or_revision.id(), None)) | 1073 | Ok((proposal_or_revision.id, None)) |
| 1074 | } | 1074 | } |
| 1075 | } | 1075 | } |
| 1076 | 1076 | ||
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( | |||
| 113 | vec![ | 113 | vec![ |
| 114 | nostr::Filter::default() | 114 | nostr::Filter::default() |
| 115 | .kinds(status_kinds().clone()) | 115 | .kinds(status_kinds().clone()) |
| 116 | .events(proposals.iter().map(nostr::Event::id)), | 116 | .events(proposals.iter().map(|e| e.id)), |
| 117 | ], | 117 | ], |
| 118 | ) | 118 | ) |
| 119 | .await?; | 119 | .await?; |
| @@ -127,15 +127,15 @@ pub async fn get_open_proposals( | |||
| 127 | let status = if let Some(e) = statuses | 127 | let status = if let Some(e) = statuses |
| 128 | .iter() | 128 | .iter() |
| 129 | .filter(|e| { | 129 | .filter(|e| { |
| 130 | status_kinds().contains(&e.kind()) | 130 | status_kinds().contains(&e.kind) |
| 131 | && e.tags() | 131 | && e.tags |
| 132 | .iter() | 132 | .iter() |
| 133 | .any(|t| t.as_vec()[1].eq(&proposal.id.to_string())) | 133 | .any(|t| t.as_slice()[1].eq(&proposal.id.to_string())) |
| 134 | }) | 134 | }) |
| 135 | .collect::<Vec<&nostr::Event>>() | 135 | .collect::<Vec<&nostr::Event>>() |
| 136 | .first() | 136 | .first() |
| 137 | { | 137 | { |
| 138 | e.kind() | 138 | e.kind |
| 139 | } else { | 139 | } else { |
| 140 | Kind::GitStatusOpen | 140 | Kind::GitStatusOpen |
| 141 | }; | 141 | }; |
| @@ -148,7 +148,7 @@ pub async fn get_open_proposals( | |||
| 148 | get_most_recent_patch_with_ancestors(commits_events.clone()) | 148 | get_most_recent_patch_with_ancestors(commits_events.clone()) |
| 149 | { | 149 | { |
| 150 | open_proposals | 150 | open_proposals |
| 151 | .insert(proposal.id(), (proposal, most_recent_proposal_patch_chain)); | 151 | .insert(proposal.id, (proposal, most_recent_proposal_patch_chain)); |
| 152 | } | 152 | } |
| 153 | } | 153 | } |
| 154 | } | 154 | } |
| @@ -178,7 +178,7 @@ pub async fn get_all_proposals( | |||
| 178 | if let Ok(most_recent_proposal_patch_chain) = | 178 | if let Ok(most_recent_proposal_patch_chain) = |
| 179 | get_most_recent_patch_with_ancestors(commits_events.clone()) | 179 | get_most_recent_patch_with_ancestors(commits_events.clone()) |
| 180 | { | 180 | { |
| 181 | all_proposals.insert(proposal.id(), (proposal, most_recent_proposal_patch_chain)); | 181 | all_proposals.insert(proposal.id, (proposal, most_recent_proposal_patch_chain)); |
| 182 | } | 182 | } |
| 183 | } | 183 | } |
| 184 | } | 184 | } |
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<()> { | |||
| 52 | vec![ | 52 | vec![ |
| 53 | nostr::Filter::default() | 53 | nostr::Filter::default() |
| 54 | .kinds(status_kinds().clone()) | 54 | .kinds(status_kinds().clone()) |
| 55 | .events(proposals_and_revisions.iter().map(nostr::Event::id)), | 55 | .events(proposals_and_revisions.iter().map(|e| e.id)), |
| 56 | ], | 56 | ], |
| 57 | ) | 57 | ) |
| 58 | .await?; | 58 | .await?; |
| @@ -76,15 +76,15 @@ pub async fn launch() -> Result<()> { | |||
| 76 | let status = if let Some(e) = statuses | 76 | let status = if let Some(e) = statuses |
| 77 | .iter() | 77 | .iter() |
| 78 | .filter(|e| { | 78 | .filter(|e| { |
| 79 | status_kinds().contains(&e.kind()) | 79 | status_kinds().contains(&e.kind) |
| 80 | && e.tags() | 80 | && e.tags |
| 81 | .iter() | 81 | .iter() |
| 82 | .any(|t| t.as_vec()[1].eq(&proposal.id.to_string())) | 82 | .any(|t| t.as_slice()[1].eq(&proposal.id.to_string())) |
| 83 | }) | 83 | }) |
| 84 | .collect::<Vec<&nostr::Event>>() | 84 | .collect::<Vec<&nostr::Event>>() |
| 85 | .first() | 85 | .first() |
| 86 | { | 86 | { |
| 87 | e.kind() | 87 | e.kind |
| 88 | } else { | 88 | } else { |
| 89 | Kind::GitStatusOpen | 89 | Kind::GitStatusOpen |
| 90 | }; | 90 | }; |
| @@ -184,7 +184,7 @@ pub async fn launch() -> Result<()> { | |||
| 184 | let commits_events: Vec<nostr::Event> = get_all_proposal_patch_events_from_cache( | 184 | let commits_events: Vec<nostr::Event> = get_all_proposal_patch_events_from_cache( |
| 185 | git_repo_path, | 185 | git_repo_path, |
| 186 | &repo_ref, | 186 | &repo_ref, |
| 187 | &proposals_for_status[selected_index].id(), | 187 | &proposals_for_status[selected_index].id, |
| 188 | ) | 188 | ) |
| 189 | .await?; | 189 | .await?; |
| 190 | 190 | ||
| @@ -704,7 +704,7 @@ fn save_patches_to_dir(mut patches: Vec<nostr::Event>, git_repo: &Repo) -> Resul | |||
| 704 | .truncate(true) | 704 | .truncate(true) |
| 705 | .open(path) | 705 | .open(path) |
| 706 | .context("open new patch file with write and truncate options")?; | 706 | .context("open new patch file with write and truncate options")?; |
| 707 | file.write_all(patch.content().as_bytes())?; | 707 | file.write_all(patch.content.as_bytes())?; |
| 708 | file.write_all("\n\n".as_bytes())?; | 708 | file.write_all("\n\n".as_bytes())?; |
| 709 | file.flush()?; | 709 | file.flush()?; |
| 710 | } | 710 | } |
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<()> { | |||
| 53 | .context("cannot find proposal that matches the current branch name")? | 53 | .context("cannot find proposal that matches the current branch name")? |
| 54 | .clone(); | 54 | .clone(); |
| 55 | 55 | ||
| 56 | let commit_events = get_all_proposal_patch_events_from_cache( | 56 | let commit_events = |
| 57 | git_repo_path, | 57 | get_all_proposal_patch_events_from_cache(git_repo_path, &repo_ref, &proposal_root_event.id) |
| 58 | &repo_ref, | 58 | .await?; |
| 59 | &proposal_root_event.id(), | ||
| 60 | ) | ||
| 61 | .await?; | ||
| 62 | 59 | ||
| 63 | let most_recent_proposal_patch_chain = | 60 | let most_recent_proposal_patch_chain = |
| 64 | get_most_recent_patch_with_ancestors(commit_events.clone()) | 61 | 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<()> { | |||
| 73 | .context("cannot find proposal that matches the current branch name")? | 73 | .context("cannot find proposal that matches the current branch name")? |
| 74 | .clone(); | 74 | .clone(); |
| 75 | 75 | ||
| 76 | let commit_events = get_all_proposal_patch_events_from_cache( | 76 | let commit_events = |
| 77 | git_repo_path, | 77 | get_all_proposal_patch_events_from_cache(git_repo_path, &repo_ref, &proposal_root_event.id) |
| 78 | &repo_ref, | 78 | .await?; |
| 79 | &proposal_root_event.id(), | ||
| 80 | ) | ||
| 81 | .await?; | ||
| 82 | 79 | ||
| 83 | let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commit_events) | 80 | let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commit_events) |
| 84 | .context("cannot get most recent patch for proposal")?; | 81 | .context("cannot get most recent patch for proposal")?; |
| @@ -191,7 +188,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 191 | Some(proposal_root_event.id), | 188 | Some(proposal_root_event.id), |
| 192 | &signer, | 189 | &signer, |
| 193 | &repo_ref, | 190 | &repo_ref, |
| 194 | patch_events.last().map(nostr::Event::id), | 191 | patch_events.last().map(|e| e.id), |
| 195 | None, | 192 | None, |
| 196 | None, | 193 | None, |
| 197 | &None, | 194 | &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 | |||
| 240 | if root_proposal_id.is_none() { | 240 | if root_proposal_id.is_none() { |
| 241 | if let Some(event) = events.first() { | 241 | if let Some(event) = events.first() { |
| 242 | let event_bech32 = if let Some(relay) = repo_ref.relays.first() { | 242 | let event_bech32 = if let Some(relay) = repo_ref.relays.first() { |
| 243 | Nip19Event::new(event.id(), vec![relay]).to_bech32()? | 243 | Nip19Event::new(event.id, vec![relay]).to_bech32()? |
| 244 | } else { | 244 | } else { |
| 245 | event.id().to_bech32()? | 245 | event.id.to_bech32()? |
| 246 | }; | 246 | }; |
| 247 | println!( | 247 | println!( |
| 248 | "{}", | 248 | "{}", |