mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
use auto proxy option
This commit is contained in:
parent
bfba218fb4
commit
53e855e488
3 changed files with 22 additions and 6 deletions
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
ProgressPercent,
|
||||
};
|
||||
use crossbeam_channel::Sender;
|
||||
use git2::{BranchType, FetchOptions, Repository};
|
||||
use git2::{BranchType, FetchOptions, ProxyOptions, Repository};
|
||||
use scopetime::scope_time;
|
||||
use utils::bytes2string;
|
||||
|
||||
|
|
@ -25,6 +25,13 @@ use super::RepoPath;
|
|||
/// origin
|
||||
pub const DEFAULT_REMOTE_NAME: &str = "origin";
|
||||
|
||||
///
|
||||
pub fn proxy_auto<'a>() -> ProxyOptions<'a> {
|
||||
let mut proxy = ProxyOptions::new();
|
||||
proxy.auto();
|
||||
proxy
|
||||
}
|
||||
|
||||
///
|
||||
pub fn get_remotes(repo_path: &RepoPath) -> Result<Vec<String>> {
|
||||
scope_time!("get_remotes");
|
||||
|
|
@ -92,6 +99,7 @@ fn fetch_from_remote(
|
|||
let mut options = FetchOptions::new();
|
||||
let callbacks = Callbacks::new(progress_sender, basic_credential);
|
||||
options.prune(git2::FetchPrune::On);
|
||||
options.proxy_options(proxy_auto());
|
||||
options.download_tags(git2::AutotagOption::All);
|
||||
options.remote_callbacks(callbacks.callbacks());
|
||||
remote.fetch(&[] as &[&str], Some(&mut options), None)?;
|
||||
|
|
@ -161,6 +169,7 @@ pub(crate) fn fetch(
|
|||
options.download_tags(git2::AutotagOption::All);
|
||||
let callbacks = Callbacks::new(progress_sender, basic_credential);
|
||||
options.remote_callbacks(callbacks.callbacks());
|
||||
options.proxy_options(proxy_auto());
|
||||
|
||||
remote.fetch(&[branch], Some(&mut options), None)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,11 @@ use crate::{
|
|||
error::{Error, Result},
|
||||
progress::ProgressPercent,
|
||||
sync::{
|
||||
branch::branch_set_upstream, cred::BasicAuthCredential,
|
||||
remotes::Callbacks, repository::repo, CommitId, RepoPath,
|
||||
branch::branch_set_upstream,
|
||||
cred::BasicAuthCredential,
|
||||
remotes::{proxy_auto, Callbacks},
|
||||
repository::repo,
|
||||
CommitId, RepoPath,
|
||||
},
|
||||
};
|
||||
use crossbeam_channel::Sender;
|
||||
|
|
@ -143,6 +146,7 @@ pub fn push_raw(
|
|||
let mut remote = repo.find_remote(remote)?;
|
||||
|
||||
let mut options = PushOptions::new();
|
||||
options.proxy_options(proxy_auto());
|
||||
|
||||
let callbacks = Callbacks::new(progress_sender, basic_credential);
|
||||
options.remote_callbacks(callbacks.callbacks());
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ use crate::{
|
|||
error::Result,
|
||||
progress::ProgressPercent,
|
||||
sync::{
|
||||
cred::BasicAuthCredential, remotes::Callbacks,
|
||||
repository::repo, RepoPath,
|
||||
cred::BasicAuthCredential,
|
||||
remotes::{proxy_auto, Callbacks},
|
||||
repository::repo,
|
||||
RepoPath,
|
||||
},
|
||||
};
|
||||
use crossbeam_channel::Sender;
|
||||
|
|
@ -59,7 +61,7 @@ fn remote_tag_refs(
|
|||
let conn = remote.connect_auth(
|
||||
Direction::Fetch,
|
||||
Some(callbacks.callbacks()),
|
||||
None,
|
||||
Some(proxy_auto()),
|
||||
)?;
|
||||
|
||||
let remote_heads = conn.list()?;
|
||||
|
|
@ -133,6 +135,7 @@ pub fn push_tags(
|
|||
Callbacks::new(None, basic_credential.clone());
|
||||
options.remote_callbacks(callbacks.callbacks());
|
||||
options.packbuilder_parallelism(0);
|
||||
options.proxy_options(proxy_auto());
|
||||
remote.push(&[tag.as_str()], Some(&mut options))?;
|
||||
|
||||
progress_sender.as_ref().map(|sender| {
|
||||
|
|
|
|||
Loading…
Reference in a new issue