upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/git/mod.rs1
-rw-r--r--src/lib/git/utils.rs25
2 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs
index f92272f..72717f7 100644
--- a/src/lib/git/mod.rs
+++ b/src/lib/git/mod.rs
@@ -11,6 +11,7 @@ use nostr_sdk::hashes::{sha1::Hash as Sha1Hash, Hash};
11use crate::git_events::{get_commit_id_from_patch, tag_value}; 11use crate::git_events::{get_commit_id_from_patch, tag_value};
12pub mod identify_ahead_behind; 12pub mod identify_ahead_behind;
13pub mod nostr_url; 13pub mod nostr_url;
14pub mod utils;
14 15
15pub struct Repo { 16pub struct Repo {
16 pub git_repo: git2::Repository, 17 pub git_repo: git2::Repository,
diff --git a/src/lib/git/utils.rs b/src/lib/git/utils.rs
new file mode 100644
index 0000000..4e8f153
--- /dev/null
+++ b/src/lib/git/utils.rs
@@ -0,0 +1,25 @@
1use std::path::Path;
2
3use directories::UserDirs;
4
5pub fn check_ssh_keys() -> bool {
6 // Get the user's home directory using the directories crate
7 if let Some(user_dirs) = UserDirs::new() {
8 let ssh_dir = user_dirs.home_dir().join(".ssh");
9 let key_files = vec![
10 "id_rsa",
11 "id_ecdsa",
12 "id_ed25519",
13 "id_rsa.pub",
14 "id_ecdsa.pub",
15 "id_ed25519.pub",
16 ];
17
18 for key in key_files {
19 if Path::new(&ssh_dir.join(key)).exists() {
20 return true; // At least one key exists
21 }
22 }
23 }
24 false // No keys found
25}