diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-27 17:08:25 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-27 17:08:25 +0000 |
| commit | 83448a99aaf18c7a045a081c5de0c22bc4a83de1 (patch) | |
| tree | 28076a33b40e63937d79a8fe8d54b58d42db092c /src/bin | |
| parent | 5478aa74cc26452809e499a461067ca9744cb7ce (diff) | |
chore: bump rust-nosrt v0.37.0
use RelayUrl in repo_ref which I had resisted as it mutates relay
urls when printed to append a slash
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 15 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/init.rs | 63 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/send.rs | 3 |
3 files changed, 54 insertions, 27 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 381a45e..d8ba65a 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -961,9 +961,7 @@ async fn create_merge_status( | |||
| 961 | public_keys.insert(revision.pubkey); | 961 | public_keys.insert(revision.pubkey); |
| 962 | } | 962 | } |
| 963 | sign_event( | 963 | sign_event( |
| 964 | EventBuilder::new( | 964 | EventBuilder::new(nostr::event::Kind::GitStatusApplied, String::new()).tags( |
| 965 | nostr::event::Kind::GitStatusApplied, | ||
| 966 | String::new(), | ||
| 967 | [ | 965 | [ |
| 968 | vec![ | 966 | vec![ |
| 969 | Tag::custom( | 967 | Tag::custom( |
| @@ -972,23 +970,26 @@ async fn create_merge_status( | |||
| 972 | ), | 970 | ), |
| 973 | Tag::from_standardized(nostr::TagStandard::Event { | 971 | Tag::from_standardized(nostr::TagStandard::Event { |
| 974 | event_id: proposal.id, | 972 | event_id: proposal.id, |
| 975 | relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::new), | 973 | relay_url: repo_ref.relays.first().cloned(), |
| 976 | marker: Some(Marker::Root), | 974 | marker: Some(Marker::Root), |
| 977 | public_key: None, | 975 | public_key: None, |
| 976 | uppercase: false, | ||
| 978 | }), | 977 | }), |
| 979 | Tag::from_standardized(nostr::TagStandard::Event { | 978 | Tag::from_standardized(nostr::TagStandard::Event { |
| 980 | event_id: merged_patch, | 979 | event_id: merged_patch, |
| 981 | relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::new), | 980 | relay_url: repo_ref.relays.first().cloned(), |
| 982 | marker: Some(Marker::Mention), | 981 | marker: Some(Marker::Mention), |
| 983 | public_key: None, | 982 | public_key: None, |
| 983 | uppercase: false, | ||
| 984 | }), | 984 | }), |
| 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().cloned(), |
| 990 | marker: Some(Marker::Root), | 990 | marker: Some(Marker::Root), |
| 991 | public_key: None, | 991 | public_key: None, |
| 992 | uppercase: false, | ||
| 992 | })] | 993 | })] |
| 993 | } else { | 994 | } else { |
| 994 | vec![] | 995 | vec![] |
| @@ -1202,7 +1203,7 @@ impl BuildRepoState for RepoState { | |||
| 1202 | vec![value.clone()], | 1203 | vec![value.clone()], |
| 1203 | )); | 1204 | )); |
| 1204 | } | 1205 | } |
| 1205 | let event = sign_event(EventBuilder::new(STATE_KIND, "", tags), signer).await?; | 1206 | let event = sign_event(EventBuilder::new(STATE_KIND, "").tags(tags), signer).await?; |
| 1206 | Ok(RepoState { | 1207 | Ok(RepoState { |
| 1207 | identifier, | 1208 | identifier, |
| 1208 | state, | 1209 | state, |
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 2af6aef..0d3e344 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs | |||
| @@ -3,7 +3,7 @@ use std::collections::HashMap; | |||
| 3 | use anyhow::{Context, Result}; | 3 | use anyhow::{Context, Result}; |
| 4 | use ngit::cli_interactor::PromptConfirmParms; | 4 | use ngit::cli_interactor::PromptConfirmParms; |
| 5 | use nostr::{nips::nip01::Coordinate, FromBech32, PublicKey, ToBech32}; | 5 | use nostr::{nips::nip01::Coordinate, FromBech32, PublicKey, ToBech32}; |
| 6 | use nostr_sdk::Kind; | 6 | use nostr_sdk::{Kind, RelayUrl}; |
| 7 | 7 | ||
| 8 | use crate::{ | 8 | use crate::{ |
| 9 | cli::{extract_signer_cli_arguments, Cli}, | 9 | cli::{extract_signer_cli_arguments, Cli}, |
| @@ -323,24 +323,45 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 323 | 323 | ||
| 324 | // TODO: check if relays are free to post to so contributors can submit patches | 324 | // TODO: check if relays are free to post to so contributors can submit patches |
| 325 | // TODO: recommend some reliable free ones | 325 | // TODO: recommend some reliable free ones |
| 326 | let relays: Vec<String> = if args.relays.is_empty() { | 326 | let relays: Vec<RelayUrl> = { |
| 327 | Interactor::default() | 327 | let mut default = if let Ok(config) = &repo_config_result { |
| 328 | .input( | 328 | config.relays.clone().join(" ") |
| 329 | PromptInputParms::default() | 329 | } else if let Some(repo_ref) = &repo_ref { |
| 330 | .with_prompt("relays") | 330 | repo_ref |
| 331 | .with_default(if let Ok(config) = &repo_config_result { | 331 | .relays |
| 332 | config.relays.clone().join(" ") | 332 | .iter() |
| 333 | } else if let Some(repo_ref) = &repo_ref { | 333 | .map(std::string::ToString::to_string) |
| 334 | repo_ref.relays.clone().join(" ") | 334 | .collect::<Vec<String>>() |
| 335 | } else { | 335 | .join(" ") |
| 336 | user_ref.relays.write().join(" ") | 336 | } else { |
| 337 | }), | 337 | user_ref.relays.write().join(" ") |
| 338 | )? | 338 | }; |
| 339 | .split(' ') | 339 | 'outer: loop { |
| 340 | .map(std::string::ToString::to_string) | 340 | let relays: Vec<String> = if args.relays.is_empty() { |
| 341 | .collect() | 341 | Interactor::default() |
| 342 | } else { | 342 | .input( |
| 343 | args.relays.clone() | 343 | PromptInputParms::default() |
| 344 | .with_prompt("relays") | ||
| 345 | .with_default(default), | ||
| 346 | )? | ||
| 347 | .split(' ') | ||
| 348 | .map(std::string::ToString::to_string) | ||
| 349 | .collect() | ||
| 350 | } else { | ||
| 351 | args.relays.clone() | ||
| 352 | }; | ||
| 353 | let mut relay_urls = vec![]; | ||
| 354 | for r in &relays { | ||
| 355 | if let Ok(r) = RelayUrl::parse(r) { | ||
| 356 | relay_urls.push(r); | ||
| 357 | } else { | ||
| 358 | eprintln!("{r} is not a valid relay url"); | ||
| 359 | default = relays.join(" "); | ||
| 360 | continue 'outer; | ||
| 361 | } | ||
| 362 | } | ||
| 363 | break relay_urls; | ||
| 364 | } | ||
| 344 | }; | 365 | }; |
| 345 | 366 | ||
| 346 | let earliest_unique_commit = match &args.earliest_unique_commit { | 367 | let earliest_unique_commit = match &args.earliest_unique_commit { |
| @@ -415,6 +436,10 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 415 | false, | 436 | false, |
| 416 | )?; | 437 | )?; |
| 417 | 438 | ||
| 439 | let relays = relays | ||
| 440 | .iter() | ||
| 441 | .map(std::string::ToString::to_string) | ||
| 442 | .collect::<Vec<String>>(); | ||
| 418 | // if yaml file doesnt exist or needs updating | 443 | // if yaml file doesnt exist or needs updating |
| 419 | if match &repo_config_result { | 444 | if match &repo_config_result { |
| 420 | Ok(config) => { | 445 | Ok(config) => { |
diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index 1965875..6c9d8eb 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs | |||
| @@ -237,7 +237,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re | |||
| 237 | if root_proposal_id.is_none() { | 237 | if root_proposal_id.is_none() { |
| 238 | if let Some(event) = events.first() { | 238 | if let Some(event) = events.first() { |
| 239 | let event_bech32 = if let Some(relay) = repo_ref.relays.first() { | 239 | let event_bech32 = if let Some(relay) = repo_ref.relays.first() { |
| 240 | Nip19Event::new(event.id, vec![relay]).to_bech32()? | 240 | Nip19Event::new(event.id, vec![relay.to_string()]).to_bech32()? |
| 241 | } else { | 241 | } else { |
| 242 | event.id.to_bech32()? | 242 | event.id.to_bech32()? |
| 243 | }; | 243 | }; |
| @@ -366,6 +366,7 @@ async fn get_root_proposal_id_and_mentions_from_in_reply_to( | |||
| 366 | relay_url: _, | 366 | relay_url: _, |
| 367 | marker: _, | 367 | marker: _, |
| 368 | public_key: _, | 368 | public_key: _, |
| 369 | uppercase: false, | ||
| 369 | }) => { | 370 | }) => { |
| 370 | let events = get_events_from_local_cache( | 371 | let events = get_events_from_local_cache( |
| 371 | git_repo_path, | 372 | git_repo_path, |