You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have fill all of the values, I want to know what's wrong with these code.
OS: Windows 11
rustc: 1.70.0 (90c541806 2023-05-31)
git2: 0.17.2
My code:
fn push_repo() -> Result<(), git2::Error> {
let repo = Repository::open("cache/repo")?;
let mut remote = repo.find_remote("origin")?;
remote.connect_auth(Direction::Push, Some(create_callbacks()), None).unwrap();
repo.remote_add_push("origin", "refs/heads/temp:refs/heads/temp").unwrap();
let mut push_options = PushOptions::default();
let callbacks = create_callbacks();
push_options.remote_callbacks(callbacks);
remote.push(&["refs/heads/temp:refs/heads/temp"], Some(&mut push_options)).unwrap();
std::mem::drop(remote);
Ok(())
}
fn create_callbacks<'a>() -> RemoteCallbacks<'a>{
let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(|_url, username_from_url, _allowed_types| {
// Use the username from the url or a default one
let username = username_from_url.unwrap_or("git");
Cred::ssh_key(
username,
Some(std::path::Path::new("ssh_key/pushzig_rsa.pub")),
std::path::Path::new("ssh_key/pushzig_rsa"),
None,
)
});
callbacks
}
Error:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 34, message: "request failed with status code: 401" }', src\main.rs:261:74
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\zos-index-generator.exe new` (exit code: 101)
The text was updated successfully, but these errors were encountered:
I have fill all of the values, I want to know what's wrong with these code.
OS: Windows 11
rustc: 1.70.0 (90c541806 2023-05-31)
git2: 0.17.2
My code:
Error:
The text was updated successfully, but these errors were encountered: