@@ -43,10 +43,32 @@ mod blocking_and_async_io {
43
43
#[ allow( clippy:: result_large_err) ]
44
44
pub ( crate ) fn try_repo_rw (
45
45
name : & str ,
46
+ ) -> Result < ( gix:: Repository , gix_testtools:: tempfile:: TempDir ) , gix:: open:: Error > {
47
+ try_repo_rw_args ( name, Vec :: < String > :: new ( ) , Mode :: FastClone )
48
+ }
49
+
50
+ pub ( crate ) enum Mode {
51
+ FastClone ,
52
+ CloneWithShallowSupport ,
53
+ }
54
+
55
+ #[ allow( clippy:: result_large_err) ]
56
+ pub ( crate ) fn try_repo_rw_args < S : Into < String > > (
57
+ name : & str ,
58
+ args : impl IntoIterator < Item = S > ,
59
+ mode : Mode ,
46
60
) -> Result < ( gix:: Repository , gix_testtools:: tempfile:: TempDir ) , gix:: open:: Error > {
47
61
let dir = gix_testtools:: scripted_fixture_writable_with_args (
48
62
"make_fetch_repos.sh" ,
49
- [ base_repo_path ( ) ] ,
63
+ [ {
64
+ let mut url = base_repo_path ( ) ;
65
+ if matches ! ( mode, Mode :: CloneWithShallowSupport ) {
66
+ url. insert_str ( 0 , "file://" ) ;
67
+ }
68
+ url
69
+ } ]
70
+ . into_iter ( )
71
+ . chain ( args. into_iter ( ) . map ( Into :: into) ) ,
50
72
gix_testtools:: Creation :: ExecuteScript ,
51
73
)
52
74
. unwrap ( ) ;
@@ -84,6 +106,55 @@ mod blocking_and_async_io {
84
106
Ok ( ( ) )
85
107
}
86
108
109
+ #[ maybe_async:: test(
110
+ feature = "blocking-network-client" ,
111
+ async ( feature = "async-network-client-async-std" , async_std:: test)
112
+ ) ]
113
+ #[ ignore]
114
+ async fn fetch_shallow ( ) -> crate :: Result {
115
+ let ( repo, _tmp) = try_repo_rw_args ( "two-origins" , [ "--depth=2" ] , Mode :: CloneWithShallowSupport ) ?;
116
+ let remote = repo
117
+ . head ( ) ?
118
+ . into_remote ( Fetch )
119
+ . expect ( "present" ) ?
120
+ . with_fetch_tags ( fetch:: Tags :: Included ) ;
121
+
122
+ assert_eq ! (
123
+ repo. shallow_commits( ) ?. expect( "shallow clone" ) . as_slice( ) ,
124
+ [
125
+ hex_to_id( "2d9d136fb0765f2e24c44a0f91984318d580d03b" ) ,
126
+ hex_to_id( "dfd0954dabef3b64f458321ef15571cc1a46d552" ) ,
127
+ hex_to_id( "dfd0954dabef3b64f458321ef15571cc1a46d552" )
128
+ ]
129
+ ) ;
130
+ let prev_commits = repo. head_id ( ) ?. ancestors ( ) . all ( ) ?. count ( ) ;
131
+ let changes = remote
132
+ . connect ( Fetch , gix:: progress:: Discard )
133
+ . await ?
134
+ . prepare_fetch ( Default :: default ( ) )
135
+ . await ?
136
+ . with_shallow ( fetch:: Shallow :: Deepen ( 1 ) )
137
+ . receive ( & AtomicBool :: default ( ) )
138
+ . await ?;
139
+ dbg ! ( changes) ;
140
+
141
+ assert_eq ! (
142
+ repo. shallow_commits( ) ?. expect( "shallow clone" ) . as_slice( ) ,
143
+ [
144
+ hex_to_id( "2d9d136fb0765f2e24c44a0f91984318d580d03b" ) ,
145
+ hex_to_id( "dfd0954dabef3b64f458321ef15571cc1a46d552" ) ,
146
+ hex_to_id( "dfd0954dabef3b64f458321ef15571cc1a46d552" )
147
+ ] ,
148
+ "the shallow boundary was moved by one"
149
+ ) ;
150
+ assert_ne ! (
151
+ repo. head_id( ) ?. ancestors( ) . all( ) ?. count( ) ,
152
+ prev_commits,
153
+ "more commits are available now"
154
+ ) ;
155
+ Ok ( ( ) )
156
+ }
157
+
87
158
#[ maybe_async:: test(
88
159
feature = "blocking-network-client" ,
89
160
async ( feature = "async-network-client-async-std" , async_std:: test)
0 commit comments