@@ -137,6 +137,54 @@ mod v1 {
137
137
Ok ( ( ) )
138
138
}
139
139
}
140
+
141
+ mod arguments {
142
+ use crate :: fetch:: response:: id;
143
+ use crate :: fetch:: transport;
144
+ use bstr:: ByteSlice ;
145
+ use gix_protocol:: { fetch, Command } ;
146
+ use gix_transport:: client:: Capabilities ;
147
+ use gix_transport:: Protocol ;
148
+
149
+ #[ maybe_async:: test( feature = "blocking-client" , async ( feature = "async-client" , async_std:: test) ) ]
150
+ async fn all ( ) -> crate :: Result {
151
+ let ( caps, _) = Capabilities :: from_bytes ( & b"7814e8a05a59c0cf5fb186661d1551c75d1299b5 HEAD\0 multi_ack thin-pack filter side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed symref=HEAD:refs/heads/master object-format=sha1 agent=git/2.28.0" [ ..] ) ?;
152
+ let mut args = fetch:: Arguments :: new ( Protocol :: V1 , Command :: Fetch . default_features ( Protocol :: V1 , & caps) ) ;
153
+ assert ! ( args. can_use_shallow( ) ) ;
154
+ assert ! ( args. can_use_deepen( ) ) ;
155
+ assert ! ( args. can_use_deepen_not( ) ) ;
156
+ assert ! ( args. can_use_deepen_relative( ) ) ;
157
+ assert ! ( args. can_use_deepen_since( ) ) ;
158
+ assert ! ( args. can_use_filter( ) ) ;
159
+ assert ! ( args. can_use_include_tag( ) ) ;
160
+ assert ! (
161
+ !args. can_use_ref_in_want( ) ,
162
+ "V2 only feature, and we initialize capabilities with V1 for convenience"
163
+ ) ;
164
+ assert ! ( args. is_empty( ) ) ;
165
+
166
+ args. shallow ( id ( "97c5a932b3940a09683e924ef6a92b31a6f7c6de" ) ) ;
167
+ args. deepen ( 1 ) ;
168
+ args. deepen_relative ( ) ;
169
+ args. deepen_since ( 123456 ) ;
170
+ args. deepen_not ( "tag" . into ( ) ) ;
171
+ args. want ( id ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ) ) ;
172
+ args. have ( id ( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" ) ) ;
173
+
174
+ let mut out = Vec :: new ( ) ;
175
+ let mut transport = transport (
176
+ & mut out,
177
+ "v1/clone.response" ,
178
+ Protocol :: V2 ,
179
+ gix_transport:: client:: git:: ConnectMode :: Daemon ,
180
+ ) ;
181
+
182
+ let _response = args. send ( & mut transport, true ) . await ?;
183
+ drop ( _response) ;
184
+ assert_eq ! ( out. as_slice( ) . as_bstr( ) , "00aawant aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa thin-pack side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative include-tag multi_ack_detailed filter\n 000ddeepen 1\n 0014deepen-relative\n 0018deepen-since 123456\n 0013deepen-not tag\n 0035shallow 97c5a932b3940a09683e924ef6a92b31a6f7c6de\n 00000032have bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n 0009done\n " ) ;
185
+ Ok ( ( ) )
186
+ }
187
+ }
140
188
}
141
189
mod v2 {
142
190
mod from_line_reader {
@@ -305,4 +353,53 @@ mod v2 {
305
353
Ok ( ( ) )
306
354
}
307
355
}
356
+
357
+ mod arguments {
358
+ use crate :: fetch:: response:: id;
359
+ use crate :: fetch:: transport;
360
+ use bstr:: ByteSlice ;
361
+ use gix_protocol:: { fetch, Command } ;
362
+ use gix_transport:: client:: Capabilities ;
363
+ use gix_transport:: Protocol ;
364
+
365
+ #[ maybe_async:: test( feature = "blocking-client" , async ( feature = "async-client" , async_std:: test) ) ]
366
+ async fn all ( ) -> crate :: Result {
367
+ let ( caps, _) = Capabilities :: from_bytes ( & b"7814e8a05a59c0cf5fb186661d1551c75d1299b5 HEAD\0 multi_ack thin-pack filter side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed symref=HEAD:refs/heads/master object-format=sha1 agent=git/2.28.0" [ ..] ) ?;
368
+ let mut args = fetch:: Arguments :: new ( Protocol :: V2 , Command :: Fetch . default_features ( Protocol :: V1 , & caps) ) ;
369
+ assert ! ( args. can_use_shallow( ) ) ;
370
+ assert ! ( args. can_use_deepen( ) ) ;
371
+ assert ! ( args. can_use_deepen_not( ) ) ;
372
+ assert ! ( args. can_use_deepen_relative( ) ) ;
373
+ assert ! ( args. can_use_deepen_since( ) ) ;
374
+ assert ! ( args. can_use_filter( ) ) ;
375
+ assert ! ( args. can_use_include_tag( ) ) ;
376
+ assert ! (
377
+ !args. can_use_ref_in_want( ) ,
378
+ "V2 only feature, and we initialize capabilities with V1 for convenience"
379
+ ) ;
380
+ assert ! ( args. is_empty( ) ) ;
381
+
382
+ args. shallow ( id ( "97c5a932b3940a09683e924ef6a92b31a6f7c6de" ) ) ;
383
+ args. deepen ( 1 ) ;
384
+ args. deepen_relative ( ) ;
385
+ args. deepen_since ( 123456 ) ;
386
+ args. deepen_not ( "tag" . into ( ) ) ;
387
+ args. want ( id ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ) ) ;
388
+ args. have ( id ( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" ) ) ;
389
+
390
+ let mut out = Vec :: new ( ) ;
391
+ let mut transport = transport (
392
+ & mut out,
393
+ "v1/clone.response" ,
394
+ Protocol :: V2 ,
395
+ gix_transport:: client:: git:: ConnectMode :: Daemon ,
396
+ ) ;
397
+
398
+ let _response = args. send ( & mut transport, true ) . await ?;
399
+ drop ( _response) ;
400
+ assert_eq ! ( out. as_slice( ) . as_bstr( ) , "0012command=fetch\n 0001000ethin-pack\n 000eofs-delta\n 0035shallow 97c5a932b3940a09683e924ef6a92b31a6f7c6de\n 000ddeepen 1\n 0014deepen-relative\n 0018deepen-since 123456\n 0013deepen-not tag\n 0032want aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
401
+ 0032have bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n 0009done\n 0000" ) ;
402
+ Ok ( ( ) )
403
+ }
404
+ }
308
405
}
0 commit comments