Skip to content

Commit 65c7d20

Browse files
committed
Refactor SSH authentication handling
- Moved SSH utility functions from `ssh_utils.rs` to platform-specific modules. - Created a new `ssh` module to encapsulate platform-specific implementations for SSH agent management. - Implemented Unix-specific SSH agent functions in `src/auth/ssh/unix.rs`. - Implemented Windows-specific SSH agent functions in `src/auth/ssh/windows.rs`. - Added an unsupported module for platforms that do not support SSH agents in `src/auth/ssh/unsupported.rs`. - Updated the main authentication module to use the new `ssh` module instead of the deprecated `ssh_utils.rs`. - Enhanced error handling in the unsupported module to provide clear feedback for unsupported operations. - Updated the `BGitErrorWorkflowType` enum to include an `Authentication` variant for better error categorization.
1 parent 9991c47 commit 65c7d20

File tree

8 files changed

+858
-494
lines changed

8 files changed

+858
-494
lines changed

src/auth/git_ssh.rs

Lines changed: 3 additions & 429 deletions
Large diffs are not rendered by default.

src/auth/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ pub mod auth_utils;
22
pub mod git_auth;
33
mod git_http;
44
mod git_ssh;
5-
mod ssh_utils;
5+
pub mod ssh;

src/auth/ssh/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Platform-specific SSH implementations
2+
#[cfg(unix)]
3+
mod unix;
4+
#[cfg(not(any(windows, unix)))]
5+
mod unsupported;
6+
#[cfg(windows)]
7+
mod windows;
8+
9+
// Re-export platform-specific functions with a unified interface
10+
// This follows the same pattern as hook_executor
11+
#[cfg(unix)]
12+
pub use self::unix::{
13+
add_all_ssh_keys, agent_identities_count, ensure_agent_ready, try_ssh_key_files_directly,
14+
};
15+
16+
#[cfg(windows)]
17+
pub use self::windows::{
18+
add_all_ssh_keys, agent_identities_count, ensure_agent_ready, try_ssh_key_files_directly,
19+
};
20+
21+
#[cfg(not(any(windows, unix)))]
22+
pub use self::unsupported::{
23+
add_all_ssh_keys, agent_identities_count, ensure_agent_ready, try_ssh_key_files_directly,
24+
};

0 commit comments

Comments
 (0)