git-api 0.1.1

git2-rs based utility library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use git2::{Cred, RemoteCallbacks};
use macro_log::*;

/// remote authentication required a callback
pub fn auth_callbacks<'a>(username: &'a str, password: &'a str) -> RemoteCallbacks<'a> {
    let mut callbacks = RemoteCallbacks::new();
    callbacks.credentials(|url, username_from_url, allowed_types| {
        d!("请求凭证: {url:?} {username_from_url:?} {allowed_types:?}");
        // 替换成你的 Git 凭据(如果远程仓库需要认证)
        Cred::userpass_plaintext(username, password)
    });
    callbacks
}