-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
enhancementNew feature or requestNew feature or request
Description
There is one git host I need to conect to, which does not allow ssh connections.
I use https + username + access tokens instead.
My local git-cli is configured to use OSXKeychain:
git config credential.helper
> osxkeychainwhen I use a regular git clone git asks me for the credentials on the very first connection, but stores the credentials in OSXKeychain for any subsequent commands (survives restarts as well).
When using git2_credentials + git2 I can clone repos, but it always asks for the credentials.
Would it be possible that git2_credentials uses OSXKeychain as well?
My code is very close to your official example :)
use std::path::PathBuf;
use git2::Repository;
use git2_credentials::CredentialHandler;
pub fn clone_with_auth(repo_url: &str, target_path: &PathBuf) -> Result<Repository, git2::Error> {
let mut remote_callback = git2::RemoteCallbacks::new();
let git_config = git2::Config::open_default()?;
let mut credential_handler = CredentialHandler::new(git_config);
remote_callback.credentials(move |url, username, allowed| {
credential_handler.try_next_credential(url, username, allowed)
});
let mut fetch_options = git2::FetchOptions::new();
fetch_options.remote_callbacks(remote_callback);
git2::build::RepoBuilder::new()
.fetch_options(fetch_options)
.clone(&repo_url, &target_path)
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request