@@ -13,7 +13,7 @@ use crate::{
13
13
ProgressPercent ,
14
14
} ;
15
15
use crossbeam_channel:: Sender ;
16
- use git2:: { BranchType , FetchOptions , Repository } ;
16
+ use git2:: { BranchType , FetchOptions , ProxyOptions , Repository } ;
17
17
use scopetime:: scope_time;
18
18
use utils:: bytes2string;
19
19
@@ -25,6 +25,13 @@ use super::RepoPath;
25
25
/// origin
26
26
pub const DEFAULT_REMOTE_NAME : & str = "origin" ;
27
27
28
+ ///
29
+ pub fn proxy_auto < ' a > ( ) -> ProxyOptions < ' a > {
30
+ let mut proxy = ProxyOptions :: new ( ) ;
31
+ proxy. auto ( ) ;
32
+ proxy
33
+ }
34
+
28
35
///
29
36
pub fn get_remotes ( repo_path : & RepoPath ) -> Result < Vec < String > > {
30
37
scope_time ! ( "get_remotes" ) ;
@@ -92,6 +99,7 @@ fn fetch_from_remote(
92
99
let mut options = FetchOptions :: new ( ) ;
93
100
let callbacks = Callbacks :: new ( progress_sender, basic_credential) ;
94
101
options. prune ( git2:: FetchPrune :: On ) ;
102
+ options. proxy_options ( proxy_auto ( ) ) ;
95
103
options. download_tags ( git2:: AutotagOption :: All ) ;
96
104
options. remote_callbacks ( callbacks. callbacks ( ) ) ;
97
105
remote. fetch ( & [ ] as & [ & str ] , Some ( & mut options) , None ) ?;
@@ -161,6 +169,7 @@ pub(crate) fn fetch(
161
169
options. download_tags ( git2:: AutotagOption :: All ) ;
162
170
let callbacks = Callbacks :: new ( progress_sender, basic_credential) ;
163
171
options. remote_callbacks ( callbacks. callbacks ( ) ) ;
172
+ options. proxy_options ( proxy_auto ( ) ) ;
164
173
165
174
remote. fetch ( & [ branch] , Some ( & mut options) , None ) ?;
166
175
0 commit comments