blob: 60d0b46aec63e1c81f3ae637a7153d3b54551a7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
pub fn git_credentials_callback(
_user: &str,
user_from_url: Option<&str>,
_cred: git2::CredentialType,
) -> Result<git2::Cred, git2::Error> {
if let Some(user) = user_from_url {
git2::Cred::ssh_key_from_agent(user)
} else {
Err(git2::Error::from_str("no url username found"))
}
}
pub fn callbacks<'g>() -> git2::RemoteCallbacks<'g> {
let mut callbacks = git2::RemoteCallbacks::new();
callbacks.credentials(git_credentials_callback);
callbacks
}
#[tracing::instrument(level = "trace")]
pub fn fetch_options<'g>() -> git2::FetchOptions<'g> {
let mut opts = git2::FetchOptions::new();
opts.remote_callbacks(callbacks());
opts.download_tags(git2::AutotagOption::All);
opts
}
|