Skip to content

Commit db161ee

Browse files
committed
No reason to derive from FetchOptionsBase and have FetchOptions property
1 parent 75b4432 commit db161ee

File tree

2 files changed

+51
-41
lines changed

2 files changed

+51
-41
lines changed

LibGit2Sharp.Tests/CloneFixture.cs

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,14 @@ public void CallsProgressCallbacks(string url)
151151

152152
Repository.Clone(url, scd.DirectoryPath, new CloneOptions()
153153
{
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+
},
157160
OnCheckoutProgress = (a, b, c) => checkoutWasCalled = true
161+
158162
});
159163

160164
Assert.True(transferWasCalled);
@@ -174,7 +178,7 @@ public void CanCloneWithCredentials()
174178
string clonedRepoPath = Repository.Clone(Constants.PrivateRepoUrl, scd.DirectoryPath,
175179
new CloneOptions()
176180
{
177-
CredentialsProvider = Constants.PrivateRepoCredentials
181+
FetchOptions = { CredentialsProvider = Constants.PrivateRepoCredentials }
178182
});
179183

180184

@@ -249,43 +253,46 @@ public void CanInspectCertificateOnClone(string url, string hostname, Type certT
249253

250254
var options = new CloneOptions
251255
{
252-
CertificateCheck = (cert, valid, host) =>
256+
FetchOptions =
253257
{
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) =>
260259
{
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+
}
268292

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;
284293
return false;
285294
}
286-
287-
return false;
288-
},
295+
}
289296
};
290297

291298
Assert.Throws<UserCancelledException>(() =>
@@ -432,9 +439,12 @@ public void CanRecursivelyCloneSubmodules()
432439
{
433440
RecurseSubmodules = true,
434441
OnCheckoutProgress = checkoutProgressHandler,
435-
OnUpdateTips = remoteRefUpdated,
436-
RepositoryOperationStarting = repositoryOperationStarting,
437-
RepositoryOperationCompleted = repositoryOperationCompleted,
442+
FetchOptions =
443+
{
444+
OnUpdateTips = remoteRefUpdated,
445+
RepositoryOperationStarting = repositoryOperationStarting,
446+
RepositoryOperationCompleted = repositoryOperationCompleted
447+
}
438448
};
439449

440450
string clonedRepoPath = Repository.Clone(uri.AbsolutePath, scd.DirectoryPath, options);
@@ -517,7 +527,7 @@ public void CanCancelRecursiveClone()
517527
CloneOptions options = new CloneOptions()
518528
{
519529
RecurseSubmodules = true,
520-
RepositoryOperationStarting = repositoryOperationStarting,
530+
FetchOptions = { RepositoryOperationStarting = repositoryOperationStarting }
521531
};
522532

523533
Assert.Throws<UserCancelledException>(() =>

LibGit2Sharp/CloneOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace LibGit2Sharp
66
/// <summary>
77
/// Options to define clone behaviour
88
/// </summary>
9-
public sealed class CloneOptions : FetchOptionsBase, IConvertableToGitCheckoutOpts
9+
public sealed class CloneOptions : IConvertableToGitCheckoutOpts
1010
{
1111
/// <summary>
1212
/// Creates default <see cref="CloneOptions"/> for a non-bare clone

0 commit comments

Comments
 (0)