diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/git/mod.rs | 1 | ||||
| -rw-r--r-- | src/lib/git/utils.rs | 25 |
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}; | |||
| 11 | use crate::git_events::{get_commit_id_from_patch, tag_value}; | 11 | use crate::git_events::{get_commit_id_from_patch, tag_value}; |
| 12 | pub mod identify_ahead_behind; | 12 | pub mod identify_ahead_behind; |
| 13 | pub mod nostr_url; | 13 | pub mod nostr_url; |
| 14 | pub mod utils; | ||
| 14 | 15 | ||
| 15 | pub struct Repo { | 16 | pub 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 @@ | |||
| 1 | use std::path::Path; | ||
| 2 | |||
| 3 | use directories::UserDirs; | ||
| 4 | |||
| 5 | pub 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 | } | ||