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/export_keys.rs7
-rw-r--r--src/bin/ngit/sub_commands/init.rs14
-rw-r--r--src/bin/ngit/sub_commands/login.rs7
-rw-r--r--src/bin/ngit/sub_commands/logout.rs7
4 files changed, 5 insertions, 30 deletions
diff --git a/src/bin/ngit/sub_commands/export_keys.rs b/src/bin/ngit/sub_commands/export_keys.rs
index 45b1b89..4a32a3a 100644
--- a/src/bin/ngit/sub_commands/export_keys.rs
+++ b/src/bin/ngit/sub_commands/export_keys.rs
@@ -12,12 +12,7 @@ use crate::git::Repo;
12 12
13pub async fn launch() -> Result<()> { 13pub async fn launch() -> Result<()> {
14 let git_repo_result = Repo::discover().context("failed to find a git repository"); 14 let git_repo_result = Repo::discover().context("failed to find a git repository");
15 let git_repo = { 15 let git_repo = { git_repo_result.ok() };
16 match git_repo_result {
17 Ok(git_repo) => Some(git_repo),
18 Err(_) => None,
19 }
20 };
21 16
22 if let Ok((signer_info, source)) = get_signer_info(&git_repo.as_ref(), &None, &None, &None) { 17 if let Ok((signer_info, source)) = get_signer_info(&git_repo.as_ref(), &None, &None, &None) {
23 if let Ok((_, user_ref, source)) = load_existing_login( 18 if let Ok((_, user_ref, source)) = load_existing_login(
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 9c544d6..3c58a52 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -70,21 +70,11 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
70 70
71 let mut client = Client::default(); 71 let mut client = Client::default();
72 72
73 let repo_coordinate = if let Ok(repo_coordinate) = 73 let repo_coordinate = (try_and_get_repo_coordinates_when_remote_unknown(&git_repo).await).ok();
74 try_and_get_repo_coordinates_when_remote_unknown(&git_repo).await
75 {
76 Some(repo_coordinate)
77 } else {
78 None
79 };
80 74
81 let repo_ref = if let Some(repo_coordinate) = &repo_coordinate { 75 let repo_ref = if let Some(repo_coordinate) = &repo_coordinate {
82 fetching_with_report(git_repo_path, &client, repo_coordinate).await?; 76 fetching_with_report(git_repo_path, &client, repo_coordinate).await?;
83 if let Ok(repo_ref) = get_repo_ref_from_cache(Some(git_repo_path), repo_coordinate).await { 77 (get_repo_ref_from_cache(Some(git_repo_path), repo_coordinate).await).ok()
84 Some(repo_ref)
85 } else {
86 None
87 }
88 } else { 78 } else {
89 None 79 None
90 }; 80 };
diff --git a/src/bin/ngit/sub_commands/login.rs b/src/bin/ngit/sub_commands/login.rs
index 06236ec..e76a089 100644
--- a/src/bin/ngit/sub_commands/login.rs
+++ b/src/bin/ngit/sub_commands/login.rs
@@ -32,12 +32,7 @@ pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> {
32 }; 32 };
33 33
34 let git_repo_result = Repo::discover().context("failed to find a git repository"); 34 let git_repo_result = Repo::discover().context("failed to find a git repository");
35 let git_repo = { 35 let git_repo = { git_repo_result.ok() };
36 match git_repo_result {
37 Ok(git_repo) => Some(git_repo),
38 Err(_) => None,
39 }
40 };
41 36
42 let (logged_out, log_in_locally_only) = logout(git_repo.as_ref(), command_args.local).await?; 37 let (logged_out, log_in_locally_only) = logout(git_repo.as_ref(), command_args.local).await?;
43 if logged_out || log_in_locally_only { 38 if logged_out || log_in_locally_only {
diff --git a/src/bin/ngit/sub_commands/logout.rs b/src/bin/ngit/sub_commands/logout.rs
index 2df96c8..da445b4 100644
--- a/src/bin/ngit/sub_commands/logout.rs
+++ b/src/bin/ngit/sub_commands/logout.rs
@@ -11,12 +11,7 @@ use crate::{
11 11
12pub async fn launch() -> Result<()> { 12pub async fn launch() -> Result<()> {
13 let git_repo_result = Repo::discover().context("failed to find a git repository"); 13 let git_repo_result = Repo::discover().context("failed to find a git repository");
14 let git_repo = { 14 let git_repo = { git_repo_result.ok() };
15 match git_repo_result {
16 Ok(git_repo) => Some(git_repo),
17 Err(_) => None,
18 }
19 };
20 logout(git_repo.as_ref()).await 15 logout(git_repo.as_ref()).await
21} 16}
22 17