From 7227db8d2a506912eb5ffd3d25dee1c95544cbf4 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 17 Jul 2024 16:44:00 +0100 Subject: feat(init): set repo pointer in git config set repo.nostr to naddr reflecting the announcement just issued --- src/sub_commands/init.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src') 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 @@ use std::collections::HashMap; use anyhow::{Context, Result}; -use nostr::{FromBech32, PublicKey, ToBech32}; +use nostr::{nips::nip01::Coordinate, FromBech32, PublicKey, ToBech32}; +use nostr_sdk::Kind; use super::send::send_events; #[cfg(not(test))] @@ -13,7 +14,10 @@ use crate::{ client::Connect, git::{Repo, RepoActions}, login, - repo_ref::{self, extract_pks, get_repo_config_from_yaml, save_repo_config_to_yaml, RepoRef}, + repo_ref::{ + self, extract_pks, get_repo_config_from_yaml, save_repo_config_to_yaml, RepoRef, + REPO_REF_KIND, + }, Cli, }; @@ -292,7 +296,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { println!("publishing repostory reference..."); - let repo_event = RepoRef { + let repo_ref = RepoRef { identifier: identifier.clone(), name, description, @@ -302,9 +306,8 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { relays: relays.clone(), maintainers: maintainers.clone(), events: HashMap::new(), - } - .to_event(&signer) - .await?; + }; + let repo_event = repo_ref.to_event(&signer).await?; client.set_signer(signer).await; @@ -317,6 +320,18 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { ) .await?; + git_repo.save_git_config_item( + "nostr.repo", + &Coordinate { + kind: Kind::Custom(REPO_REF_KIND), + public_key: user_ref.public_key, + identifier: identifier.clone(), + relays: vec![], + } + .to_bech32()?, + false, + )?; + // if yaml file doesnt exist or needs updating if match &repo_config_result { Ok(config) => { -- cgit v1.2.3