mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-14 04:10:36 +00:00
24 lines
778 B
Rust
24 lines
778 B
Rust
|
use crate::AuthConfig;
|
||
|
|
||
|
pub fn authenticate_conn(
|
||
|
conn: &mut gix::remote::Connection<
|
||
|
'_,
|
||
|
'_,
|
||
|
Box<dyn gix::protocol::transport::client::Transport + Send>,
|
||
|
>,
|
||
|
auth_config: &AuthConfig,
|
||
|
) {
|
||
|
if let Some(iden) = auth_config.git_credentials().cloned() {
|
||
|
conn.set_credentials(move |action| match action {
|
||
|
gix::credentials::helper::Action::Get(ctx) => {
|
||
|
Ok(Some(gix::credentials::protocol::Outcome {
|
||
|
identity: iden.clone(),
|
||
|
next: gix::credentials::helper::NextAction::from(ctx),
|
||
|
}))
|
||
|
}
|
||
|
gix::credentials::helper::Action::Store(_) => Ok(None),
|
||
|
gix::credentials::helper::Action::Erase(_) => Ok(None),
|
||
|
});
|
||
|
}
|
||
|
}
|