History

[transport] flexible version of version support check doesn't actually work :D

As we also hold a mutable borrow to the refs. Fair enough.

Sebastian Thiel committed 5 years ago

Commit 2b220f01 parent 22f7e6710 files · +89 −28Browse files

Showing the changes to git-protocol/src/fetch/function.rs (1 of 10 files). Show all

Unified · Split

git-protocol/src/fetch/function.rs+12−9
@@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines
55 use git_features::{progress, progress::Progress};
66 use git_transport::{
77 client,
8− client::{SetServiceResponse, TransportV2Ext},
8+ client::{ProtocolDecision, SetServiceResponse, TransportV2Ext},
99 Service,
1010 };
1111 use maybe_async::maybe_async;
@@ -71,6 +71,17 @@ where · 59 unmodified lines
7171 Err(err) => Err(err),
7272 }?;
7373
74+ match transport.supports_advertised_version(actual_protocol) {
75+ ProtocolDecision::Continue => {}
76+ ProtocolDecision::CloseConnectionImmediately => {
77+ drop(refs);
78+ transport.close().await;
79+ return Err((Error::TransportProtocolPolicyViolation {
80+ actual_version: actual_protocol,
81+ }));
82+ }
83+ }
84+
7485 let parsed_refs = match refs {
7586 Some(mut refs) => {
7687 assert_eq!(
@@ -88,14 +99,6 @@ where · 11 unmodified lines
8899 (actual_protocol, parsed_refs, capabilities)
89100 }; // this scope is needed, see https://github.com/rust-lang/rust/issues/76149
90101
91− if transport.desired_protocol_version() != protocol_version {
92− progress.info(format!(
93− "server did not support protocol {} and downgraded to {}",
94− transport.desired_protocol_version() as usize,
95− protocol_version as usize,
96− ));
97− }
98−
99102 let parsed_refs = match parsed_refs {
100103 Some(refs) => refs,
101104 None => {