Beispiel #1
0
        public async Task RunAsync(CommandLineOptions options)
        {
            var git   = new GitCommands(options.GetGitOptions());
            var files = await git.GetFilesAsync().ConfigureAwait(false);

            var gitFileAnalyzer = new GitFileAnalyzer(options.GetFileAnalyzerOptions(), git);

            ICollection <AuthorStatistics> authorStatistics;

            using (var progressBar = CreateProgressBar(files.Count))
            {
                // ReSharper disable once AccessToDisposedClosure => false positive
                authorStatistics = await gitFileAnalyzer.BlameFilesAsync(files, progress => AdvanceProgressBar(progressBar, progress)).ConfigureAwait(false);

                var commitStatistics = await git.ShortlogAsync().ConfigureAwait(false);

                foreach (var commitStatistic in commitStatistics)
                {
                    var authorStatistic = authorStatistics.SingleOrDefault(x => x.Author.Equals(commitStatistic.Key));
                    if (authorStatistic == null)
                    {
                        authorStatistic = new AuthorStatistics(commitStatistic.Key);
                        authorStatistics.Add(authorStatistic);
                    }

                    authorStatistic.CommitCount = commitStatistic.Value;
                }

                var merger = new AuthorsMerger(options.GetAuthorMergeOptions());
                authorStatistics = merger.Merge(authorStatistics);
            }

            WriteOutput(options, authorStatistics);
            DisplaySummary(authorStatistics);
        }