public static CardType CalculateLeanKitCardType(BoardMapping project, GitHubIssues.Issue issue) { // NOTE: GitHub does not use types for issues. It uses labels. // Default labels are: bug, duplicate, enhancement, invalid, question, wont fix // of those bug and enhancement are the ones that fit a type the best. // bug could be mapped to bug/issue in LeanKit and enhancement mapped to improvement/feature in LeanKit var defaultCardType = project.ValidCardTypes.FirstOrDefault(x => x.IsDefault); if (issue != null && issue.Labels != null && issue.Labels.Any()) { foreach (var label in issue.Labels) { var mappedWorkType = project.Types.FirstOrDefault(x => x.Target.ToLowerInvariant() == label.Name.ToLowerInvariant()); if (mappedWorkType != null) { var definedVal = project.ValidCardTypes.FirstOrDefault(x => x.Name.ToLowerInvariant() == mappedWorkType.LeanKit.ToLowerInvariant()); if (definedVal != null) { return definedVal; } } var implicitVal = project.ValidCardTypes.FirstOrDefault(x => x.Name.ToLowerInvariant() == label.Name.ToLowerInvariant()); if (implicitVal != null) { return implicitVal; } } } return defaultCardType; }
public static int CalculateLeanKitPriority(GitHubIssues.Issue issue) { // NOTE: GitHub does not use priorities for issues. The only thing we could do is use labels. // However the default labels of bug, duplicate, enhancement, invalid, question and wont fix // do not map well to priorities. We can look for custom labels but that would be up to the // GitHub admin to create the custom labels // If you would like to use different priorities/labels than the OOTB LeanKit priorities // then you will have to alter this method const int lkPriority = 1; // default to 1 - Normal // LK Priority: 0 = Low, 1 = Normal, 2 = High, 3 = Critical if (issue != null && issue.Labels != null && issue.Labels.Any()) { foreach (var label in issue.Labels) { switch (label.Name.ToLowerInvariant()) { case "critical": return 3; case "high": return 2; case "normal": return 1; case "low": return 0; } } } // else just set it to default of Normal return lkPriority; }
protected override void OnStartTest() { TestItem = new GitHubIssues(SubscriptionManager, ConfigurationProvider, LocalStorage, LeanKitClientFactory, RestClient); }
public static long? CalculateLeanKitAssignedUserId(long boardId, GitHubIssues.Issue issue, ILeanKitApi leanKit) { if (issue == null) return null; if (issue.Assignee != null && !string.IsNullOrEmpty(issue.Assignee.Login)) { var lkUser = leanKit.GetBoard(boardId).BoardUsers.FirstOrDefault(x => x != null && (((!string.IsNullOrEmpty(x.EmailAddress)) && x.EmailAddress.ToLowerInvariant() == issue.Assignee.Login.ToLowerInvariant()) || ((!string.IsNullOrEmpty(x.FullName)) && x.FullName.ToLowerInvariant() == issue.Assignee.Login.ToLowerInvariant()) || ((!string.IsNullOrEmpty(x.UserName)) && x.UserName.ToLowerInvariant() == issue.Assignee.Login.ToLowerInvariant()))); if (lkUser != null) return lkUser.Id; } return null; }