Beispiel #1
0
        private ValidationResult ValidateRepository(string fromCommit, string toCommit)
        {
            if (!_repositoryReader.ToolExists())
            {
                return(ValidationResult.Fail("No git executable could be found"));
            }
            if (!_repositoryReader.RepositoryExists())
            {
                return(ValidationResult.Fail($"No repository could be found at: {_repositoryReader.WorkingDirectory}"));
            }

            if (!_repositoryReader.CommitExists(fromCommit))
            {
                return(ValidationResult.Fail($"No commit could be found: {fromCommit}"));
            }

            if (!_repositoryReader.CommitExists(toCommit))
            {
                return(ValidationResult.Fail($"No commit could be found: {toCommit}"));
            }

            if (!_repositoryReader.CommitIsAncestor(toCommit, fromCommit))
            {
                return(ValidationResult.Fail($"The commit {fromCommit} is not an ancestor of {toCommit}"));
            }

            return(ValidationResult.Pass);
        }