コード例 #1
0
        public DiffResult ScanDiff()
        {
            var diffResult = new DiffResult()
            {
                ChangedFiles = new Collection <string>(),
                TestsChanged = false
            };

            // A git repository has been detected, calculate the diff to filter
            var commit = _gitInfoProvider.DetermineCommit();

            if (commit == null)
            {
                throw new Stryker.Core.Exceptions.StrykerInputException("Could not determine a commit to check for diff. Please check you have provided the correct value for --git-source");
            }

            foreach (var patchChanges in _gitInfoProvider.Repository.Diff.Compare <Patch>(commit.Tree, DiffTargets.Index | DiffTargets.WorkingDirectory))
            {
                string diffPath = FilePathUtils.NormalizePathSeparators(Path.Combine(_gitInfoProvider.RepositoryPath, patchChanges.Path));
                diffResult.ChangedFiles.Add(diffPath);
                if (diffPath.StartsWith(_options.BasePath) && diffPath.EndsWith(".cs"))
                {
                    diffResult.TestsChanged = true;
                }
            }
            return(diffResult);
        }
コード例 #2
0
        public DiffResult ScanDiff()
        {
            var diffResult = new DiffResult()
            {
                ChangedSourceFiles = new Collection <string>(),
                ChangedTestFiles   = new Collection <string>()
            };

            // A git repository has been detected, calculate the diff to filter
            var repository = _gitInfoProvider.Repository;
            var commit     = _gitInfoProvider.DetermineCommit();

            if (commit == null)
            {
                throw new StrykerInputException("Could not determine a commit to check for diff. Please check you have provided the correct value for --git-source");
            }

            foreach (var patchChanges in repository.Diff.Compare <Patch>(commit.Tree, DiffTargets.WorkingDirectory))
            {
                string diffPath = FilePathUtils.NormalizePathSeparators(Path.Combine(_gitInfoProvider.RepositoryPath, patchChanges.Path));

                if (diffPath.EndsWith("stryker-config.json"))
                {
                    continue;
                }

                var fullName = _options.BasePath.EndsWith(Path.DirectorySeparatorChar)
                    ? _options.BasePath
                    : _options.BasePath + Path.DirectorySeparatorChar;

                if (diffPath.StartsWith(fullName))
                {
                    diffResult.ChangedTestFiles.Add(diffPath);
                }
                else
                {
                    diffResult.ChangedSourceFiles.Add(diffPath);
                }
            }
            RemoveFilteredOutFiles(diffResult);

            return(diffResult);
        }