Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public int CompareTo(object obj)
        {
            CommitInfo info = (CommitInfo)obj;

            return(this.Author.CompareTo(info.Author));
        }