diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-06 07:47:13 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-06 07:47:13 +0100 |
| commit | a5a662632b61ef2b35946af1e93f30a885ea1db2 (patch) | |
| tree | 938fac721d85ad771a237999b7212ee6ea72d77d /src/lib/git/utils.rs | |
| parent | fad3f8fddffb55597432243e129e4012034b3627 (diff) | |
feat(remote): fetch protocol selection / fallback
enable override from nostr url
clone url is local use local
otherwise try https unathenticated, ssh, then https authenticated
Diffstat (limited to 'src/lib/git/utils.rs')
| -rw-r--r-- | src/lib/git/utils.rs | 25 |
1 files changed, 25 insertions, 0 deletions
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 | } | ||