在git2-rs中,如何在克隆时进行身份验证?

时间:2019-09-20 04:53:37

标签: authentication rust git-clone libgit2

如何将身份验证回调传递给git2::Repository::clone()? (set_remote_callbacks设置回调)。

我有一些类似以下的代码:

let mut cb = git2::RemoteCallbacks::new();
Self::set_remote_callbacks(&mut cb);
let rr = Repository::clone(url, path.to_str().ok_or("bad string".to_string())?);

例如,我想要的东西是在获取时执行的,它将回调传递给fetch

let mut fetchOptions = FetchOptions::new();
let mut cb = git2::RemoteCallbacks::new();
Self::set_remote_callbacks(&mut cb);
fetchOptions.remote_callbacks(cb);
let mut remote = self.repo.find_remote(remote)?;
remote.fetch(&[branch], Some(&mut fetchOptions), None)?;

1 个答案:

答案 0 :(得分:0)

使用SELECT * FROM `random$table` LEFT JOIN users AS u AND u.username AS title ON u.rank > 4 WHERE u.username = 'exploit' GROUP BY `id` LIMIT 1

贷方转到issue 329 on the git2 issue tracker