public static void Execute(string[] args) { CombinedReport reports = new CombinedReport(); reports.ReportDate = DateTime.Now; reports.Comparisons = new List <ComparisonReport>(); for (int i = 1; i < args.Length; i++) { try { ComparisonReport report = JsonConvert.DeserializeObject <ComparisonReport>(File.ReadAllText(args[i])); reports.Comparisons.Add(report); } catch (Exception e) { Console.Error.WriteLine($"Error while collecting reports: {e}"); } } using (Stream textStream = File.OpenWrite("report.txt")) using (StreamWriter textWriter = new StreamWriter(textStream)) { TextRenderer textRenderer = new TextRenderer(textWriter); Render(textRenderer, reports); } using (Stream htmlStream = File.OpenWrite("report.htm")) using (StreamWriter htmlWriter = new StreamWriter(htmlStream)) { HtmlRenderer htmlRenderer = new HtmlRenderer(htmlWriter); Render(htmlRenderer, reports); } using (Stream textStream = File.OpenWrite("commit-report.txt")) using (StreamWriter textWriter = new StreamWriter(textStream)) { TextRenderer textRenderer = new TextRenderer(textWriter); RenderCommitView(textRenderer, reports); } using (Stream htmlStream = File.OpenWrite("commit-report.htm")) using (StreamWriter htmlWriter = new StreamWriter(htmlStream)) { HtmlRenderer htmlRenderer = new HtmlRenderer(htmlWriter); RenderCommitView(htmlRenderer, reports); } }
public static void Execute(string[] args) { string ignoredDirectory = null; ComparisonReport report = new ComparisonReport(); report.TargetBranch = args[1]; report.TargetCommitId = args[2]; report.BaseBranch = args[3]; report.BaseCommitId = args[4]; if (args.Length > 5) { ignoredDirectory = args[5]; } report.Files = new Dictionary <string, List <FileReportLine> >(); report.Commits = new List <CommitInfo>(); HashSet <string> commits = new HashSet <string>(); HashSet <string> ignoredCommits = new HashSet <string>(); foreach (string file in ChangedFiles(report.BaseCommitId, report.TargetCommitId)) { List <FileReportLine> lines = GetUncoveredLines(file, report.BaseCommitId, report.TargetCommitId, ignoredDirectory); if (lines.Count == 0) { continue; } report.Files[file] = lines; foreach (FileReportLine line in lines) { if (line.Ignored) { ignoredCommits.Add(line.CommitId); } else { commits.Add(line.CommitId); } } } foreach (string commitId in commits) { report.Commits.Add(GetCommitInfo(commitId)); } foreach (string commitId in ignoredCommits) { if (!commits.Contains(commitId)) { CommitInfo info = GetCommitInfo(commitId); info.AllIgnored = true; report.Commits.Add(info); } } report.Commits.Sort(); File.WriteAllText("report.json", JsonConvert.SerializeObject(report)); }