Esempio n. 1
0
        public IRepositorySnapshot EnrichWithGitStats(IRepositorySnapshot repositorySnapshot,
                                                      GitStatGranularity granularity,
                                                      Option <ISubject <int> > progress)
        {
            _logger.Debug($"Enriching repository snapshot with hash {repositorySnapshot.AtHash} with git stats");

            return(repositorySnapshot.With(repositorySnapshot
                                           .Files
                                           .Apply(files => files.AsParallel()
                                                  .Select((f, i) =>
            {
                var result = EnrichWithGitStats(f, granularity);
                progress.Do(subject => subject.OnNext(i + 1));

                return result;
            }))
                                           .ToList(),
                                           _gitCommands.GetHashForLatestCommit(repositorySnapshot.RootPath),
                                           commitCreationDate:
                                           _gitCommands.DateOfLatestCommitOnBranch(repositorySnapshot.RootPath),
                                           numberOfCommitsOnBranch:
                                           _gitCommands.NumberOfCommitsOnCurrentBranch(repositorySnapshot.RootPath)));

            // I can't find a way to make this work consistently, rev-parse doesn't return the precise number of branch-specific commits
            // commitRelativePosition: _gitCommands.GetOrderOfCurrentHeadRelativeToFirstCommitOfBranch(repositorySnapshot.RootPath),
        }
Esempio n. 2
0
        private IRepositorySnapshot ConvertCoverageReport(IRepositorySnapshot snapshot)
        {
            var coverageOutputLocation = snapshot.PathToCoverageResultFile.Match(x => x, string.Empty);
            var newPath = _converter.Convert(coverageOutputLocation,
                                             Path.GetDirectoryName(coverageOutputLocation) !);

            return(snapshot.With(pathToCoverageResultFile: newPath));
        }
Esempio n. 3
0
        private IRepositorySnapshot ConvertCoverageResults(IRepositorySnapshot repositorySnapshot)
        {
            var path = repositorySnapshot.PathToCoverageResultFile.Some(x => x)
                       .None(() => string.Empty);
            var result = _converter.Convert(path, Path.GetDirectoryName(path) !);

            return(repositorySnapshot.With(pathToCoverageResultFile: result.Some(x => x)
                                           .None(() => path)));
        }
Esempio n. 4
0
        public IRepositorySnapshot EnrichWithCoverage(IRepositorySnapshot repositorySnapshot)
        {
            _logger.Debug($"Enriching repository snapshot at {repositorySnapshot.AtHash} with coverage stats");
            var pathToCoverageFile = match(repositorySnapshot.PathToCoverageResultFile,
                                           s => s,
                                           () =>
                                           throw new
                                           OptionIsNoneException($"{nameof(repositorySnapshot.PathToCoverageResultFile)} cannot be None"));
            IEnumerable <IFileCoverage> coverages = _providerFactory.CreateProviderForFile(pathToCoverageFile)
                                                    .ParseFileCoveragesFromFilePath(pathToCoverageFile);

            return(repositorySnapshot.With(repositorySnapshot.Files
                                           .Apply(f => EnrichWithCoverage(f, coverages))
                                           .ToArray(),
                                           pathToCoverageResultFile: pathToCoverageFile));
        }