Crates.io | git2_auth |
lib.rs | git2_auth |
version | 0.1.0 |
source | src |
created_at | 2023-03-07 18:35:49.09009 |
updated_at | 2023-03-07 18:35:49.09009 |
description | A small library to provide easy to use callback handler to authenticate with git2-rs |
homepage | |
repository | |
max_upload_size | |
id | 803816 |
size | 16,026 |
An authentication handler to be used with git2_rs
. An example usage can be seen below. I used the following repos:
// Setup remote callbacks
let mut callback = git2::RemoteCallbacks::new();
let config = git2::Config::open_default().unwrap();
// Setup authentication handler
let mut auth_handler = AuthHandler::default_with_config(config);
callback.credentials(move |url, username, allowed| {
auth_handler.handle_callback(url, username, allowed)
});
// Create fetch options
let mut fetch_options = git2::FetchOptions::new();
fetch_options
.remote_callbacks(callback)
.download_tags(git2::AutotagOption::All)
.update_fetchhead(true);
// Clone the repo
git2::build::RepoBuilder::new()
.branch("master")
.fetch_options(fetch_options)
.clone("git@github.com:kayagokalp/git2_auth.git", dir.as_ref())
.unwrap();