{"id":13822598,"url":"https://github.com/davidB/git2_credentials","last_synced_at":"2025-05-16T17:31:14.794Z","repository":{"id":34637719,"uuid":"181170739","full_name":"davidB/git2_credentials","owner":"davidB","description":"Provide credentials function to used with git2::RemoteCallbacks.credentials","archived":false,"fork":false,"pushed_at":"2025-01-22T15:12:57.000Z","size":76,"stargazers_count":23,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-06T08:50:51.450Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-13T12:52:38.000Z","updated_at":"2025-01-28T13:24:56.000Z","dependencies_parsed_at":"2024-01-18T04:07:05.338Z","dependency_job_id":"70691432-a805-44c6-891d-88de1698cc95","html_url":"https://github.com/davidB/git2_credentials","commit_stats":{"total_commits":105,"total_committers":6,"mean_commits":17.5,"dds":"0.19047619047619047","last_synced_commit":"d5b459bb13a2a57343de4dcb4fdccd8c5e5f8d9c"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidB%2Fgit2_credentials","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidB%2Fgit2_credentials/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidB%2Fgit2_credentials/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidB%2Fgit2_credentials/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidB","download_url":"https://codeload.github.com/davidB/git2_credentials/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254576468,"owners_count":22094376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T08:02:07.977Z","updated_at":"2025-05-16T17:31:14.450Z","avatar_url":"https://github.com/davidB.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# git2_credentials\n\n[![crate license](https://img.shields.io/crates/l/git2_credentials.svg)](https://spdx.org/licenses/Apache-2.0.html)\n[![crate version](https://img.shields.io/crates/v/git2_credentials.svg)](https://crates.io/crates/git2_credentials)\n\n[![Actions Status](https://github.com/davidB/git2_credentials/workflows/ci-flow/badge.svg)](https://github.com/davidB/git2_credentials/actions)\n\nProvide credentials function to used with [git2](https://crates.io/crates/git2)::[RemoteCallbacks.credentials](https://docs.rs/git2/0.8.0/git2/struct.RemoteCallbacks.html#method.credentials)\n\n## Usage\n\n```rust\nuse git2;\nuse git2_credentials::CredentialHandler;\nuse tempfile;\n\nlet mut cb = git2::RemoteCallbacks::new();\nlet git_config = git2::Config::open_default().unwrap();\nlet mut ch = CredentialHandler::new(git_config);\ncb.credentials(move |url, username, allowed| ch.try_next_credential(url, username, allowed));\n\n// clone a repository\nlet mut fo = git2::FetchOptions::new();\nfo.remote_callbacks(cb)\n    .download_tags(git2::AutotagOption::All)\n    .update_fetchhead(true);\nlet dst = tempfile::tempdir().unwrap();\nstd::fs::create_dir_all(\u0026dst.as_ref()).unwrap();\ngit2::build::RepoBuilder::new()\n    .branch(\"master\")\n    .fetch_options(fo)\n    .clone(\"git@github.com:davidB/git2_credentials.git\", dst.as_ref()).unwrap();\n```\n\nYou can run the example via\n\n```sh\ncargo run --example clone -- --nocapture\n```\n\nYou can provide custom UI (to ask password, passphrase) by providing a `CredentialUI`. A default implementation (with [dialoguer](https://crates.io/crates/dialoguer) is provided.\n\n### Build\n\n```sh\ncargo make ci-flow\n```\n\n## Credit\n\nCode *extracted* from:\n\n- [cargo/utils.rs at master · rust-lang/cargo](https://github.com/rust-lang/cargo/blob/master/src/cargo/sources/git/utils.rs) (search `with_authentication`)\n  \u003e Cargo, a package manager for Rust.\n- [ffizer](https://crates.io/crates/ffizer)\n  \u003e ffizer is a files and folders initializer / generator. Create any kind (or part) of project from template.\n- [gpm/ssh.rs at master · aerys/gpm](https://github.com/aerys/gpm/blob/master/src/gpm/ssh.rs)\n  \u003e Git-based package manager.\n\n## Links\n\n- [\"authentication required but no callback set\" on clone with SSH url · Issue #41 · rust-lang/git2-rs](https://github.com/rust-lang/git2-rs/issues/41)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FdavidB%2Fgit2_credentials","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FdavidB%2Fgit2_credentials","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FdavidB%2Fgit2_credentials/lists"}