public async Task <PublishImpactChangesResponse> PublishChanges()
        {
            var currentSourceVersion = _build.SourceVersion;
            var baseBuild            = await GetBaseBuildAsync();

            if (baseBuild == null)
            {
                _logger.Info($"This is the first test session for pipeline {_build.AzureBuildDefinitionId}, product-line '{_productLineKey}'. All tests will be run.");
                return(await PublishNoBaseBuild());
            }
            var baseSourceVersion = baseBuild.SourceVersion;

            if (baseSourceVersion == currentSourceVersion)
            {
                _logger.Warn("This test session is being run for the same source version as the previous session: " + currentSourceVersion);
            }
            else if (!_devOpsServerHandle.IsChronologicallyAfter(currentSourceVersion, baseSourceVersion))
            {
                _logger.Info($"Source version used for this test ({currentSourceVersion}) is older than the last test ran on this build definition ({baseSourceVersion}). Nothing to update.");
                return(PublishImpactChangesResponse.Empty());
            }
            var changes = await _devOpsServerHandle.GetBuildChangesAsync(baseBuild, _build);

            LogChanges(baseBuild, _build, changes);
            return(await PublishChanges(changes));
        }
        private void LogImpactedTests(Dictionary <string, string> codeSignaturesDict, PublishImpactChangesResponse response)
        {
            if (response.ImpactedTests.Count == 0)
            {
                _logger.Debug("No tests impacted.");
                return;
            }
            _logger.Debug(response.ImpactedTests.Count + " tests impacted.");

            StringBuilder msg        = new StringBuilder();
            int           delimCount = 15;
            var           header     = new StringBuilder()
                                       .Append('=', delimCount).Append("  Impact Information  ").Append('=', delimCount)
                                       .ToString();

            msg.AppendLine().AppendLine(header);

            var testCasesDict = response.ImpactedTests.ToDictionary(it => it.TestCaseId, it => it.AzureTestCaseId);

            foreach (var cs in response.CodeSignatureImpactedTestCaseIds)
            {
                var path             = codeSignaturesDict[cs.Key];
                var azureTestCaseIds = cs.Value.Select(id => testCasesDict[id]).OrderBy(t => t).ToList();

                msg.AppendLine(
                    $"{cs.Key}  \"{path}\" - {azureTestCaseIds.Count} test cases:");
                AppendTestCases(msg, azureTestCaseIds);
            }
            msg.Append('=', header.Length).AppendLine();
            _logger.Debug(msg.ToString());
        }