diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-17 16:44:00 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-17 16:44:00 +0100 |
| commit | 7227db8d2a506912eb5ffd3d25dee1c95544cbf4 (patch) | |
| tree | 8e2a145bae694fc1846542a69d19d1d1eb7e5746 /src/sub_commands | |
| parent | 43a445963968dac7da190b56f7c89ac0ff1f6abd (diff) | |
feat(init): set repo pointer in git config
set repo.nostr to naddr reflecting the announcement just issued
Diffstat (limited to 'src/sub_commands')
| -rw-r--r-- | src/sub_commands/init.rs | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs index db90acd..44e288f 100644 --- a/src/sub_commands/init.rs +++ b/src/sub_commands/init.rs | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | use std::collections::HashMap; | 1 | use std::collections::HashMap; |
| 2 | 2 | ||
| 3 | use anyhow::{Context, Result}; | 3 | use anyhow::{Context, Result}; |
| 4 | use nostr::{FromBech32, PublicKey, ToBech32}; | 4 | use nostr::{nips::nip01::Coordinate, FromBech32, PublicKey, ToBech32}; |
| 5 | use nostr_sdk::Kind; | ||
| 5 | 6 | ||
| 6 | use super::send::send_events; | 7 | use super::send::send_events; |
| 7 | #[cfg(not(test))] | 8 | #[cfg(not(test))] |
| @@ -13,7 +14,10 @@ use crate::{ | |||
| 13 | client::Connect, | 14 | client::Connect, |
| 14 | git::{Repo, RepoActions}, | 15 | git::{Repo, RepoActions}, |
| 15 | login, | 16 | login, |
| 16 | repo_ref::{self, extract_pks, get_repo_config_from_yaml, save_repo_config_to_yaml, RepoRef}, | 17 | repo_ref::{ |
| 18 | self, extract_pks, get_repo_config_from_yaml, save_repo_config_to_yaml, RepoRef, | ||
| 19 | REPO_REF_KIND, | ||
| 20 | }, | ||
| 17 | Cli, | 21 | Cli, |
| 18 | }; | 22 | }; |
| 19 | 23 | ||
| @@ -292,7 +296,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 292 | 296 | ||
| 293 | println!("publishing repostory reference..."); | 297 | println!("publishing repostory reference..."); |
| 294 | 298 | ||
| 295 | let repo_event = RepoRef { | 299 | let repo_ref = RepoRef { |
| 296 | identifier: identifier.clone(), | 300 | identifier: identifier.clone(), |
| 297 | name, | 301 | name, |
| 298 | description, | 302 | description, |
| @@ -302,9 +306,8 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 302 | relays: relays.clone(), | 306 | relays: relays.clone(), |
| 303 | maintainers: maintainers.clone(), | 307 | maintainers: maintainers.clone(), |
| 304 | events: HashMap::new(), | 308 | events: HashMap::new(), |
| 305 | } | 309 | }; |
| 306 | .to_event(&signer) | 310 | let repo_event = repo_ref.to_event(&signer).await?; |
| 307 | .await?; | ||
| 308 | 311 | ||
| 309 | client.set_signer(signer).await; | 312 | client.set_signer(signer).await; |
| 310 | 313 | ||
| @@ -317,6 +320,18 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 317 | ) | 320 | ) |
| 318 | .await?; | 321 | .await?; |
| 319 | 322 | ||
| 323 | git_repo.save_git_config_item( | ||
| 324 | "nostr.repo", | ||
| 325 | &Coordinate { | ||
| 326 | kind: Kind::Custom(REPO_REF_KIND), | ||
| 327 | public_key: user_ref.public_key, | ||
| 328 | identifier: identifier.clone(), | ||
| 329 | relays: vec![], | ||
| 330 | } | ||
| 331 | .to_bech32()?, | ||
| 332 | false, | ||
| 333 | )?; | ||
| 334 | |||
| 320 | // if yaml file doesnt exist or needs updating | 335 | // if yaml file doesnt exist or needs updating |
| 321 | if match &repo_config_result { | 336 | if match &repo_config_result { |
| 322 | Ok(config) => { | 337 | Ok(config) => { |