upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/ngit/sub_commands')
-rw-r--r--src/bin/ngit/sub_commands/init.rs3
-rw-r--r--src/bin/ngit/sub_commands/list.rs6
-rw-r--r--src/bin/ngit/sub_commands/login.rs11
-rw-r--r--src/bin/ngit/sub_commands/send.rs7
4 files changed, 18 insertions, 9 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 3c58a52..ee5f1ab 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -4,6 +4,7 @@ use anyhow::{Context, Result};
4use console::{Style, Term}; 4use console::{Style, Term};
5use ngit::{ 5use ngit::{
6 cli_interactor::PromptConfirmParms, 6 cli_interactor::PromptConfirmParms,
7 client::Params,
7 git::nostr_url::{NostrUrlDecoded, save_nip05_to_git_config_cache}, 8 git::nostr_url::{NostrUrlDecoded, save_nip05_to_git_config_cache},
8}; 9};
9use nostr::{ 10use nostr::{
@@ -68,7 +69,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
68 // TODO: check for empty repo 69 // TODO: check for empty repo
69 // TODO: check for existing maintaiers file 70 // TODO: check for existing maintaiers file
70 71
71 let mut client = Client::default(); 72 let mut client = Client::new(Params::with_git_config_relay_defaults(&Some(&git_repo)));
72 73
73 let repo_coordinate = (try_and_get_repo_coordinates_when_remote_unknown(&git_repo).await).ok(); 74 let repo_coordinate = (try_and_get_repo_coordinates_when_remote_unknown(&git_repo).await).ok();
74 75
diff --git a/src/bin/ngit/sub_commands/list.rs b/src/bin/ngit/sub_commands/list.rs
index e8d2e97..2c91e66 100644
--- a/src/bin/ngit/sub_commands/list.rs
+++ b/src/bin/ngit/sub_commands/list.rs
@@ -2,7 +2,9 @@ use std::{io::Write, ops::Add};
2 2
3use anyhow::{Context, Result, bail}; 3use anyhow::{Context, Result, bail};
4use ngit::{ 4use ngit::{
5 client::{get_all_proposal_patch_events_from_cache, get_proposals_and_revisions_from_cache}, 5 client::{
6 Params, get_all_proposal_patch_events_from_cache, get_proposals_and_revisions_from_cache,
7 },
6 git_events::{ 8 git_events::{
7 get_commit_id_from_patch, get_most_recent_patch_with_ancestors, status_kinds, tag_value, 9 get_commit_id_from_patch, get_most_recent_patch_with_ancestors, status_kinds, tag_value,
8 }, 10 },
@@ -31,7 +33,7 @@ pub async fn launch() -> Result<()> {
31 // TODO: check for existing maintaiers file 33 // TODO: check for existing maintaiers file
32 // TODO: check for other claims 34 // TODO: check for other claims
33 35
34 let client = Client::default(); 36 let client = Client::new(Params::with_git_config_relay_defaults(&Some(&git_repo)));
35 37
36 let repo_coordinates = get_repo_coordinates_when_remote_unknown(&git_repo, &client).await?; 38 let repo_coordinates = get_repo_coordinates_when_remote_unknown(&git_repo, &client).await?;
37 39
diff --git a/src/bin/ngit/sub_commands/login.rs b/src/bin/ngit/sub_commands/login.rs
index e76a089..ed2414a 100644
--- a/src/bin/ngit/sub_commands/login.rs
+++ b/src/bin/ngit/sub_commands/login.rs
@@ -2,6 +2,7 @@ use anyhow::{Context, Result};
2use clap; 2use clap;
3use ngit::{ 3use ngit::{
4 cli_interactor::{Interactor, InteractorPrompt, PromptChoiceParms}, 4 cli_interactor::{Interactor, InteractorPrompt, PromptChoiceParms},
5 client::Params,
5 git::{get_git_config_item, remove_git_config_item}, 6 git::{get_git_config_item, remove_git_config_item},
6 login::{SignerInfoSource, existing::load_existing_login}, 7 login::{SignerInfoSource, existing::load_existing_login},
7}; 8};
@@ -25,15 +26,17 @@ pub struct SubCommandArgs {
25} 26}
26 27
27pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { 28pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> {
29 let git_repo_result = Repo::discover().context("failed to find a git repository");
30 let git_repo = { git_repo_result.ok() };
31
28 let client = if command_args.offline { 32 let client = if command_args.offline {
29 None 33 None
30 } else { 34 } else {
31 Some(Client::default()) 35 Some(Client::new(Params::with_git_config_relay_defaults(
36 &git_repo.as_ref(),
37 )))
32 }; 38 };
33 39
34 let git_repo_result = Repo::discover().context("failed to find a git repository");
35 let git_repo = { git_repo_result.ok() };
36
37 let (logged_out, log_in_locally_only) = logout(git_repo.as_ref(), command_args.local).await?; 40 let (logged_out, log_in_locally_only) = logout(git_repo.as_ref(), command_args.local).await?;
38 if logged_out || log_in_locally_only { 41 if logged_out || log_in_locally_only {
39 fresh_login_or_signup( 42 fresh_login_or_signup(
diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs
index 9fc00d9..5a5acc8 100644
--- a/src/bin/ngit/sub_commands/send.rs
+++ b/src/bin/ngit/sub_commands/send.rs
@@ -2,7 +2,10 @@ use std::path::Path;
2 2
3use anyhow::{Context, Result, bail}; 3use anyhow::{Context, Result, bail};
4use console::Style; 4use console::Style;
5use ngit::{client::send_events, git_events::generate_cover_letter_and_patch_events}; 5use ngit::{
6 client::{Params, send_events},
7 git_events::generate_cover_letter_and_patch_events,
8};
6use nostr::{ 9use nostr::{
7 ToBech32, 10 ToBech32,
8 nips::{nip10::Marker, nip19::Nip19Event}, 11 nips::{nip10::Marker, nip19::Nip19Event},
@@ -52,7 +55,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re
52 .get_main_or_master_branch() 55 .get_main_or_master_branch()
53 .context("the default branches (main or master) do not exist")?; 56 .context("the default branches (main or master) do not exist")?;
54 57
55 let mut client = Client::default(); 58 let mut client = Client::new(Params::with_git_config_relay_defaults(&Some(&git_repo)));
56 59
57 let repo_coordinates = get_repo_coordinates_when_remote_unknown(&git_repo, &client).await?; 60 let repo_coordinates = get_repo_coordinates_when_remote_unknown(&git_repo, &client).await?;
58 61