git2-rs
git2-rs copied to clipboard
push the code is not working on windows
here is my code
pub fn push(&self, branch: &str) -> Result<()> {
let mut remote = self
.repo
.find_remote("origin")
.with_context(|| "Failed to push the repository")?;
let branch = self
.repo
.find_branch(branch, git2::BranchType::Local)
.with_context(|| "Failed to find the branch")?;
let refs = branch.into_reference();
let name = refs.name().with_context(|| "The reference name is none")?;
let mut callbacks = git2::RemoteCallbacks::new();
callbacks.credentials(|_url, username_from_url, _allowed_types| {
tracing::info!("Allowed types: {:?}", _allowed_types);
Cred::ssh_key(
username_from_url.unwrap(),
None,
std::path::Path::new(self.pub_key.as_str()),
None,
)
});
let mut options = git2::PushOptions::new();
options.remote_callbacks(callbacks);
// push the code to master branch
remote
.push(&[name], Some(&mut options))
.with_context(|| "Failed to push the code")?;
Ok(())
}
it's working fine on mac but get an error on windows failed to set hostkey preference: The requested method(s) are not currently supported; class=Ssh (23)
Hi @phostann! Have the same issue on windows 11. Did you fix it somehow? Everything working at linux (ubuntu 22.04), but getting the same error on windows 11
I also have this error when attempting to clone a repository. Any help or pointers would be much appreciated.
I also have this error when attempting to clone a repository。Everything working at Mac, but getting the same error on windows 11