Skip to content

Commit 0340b01

Browse files
committed
Allow remote overrides for http options
1 parent c523c22 commit 0340b01

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

git-repository/src/repository/config/transport.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ impl crate::Repository {
99
///
1010
/// Note that the caller may cast the instance themselves to modify it before passing it on.
1111
///
12-
///
13-
// let (mut cascade, _action_with_normalized_url, prompt_opts) =
14-
// self.remote.repo.config_snapshot().credential_helpers(url)?;
15-
// Ok(Box::new(move |action| cascade.invoke(action, prompt_opts.clone())) as AuthenticateFn<'_>)
16-
/// For transports that support proxy authentication, the authentication
17-
/// [default authentication method](crate::config::Snapshot::credential_helpers()) will be used with the url of the proxy.
12+
/// For transports that support proxy authentication, the
13+
/// [default authentication method](crate::config::Snapshot::credential_helpers()) will be used with the url of the proxy
14+
/// if it contains a user name.
1815
pub fn transport_options<'a>(
1916
&self,
2017
url: impl Into<&'a BStr>,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:495e3613b7ee9c5a02101dd307de24d9754e531e2840bedecfed00d55ea656af
3-
size 10252
2+
oid sha256:83f5270e487f0364e4a63f82cf4bfb5cb302bee744e9d3df521b7b3f850f3046
3+
size 10772

git-repository/tests/fixtures/make_config_repos.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ git init http-config
1616
git config gitoxide.http.connectTimeout 60k
1717
)
1818

19+
git clone --shared http-config http-remote-override
20+
(cd http-remote-override
21+
22+
git config http.proxy http://localhost:9090
23+
git config http.proxyAuthMethod basic
24+
25+
git config remote.origin.proxy overridden
26+
git config remote.origin.proxyAuthMethod negotiate
27+
)
28+
1929
git init http-proxy-empty
2030
(cd http-proxy-empty
2131
git config http.proxy localhost:9090

git-repository/tests/repository/config/transport_options.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
))]
55
mod http {
66
use git_repository as git;
7+
use git_transport::client::http::options::{FollowRedirects, ProxyAuthMethod};
78

89
pub(crate) fn repo(name: &str) -> git::Repository {
910
let dir = git_testtools::scripted_fixture_repo_read_only("make_config_repos.sh").unwrap();
@@ -20,6 +21,20 @@ mod http {
2021
.to_owned()
2122
}
2223

24+
#[test]
25+
#[ignore]
26+
fn remote_overrides() {
27+
let repo = repo("http-remote-override");
28+
let git_transport::client::http::Options {
29+
proxy,
30+
proxy_auth_method,
31+
..
32+
} = http_options(&repo);
33+
34+
assert_eq!(proxy.as_deref(), Some("overridden"));
35+
assert_eq!(proxy_auth_method, ProxyAuthMethod::Negotiate);
36+
}
37+
2338
#[test]
2439
fn simple_configuration() {
2540
let repo = repo("http-config");
@@ -40,22 +55,15 @@ mod http {
4055
&["ExtraHeader: value2", "ExtraHeader: value3"],
4156
"it respects empty values to clear prior values"
4257
);
43-
assert_eq!(
44-
follow_redirects,
45-
git_transport::client::http::options::FollowRedirects::Initial
46-
);
58+
assert_eq!(follow_redirects, FollowRedirects::Initial);
4759
assert_eq!(low_speed_limit_bytes_per_second, 5120);
4860
assert_eq!(low_speed_time_seconds, 10);
4961
assert_eq!(proxy.as_deref(), Some("http://localhost:9090"),);
5062
assert!(
5163
proxy_authenticate.is_none(),
5264
"no username means no authentication required"
5365
);
54-
assert_eq!(
55-
proxy_auth_method,
56-
git_transport::client::http::options::ProxyAuthMethod::Basic,
57-
"TODO: implement auth"
58-
);
66+
assert_eq!(proxy_auth_method, ProxyAuthMethod::Basic, "TODO: implement auth");
5967
assert_eq!(user_agent.as_deref(), Some("agentJustForHttp"));
6068
assert_eq!(connect_timeout, Some(std::time::Duration::from_millis(60 * 1024)));
6169
assert!(

0 commit comments

Comments
 (0)