upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock18
-rw-r--r--src/bin/git_remote_nostr/list.rs9
-rw-r--r--src/bin/git_remote_nostr/push.rs2
-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
-rw-r--r--src/lib/client.rs8
-rw-r--r--src/lib/git/nostr_url.rs2
-rw-r--r--src/lib/login/mod.rs12
-rw-r--r--tests/git_remote_nostr/push.rs2
11 files changed, 22 insertions, 66 deletions
diff --git a/flake.lock b/flake.lock
index a01b7d4..b89753c 100644
--- a/flake.lock
+++ b/flake.lock
@@ -20,11 +20,11 @@
20 }, 20 },
21 "nixpkgs": { 21 "nixpkgs": {
22 "locked": { 22 "locked": {
23 "lastModified": 1734119587, 23 "lastModified": 1746141548,
24 "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", 24 "narHash": "sha256-IgBWhX7A2oJmZFIrpRuMnw5RAufVnfvOgHWgIdds+hc=",
25 "owner": "NixOS", 25 "owner": "NixOS",
26 "repo": "nixpkgs", 26 "repo": "nixpkgs",
27 "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", 27 "rev": "f02fddb8acef29a8b32f10a335d44828d7825b78",
28 "type": "github" 28 "type": "github"
29 }, 29 },
30 "original": { 30 "original": {
@@ -36,11 +36,11 @@
36 }, 36 },
37 "nixpkgs_2": { 37 "nixpkgs_2": {
38 "locked": { 38 "locked": {
39 "lastModified": 1728538411, 39 "lastModified": 1744536153,
40 "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", 40 "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
41 "owner": "NixOS", 41 "owner": "NixOS",
42 "repo": "nixpkgs", 42 "repo": "nixpkgs",
43 "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", 43 "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
44 "type": "github" 44 "type": "github"
45 }, 45 },
46 "original": { 46 "original": {
@@ -62,11 +62,11 @@
62 "nixpkgs": "nixpkgs_2" 62 "nixpkgs": "nixpkgs_2"
63 }, 63 },
64 "locked": { 64 "locked": {
65 "lastModified": 1734316514, 65 "lastModified": 1746153335,
66 "narHash": "sha256-0aLx44yMblcOGpfFXKCzp2GhU5JaE6OTvdU+JYrXiUc=", 66 "narHash": "sha256-vwKelhJJS8haCdH3t8uf96VFao7/YzJahPG5JLTO1PU=",
67 "owner": "oxalica", 67 "owner": "oxalica",
68 "repo": "rust-overlay", 68 "repo": "rust-overlay",
69 "rev": "83ee8ff74d6294a7657320f16814754c4594127b", 69 "rev": "ebc7823c3ffde594c7733113042b72694d996de9",
70 "type": "github" 70 "type": "github"
71 }, 71 },
72 "original": { 72 "original": {
diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs
index b802a4a..eba573b 100644
--- a/src/bin/git_remote_nostr/list.rs
+++ b/src/bin/git_remote_nostr/list.rs
@@ -33,12 +33,7 @@ pub async fn run_list(
33 repo_ref: &RepoRef, 33 repo_ref: &RepoRef,
34 for_push: bool, 34 for_push: bool,
35) -> Result<HashMap<String, HashMap<String, String>>> { 35) -> Result<HashMap<String, HashMap<String, String>>> {
36 let nostr_state = 36 let nostr_state = (get_state_from_cache(Some(git_repo.get_path()?), repo_ref).await).ok();
37 if let Ok(nostr_state) = get_state_from_cache(Some(git_repo.get_path()?), repo_ref).await {
38 Some(nostr_state)
39 } else {
40 None
41 };
42 37
43 let term = console::Term::stderr(); 38 let term = console::Term::stderr();
44 39
@@ -169,7 +164,7 @@ async fn get_open_and_draft_proposals_state(
169 .as_str(), 164 .as_str(),
170 ); 165 );
171 } 166 }
172 }; 167 }
173 } 168 }
174 } 169 }
175 } 170 }
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index 6113c0a..0cb1107 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -792,7 +792,7 @@ fn create_rejected_refspecs_and_remotes_refspecs(
792 ).as_str(), 792 ).as_str(),
793 )?; 793 )?;
794 } 794 }
795 }; 795 }
796 } else { 796 } else {
797 // remote_value oid is not present locally 797 // remote_value oid is not present locally
798 // TODO can we download the remote reference? 798 // TODO can we download the remote reference?
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
diff --git a/src/lib/client.rs b/src/lib/client.rs
index 478a16a..3f2ae68 100644
--- a/src/lib/client.rs
+++ b/src/lib/client.rs
@@ -968,13 +968,7 @@ async fn create_relays_request(
968 fallback_relays: HashSet<RelayUrl>, 968 fallback_relays: HashSet<RelayUrl>,
969) -> Result<FetchRequest> { 969) -> Result<FetchRequest> {
970 let repo_ref = if let Some(trusted_maintainer_coordinate) = trusted_maintainer_coordinate { 970 let repo_ref = if let Some(trusted_maintainer_coordinate) = trusted_maintainer_coordinate {
971 if let Ok(repo_ref) = 971 (get_repo_ref_from_cache(git_repo_path, trusted_maintainer_coordinate).await).ok()
972 get_repo_ref_from_cache(git_repo_path, trusted_maintainer_coordinate).await
973 {
974 Some(repo_ref)
975 } else {
976 None
977 }
978 } else { 972 } else {
979 None 973 None
980 }; 974 };
diff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs
index 54be292..fe58962 100644
--- a/src/lib/git/nostr_url.rs
+++ b/src/lib/git/nostr_url.rs
@@ -327,7 +327,7 @@ impl FromStr for CloneUrl {
327 if s.contains('@') && s 327 if s.contains('@') && s
328 .split('@') 328 .split('@')
329 .nth(0) 329 .nth(0)
330 .map_or(false, |part| !part.contains('/')) { 330 .is_some_and(|part| !part.contains('/')) {
331 "ssh" 331 "ssh"
332 } 332 }
333 // otherwise assume unspecified 333 // otherwise assume unspecified
diff --git a/src/lib/login/mod.rs b/src/lib/login/mod.rs
index c37375f..bfc7328 100644
--- a/src/lib/login/mod.rs
+++ b/src/lib/login/mod.rs
@@ -93,11 +93,7 @@ pub async fn get_likely_logged_in_user(git_repo_path: &Path) -> Result<Option<Pu
93 let git_repo = Repo::from_path(&git_repo_path.to_path_buf())?; 93 let git_repo = Repo::from_path(&git_repo_path.to_path_buf())?;
94 Ok( 94 Ok(
95 if let Some(npub) = git_repo.get_git_config_item("nostr.npub", None)? { 95 if let Some(npub) = git_repo.get_git_config_item("nostr.npub", None)? {
96 if let Ok(pubic_key) = PublicKey::parse(&npub) { 96 PublicKey::parse(&npub).ok()
97 Some(pubic_key)
98 } else {
99 None
100 }
101 } else { 97 } else {
102 None 98 None
103 }, 99 },
@@ -107,11 +103,7 @@ pub async fn get_likely_logged_in_user(git_repo_path: &Path) -> Result<Option<Pu
107pub fn get_curent_user(git_repo: &Repo) -> Result<Option<PublicKey>> { 103pub fn get_curent_user(git_repo: &Repo) -> Result<Option<PublicKey>> {
108 Ok( 104 Ok(
109 if let Some(npub) = git_repo.get_git_config_item("nostr.npub", None)? { 105 if let Some(npub) = git_repo.get_git_config_item("nostr.npub", None)? {
110 if let Ok(public_key) = PublicKey::parse(&npub) { 106 PublicKey::parse(&npub).ok()
111 Some(public_key)
112 } else {
113 None
114 }
115 } else { 107 } else {
116 None 108 None
117 }, 109 },
diff --git a/tests/git_remote_nostr/push.rs b/tests/git_remote_nostr/push.rs
index 4e44642..d041a89 100644
--- a/tests/git_remote_nostr/push.rs
+++ b/tests/git_remote_nostr/push.rs
@@ -1020,7 +1020,7 @@ async fn proposal_three_way_merge_commit_pushed_to_main_leads_to_status_event_is
1020 .any(|t| t.as_slice()[1].eq(&proposal_cover_letter_event.id.to_string())) 1020 .any(|t| t.as_slice()[1].eq(&proposal_cover_letter_event.id.to_string()))
1021 && e.kind.eq(&Kind::GitPatch) 1021 && e.kind.eq(&Kind::GitPatch)
1022 }) 1022 })
1023 .last() 1023 .next_back()
1024 .unwrap(); 1024 .unwrap();
1025 1025
1026 assert_eq!( 1026 assert_eq!(