forked from mirrors/jj
git: set authentication callback on fetch as well
I guess I had not run `jj git fetch` from GitHub until I tried to fetch the result of PR #6 just now.
This commit is contained in:
parent
6a2bb466ac
commit
429a1ad7ab
1 changed files with 7 additions and 1 deletions
|
@ -90,8 +90,14 @@ pub fn fetch(
|
|||
}
|
||||
_ => GitFetchError::InternalGitError(err),
|
||||
})?;
|
||||
let mut callbacks = git2::RemoteCallbacks::new();
|
||||
callbacks.credentials(|_url, username_from_url, _allowed_types| {
|
||||
git2::Cred::ssh_key_from_agent(username_from_url.unwrap())
|
||||
});
|
||||
let mut fetch_options = git2::FetchOptions::new();
|
||||
fetch_options.remote_callbacks(callbacks);
|
||||
let refspec: &[&str] = &[];
|
||||
remote.fetch(refspec, None, None)?;
|
||||
remote.fetch(refspec, Some(&mut fetch_options), None)?;
|
||||
import_refs(tx, git_repo).map_err(|err| match err {
|
||||
GitImportError::InternalGitError(source) => GitFetchError::InternalGitError(source),
|
||||
})?;
|
||||
|
|
Loading…
Reference in a new issue