@@ -151,10 +151,14 @@ public void CallsProgressCallbacks(string url)
151
151
152
152
Repository . Clone ( url , scd . DirectoryPath , new CloneOptions ( )
153
153
{
154
- OnTransferProgress = _ => { transferWasCalled = true ; return true ; } ,
155
- OnProgress = progress => { progressWasCalled = true ; return true ; } ,
156
- OnUpdateTips = ( name , oldId , newId ) => { updateTipsWasCalled = true ; return true ; } ,
154
+ FetchOptions =
155
+ {
156
+ OnTransferProgress = _ => { transferWasCalled = true ; return true ; } ,
157
+ OnProgress = progress => { progressWasCalled = true ; return true ; } ,
158
+ OnUpdateTips = ( name , oldId , newId ) => { updateTipsWasCalled = true ; return true ; }
159
+ } ,
157
160
OnCheckoutProgress = ( a , b , c ) => checkoutWasCalled = true
161
+
158
162
} ) ;
159
163
160
164
Assert . True ( transferWasCalled ) ;
@@ -174,7 +178,7 @@ public void CanCloneWithCredentials()
174
178
string clonedRepoPath = Repository . Clone ( Constants . PrivateRepoUrl , scd . DirectoryPath ,
175
179
new CloneOptions ( )
176
180
{
177
- CredentialsProvider = Constants . PrivateRepoCredentials
181
+ FetchOptions = { CredentialsProvider = Constants . PrivateRepoCredentials }
178
182
} ) ;
179
183
180
184
@@ -249,43 +253,46 @@ public void CanInspectCertificateOnClone(string url, string hostname, Type certT
249
253
250
254
var options = new CloneOptions
251
255
{
252
- CertificateCheck = ( cert , valid , host ) =>
256
+ FetchOptions =
253
257
{
254
- wasCalled = true ;
255
-
256
- Assert . Equal ( hostname , host ) ;
257
- Assert . Equal ( certType , cert . GetType ( ) ) ;
258
-
259
- if ( certType == typeof ( CertificateX509 ) )
258
+ CertificateCheck = ( cert , valid , host ) =>
260
259
{
261
- Assert . True ( valid ) ;
262
- var x509 = ( ( CertificateX509 ) cert ) . Certificate ;
263
- // we get a string with the different fields instead of a structure, so...
264
- Assert . Contains ( "CN=github.com," , x509 . Subject ) ;
265
- checksHappy = true ;
266
- return false ;
267
- }
260
+ wasCalled = true ;
261
+
262
+ Assert . Equal ( hostname , host ) ;
263
+ Assert . Equal ( certType , cert . GetType ( ) ) ;
264
+
265
+ if ( certType == typeof ( CertificateX509 ) )
266
+ {
267
+ Assert . True ( valid ) ;
268
+ var x509 = ( ( CertificateX509 ) cert ) . Certificate ;
269
+ // we get a string with the different fields instead of a structure, so...
270
+ Assert . Contains ( "CN=github.com," , x509 . Subject ) ;
271
+ checksHappy = true ;
272
+ return false ;
273
+ }
274
+
275
+ if ( certType == typeof ( CertificateSsh ) )
276
+ {
277
+ var hostkey = ( CertificateSsh ) cert ;
278
+ Assert . True ( hostkey . HasMD5 ) ;
279
+ /*
280
+ * Once you've connected and thus your ssh has stored the hostkey,
281
+ * you can get the hostkey for a host with
282
+ *
283
+ * ssh-keygen -F github.com -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':'
284
+ *
285
+ * though GitHub's hostkey won't change anytime soon.
286
+ */
287
+ Assert . Equal ( "1627aca576282d36631b564debdfa648" ,
288
+ BitConverter . ToString ( hostkey . HashMD5 ) . ToLower ( ) . Replace ( "-" , "" ) ) ;
289
+ checksHappy = true ;
290
+ return false ;
291
+ }
268
292
269
- if ( certType == typeof ( CertificateSsh ) )
270
- {
271
- var hostkey = ( CertificateSsh ) cert ;
272
- Assert . True ( hostkey . HasMD5 ) ;
273
- /*
274
- * Once you've connected and thus your ssh has stored the hostkey,
275
- * you can get the hostkey for a host with
276
- *
277
- * ssh-keygen -F github.com -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':'
278
- *
279
- * though GitHub's hostkey won't change anytime soon.
280
- */
281
- Assert . Equal ( "1627aca576282d36631b564debdfa648" ,
282
- BitConverter . ToString ( hostkey . HashMD5 ) . ToLower ( ) . Replace ( "-" , "" ) ) ;
283
- checksHappy = true ;
284
293
return false ;
285
294
}
286
-
287
- return false ;
288
- } ,
295
+ }
289
296
} ;
290
297
291
298
Assert . Throws < UserCancelledException > ( ( ) =>
@@ -432,9 +439,12 @@ public void CanRecursivelyCloneSubmodules()
432
439
{
433
440
RecurseSubmodules = true ,
434
441
OnCheckoutProgress = checkoutProgressHandler ,
435
- OnUpdateTips = remoteRefUpdated ,
436
- RepositoryOperationStarting = repositoryOperationStarting ,
437
- RepositoryOperationCompleted = repositoryOperationCompleted ,
442
+ FetchOptions =
443
+ {
444
+ OnUpdateTips = remoteRefUpdated ,
445
+ RepositoryOperationStarting = repositoryOperationStarting ,
446
+ RepositoryOperationCompleted = repositoryOperationCompleted
447
+ }
438
448
} ;
439
449
440
450
string clonedRepoPath = Repository . Clone ( uri . AbsolutePath , scd . DirectoryPath , options ) ;
@@ -517,7 +527,7 @@ public void CanCancelRecursiveClone()
517
527
CloneOptions options = new CloneOptions ( )
518
528
{
519
529
RecurseSubmodules = true ,
520
- RepositoryOperationStarting = repositoryOperationStarting ,
530
+ FetchOptions = { RepositoryOperationStarting = repositoryOperationStarting }
521
531
} ;
522
532
523
533
Assert . Throws < UserCancelledException > ( ( ) =>
@@ -557,10 +567,8 @@ public void CannotCloneWithForbiddenCustomHeaders()
557
567
const string url = "https://github.com/libgit2/TestGitRepository" ;
558
568
559
569
const string knownHeader = "User-Agent: mygit-201" ;
560
- var cloneOptions = new CloneOptions ( )
561
- {
562
- FetchOptions = new FetchOptions { CustomHeaders = new String [ ] { knownHeader } }
563
- } ;
570
+ var cloneOptions = new CloneOptions ( ) ;
571
+ cloneOptions . FetchOptions . CustomHeaders = new string [ ] { knownHeader } ;
564
572
565
573
Assert . Throws < LibGit2SharpException > ( ( ) => Repository . Clone ( url , scd . DirectoryPath , cloneOptions ) ) ;
566
574
}
@@ -573,10 +581,8 @@ public void CannotCloneWithMalformedCustomHeaders()
573
581
const string url = "https://github.com/libgit2/TestGitRepository" ;
574
582
575
583
const string knownHeader = "hello world" ;
576
- var cloneOptions = new CloneOptions ( )
577
- {
578
- FetchOptions = new FetchOptions { CustomHeaders = new String [ ] { knownHeader } }
579
- } ;
584
+ var cloneOptions = new CloneOptions ( ) ;
585
+ cloneOptions . FetchOptions . CustomHeaders = new string [ ] { knownHeader } ;
580
586
581
587
Assert . Throws < LibGit2SharpException > ( ( ) => Repository . Clone ( url , scd . DirectoryPath , cloneOptions ) ) ;
582
588
}
@@ -589,10 +595,8 @@ public void CanCloneWithCustomHeaders()
589
595
const string url = "https://github.com/libgit2/TestGitRepository" ;
590
596
591
597
const string knownHeader = "X-Hello: world" ;
592
- var cloneOptions = new CloneOptions ( )
593
- {
594
- FetchOptions = new FetchOptions { CustomHeaders = new String [ ] { knownHeader } }
595
- } ;
598
+ var cloneOptions = new CloneOptions ( ) ;
599
+ cloneOptions . FetchOptions . CustomHeaders = new string [ ] { knownHeader } ;
596
600
597
601
var clonedRepoPath = Repository . Clone ( url , scd . DirectoryPath , cloneOptions ) ;
598
602
Assert . True ( Directory . Exists ( clonedRepoPath ) ) ;
0 commit comments