Crates.io | git2_credentials |
lib.rs | git2_credentials |
version | |
source | src |
created_at | 2019-04-13 13:32:09.623921+00 |
updated_at | 2025-01-07 13:35:15.713002+00 |
description | Provide credential function to used with git2::RemoteCallbacks.credentials |
homepage | https://github.com/davidB/git2_credentials |
repository | https://github.com/davidB/git2_credentials |
max_upload_size | |
id | 127659 |
Cargo.toml error: | TOML parse error at line 26, column 1 | 26 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Provide credentials function to used with git2::RemoteCallbacks.credentials
use git2;
use git2_credentials::CredentialHandler;
use tempfile;
let mut cb = git2::RemoteCallbacks::new();
let git_config = git2::Config::open_default().unwrap();
let mut ch = CredentialHandler::new(git_config);
cb.credentials(move |url, username, allowed| ch.try_next_credential(url, username, allowed));
// clone a repository
let mut fo = git2::FetchOptions::new();
fo.remote_callbacks(cb)
.download_tags(git2::AutotagOption::All)
.update_fetchhead(true);
let dst = tempfile::tempdir().unwrap();
std::fs::create_dir_all(&dst.as_ref()).unwrap();
git2::build::RepoBuilder::new()
.branch("master")
.fetch_options(fo)
.clone("git@github.com:davidB/git2_credentials.git", dst.as_ref()).unwrap();
You can run the example via
cargo run --example clone -- --nocapture
You can provide custom UI (to ask password, passphrase) by providing a CredentialUI
. A default implementation (with dialoguer is provided.
cargo make ci-flow
Code extracted from:
with_authentication
)
Cargo, a package manager for Rust.
ffizer is a files and folders initializer / generator. Create any kind (or part) of project from template.
Git-based package manager.