Esempio n. 1
0
 public Repository AddSnapshot(IRepositorySnapshot snapshot) =>
 new Repository(RepositoryName,
                Snapshots.Match(s => s.Concat(new[] { snapshot })
                                .ToArray(),
                                new[] { snapshot }),
                CoverageExecutionCommand,
                CoverageOutputLocation);
Esempio n. 2
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. 3
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. 4
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. 5
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));
        }
Esempio n. 6
0
 public IRepositorySnapshot EnrichWithGitStats(IRepositorySnapshot repositorySnapshot,
                                               GitStatGranularity granularity)
 {
     return(EnrichWithGitStats(repositorySnapshot, granularity, None));
 }