private async Task SendErrorsAndThresholdThroughMail(InspectionsComparator comparer)
        {
            if (!_mailNotifier.IsSetUp)
            {
                Console.WriteLine("The Software Quality mail notifier is not set up");
                return;
            }

            var(newIssues, _, _) = comparer.GetComparison();
            var newErrors = newIssues.Where(i => i.Severity == Severity.ERROR).ToArray();

            var blamer = new GitBlamer(_gitPath);

            var(_, headCommit) = await _teamcityService.ComputeCommitRange(_buildId);

            var contributors = await blamer.GetNewContributors(headCommit, newErrors, newErrors.Length, ComputePathToRepo);

            foreach (var contributor in contributors)
            {
                try
                {
                    Console.WriteLine($"Sending mail to {contributor.Name} for errors in inspection");
                    var body = await GetBody(contributor.Contributions, contributor.Name);

                    await _mailNotifier.SendMail("Errors in daily inspection", contributor.Mail, contributor.Name, body);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Failed to send mail to {contributor.Name}: {e.Message}");
                }
            }
        }
Example #2
0
        public async Task RunAsync()
        {
            var comparer = new InspectionsComparator(_old, _new, null);

            var(newIssues, removedIssues, _) = comparer.GetComparison();

            var blamer = new GitBlamer(_gitPath);

            var contributorsForNewViolations = await blamer.GetNewContributors(_headCommit, newIssues, 10, ComputePathToRepo);

            var contributorsForRemovalViolations = await blamer.GetRemovalContributors(_baseCommit, _headCommit, removedIssues, 10, ComputePathToRepo);

            Console.WriteLine("The top ten collaborators who added violations are:");
            var rank = 1;

            foreach (var collaborator in contributorsForNewViolations)
            {
                Console.WriteLine($"{rank}# {collaborator.Name} with {collaborator.Contributions.Count} fragments");
                rank++;
            }
            Console.WriteLine("");
            Console.WriteLine("The top ten collaborators who removed violations are:");
            var goodRank = 1;

            foreach (var collaborator in contributorsForRemovalViolations)
            {
                Console.WriteLine($"{goodRank}# {collaborator.Name} with {collaborator.Contributions.Count} fragments");
                goodRank++;
            }
        }