Skip to content

Commit

Permalink
Merge pull request #27 from solidify/bugs/missing-jira-user
Browse files Browse the repository at this point in the history
Adding check for jira email when mapping user. #26
  • Loading branch information
MOlausson authored Feb 8, 2019
2 parents 8fb9fcf + 43d2928 commit 35109e3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
23 changes: 19 additions & 4 deletions src/WorkItemMigrator/JiraExport/JiraProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,28 @@ public int GetNumberOfComments(string key)
public string GetUserEmail(string username)
{
if (_userEmailCache.TryGetValue(username, out string email))
{
return email;
}
else
{
var user = Jira.Users.GetUserAsync(username).Result;
email = user.Email;
_userEmailCache.Add(username, email);
return email;
try
{
var user = Jira.Users.GetUserAsync(username).Result;
if(string.IsNullOrEmpty(user.Email))
{
Logger.Log(LogLevel.Warning, $"Email for user '{username}' not found in Jira, using '{username}' for mapping.");
return username;
}
email = user.Email;
_userEmailCache.Add(username, email);
return email;
}
catch(Exception e)
{
Logger.Log(LogLevel.Warning, $"User '{username}' not found in Jira, using '{username}' for mapping.");
return username;
}
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/WorkItemMigrator/Migration.Common/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,21 @@ public static void Summary()
{
Console.WriteLine("::: SUMMARY :::");
Console.WriteLine("===============");
foreach (var warning in Warnings)
if(Warnings.Count > 0)
{
Console.WriteLine("Warnings:");
LogInternal(LogLevel.Warning, warning);
foreach (var warning in Warnings)
{
LogInternal(LogLevel.Warning, warning);
}
}
foreach (var error in Errors)
if (Errors.Count > 0)
{
Console.WriteLine("Errors:");
LogInternal(LogLevel.Error, error);
foreach (var error in Errors)
{
LogInternal(LogLevel.Error, error);
}
}
}
}
Expand Down

0 comments on commit 35109e3

Please sign in to comment.