upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/git_remote_nostr')
-rw-r--r--src/bin/git_remote_nostr/fetch.rs6
-rw-r--r--src/bin/git_remote_nostr/list.rs2
-rw-r--r--src/bin/git_remote_nostr/push.rs38
-rw-r--r--src/bin/git_remote_nostr/utils.rs14
4 files changed, 30 insertions, 30 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, &current_user) 185 find_proposal_and_patches_by_branch_name(to, &all_proposals, &current_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 }