Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 23b26fe

Browse files
Fix NullReferenceException for dynamic repositories without authentication
1 parent 81cc9b2 commit 23b26fe

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/GitTools.Core/GitTools.Core.Shared/Git/DynamicRepositories.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,19 @@ static void CheckoutCommit(IRepository repo, string targetCommit)
170170
static void CloneRepository(string repositoryUrl, string gitDirectory, AuthenticationInfo authentication)
171171
{
172172
Credentials credentials = null;
173-
if (!string.IsNullOrWhiteSpace(authentication.Username) && !string.IsNullOrWhiteSpace(authentication.Password))
174-
{
175-
Log.Info(string.Format("Setting up credentials using name '{0}'", authentication.Username));
176173

177-
credentials = new UsernamePasswordCredentials
174+
if (authentication != null)
175+
{
176+
if (!string.IsNullOrWhiteSpace(authentication.Username) && !string.IsNullOrWhiteSpace(authentication.Password))
178177
{
179-
Username = authentication.Username,
180-
Password = authentication.Password
181-
};
178+
Log.Info(string.Format("Setting up credentials using name '{0}'", authentication.Username));
179+
180+
credentials = new UsernamePasswordCredentials
181+
{
182+
Username = authentication.Username,
183+
Password = authentication.Password
184+
};
185+
}
182186
}
183187

184188
Log.Info(string.Format("Retrieving git info from url '{0}'", repositoryUrl));

0 commit comments

Comments
 (0)