8000 Refactor Constants.PrivateRepoCredentials · GiTechLab/libgit2sharp@8cc996e · GitHub
[go: up one dir, main page]

Skip to content

Commit 8cc996e

Browse files
committed
Refactor Constants.PrivateRepoCredentials
1 parent 4bc4857 commit 8cc996e

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

LibGit2Sharp.Tests/CloneFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void CanCloneWithCredentials()
151151
string clonedRepoPath = Repository.Clone(Constants.PrivateRepoUrl, scd.DirectoryPath,
152152
new CloneOptions()
153153
{
154-
CredentialsProvider = (_url, _user, _cred) => Constants.PrivateRepoCredentials
154+
CredentialsProvider = Constants.PrivateRepoCredentials
155155
});
156156

157157

LibGit2Sharp.Tests/FetchFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void CanFetchIntoAnEmptyRepositoryWithCredentials()
6060
// Perform the actual fetch
6161
repo.Network.Fetch(remote, new FetchOptions
6262
{
63-
CredentialsProvider = (_url, _user, _credtype) => Constants.PrivateRepoCredentials
63+
CredentialsProvider = Constants.PrivateRepoCredentials
6464
});
6565
}
6666
}

LibGit2Sharp.Tests/NetworkFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void CanListRemoteReferencesWithCredentials()
121121
{
122122
Remote remote = repo.Network.Remotes.Add(remoteName, Constants.PrivateRepoUrl);
123123

124-
var references = repo.Network.ListReferences(remote, (_url, _user, _credtype) => Constants.PrivateRepoCredentials);
124+
var references = repo.Network.ListReferences(remote, Constants.PrivateRepoCredentials);
125125

126126
foreach (var directReference in references)
127127
{

LibGit2Sharp.Tests/TestHelpers/Constants.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,24 @@ public static class Constants
1010

1111
// Populate these to turn on live credential tests: set the
1212
// PrivateRepoUrl to the URL of a repository that requires
13-
// authentication. Set PrivateRepoCredentials to an instance of
13+
// authentication. Define PrivateRepoCredentials to return an instance of
1414
// UsernamePasswordCredentials (for HTTP Basic authentication) or
1515
// DefaultCredentials (for NTLM/Negotiate authentication).
1616
//
1717
// For example:
1818
// public const string PrivateRepoUrl = "https://github.com/username/PrivateRepo";
19-
// public static readonly Credentials PrivateRepoCredentials = new UsernamePasswordCredentials { Username = "username", Password = "swordfish" };
19+
// ... return new UsernamePasswordCredentials { Username = "username", Password = "swordfish" };
2020
//
2121
// Or:
2222
// public const string PrivateRepoUrl = "https://tfs.contoso.com/tfs/DefaultCollection/project/_git/project";
23-
// public static readonly Credentials PrivateRepoCredentials = new DefaultCredentials();
23+
// ... return new DefaultCredentials();
2424

2525
public const string PrivateRepoUrl = "";
26-
public static readonly Credentials PrivateRepoCredentials;
26+
27+
public static Credentials PrivateRepoCredentials(string url, string usernameFromUrl,
28+
SupportedCredentialTypes types)
29+
{
30+
return null;
31+
}
2732
}
2833
}

LibGit2Sharp/Handlers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
/// <summary>
2626
/// Delegate definition for the credentials retrieval callback
2727
/// </summary>
28-
/// <param name="usernameFromUrl">Username which was extracted form the url, if any</param>
2928
/// <param name="url">The url</param>
29+
/// <param name="usernameFromUrl">Username which was extracted from the url, if any</param>
3030
/// <param name="types">Credential types which the server accepts</param>
3131
public delegate Credentials CredentialsHandler(string url, string usernameFromUrl, SupportedCredentialTypes types);
3232

0 commit comments

Comments
 (0)
0