示例#1
0
        public static async Task <CodeCheckResult> CheckForNeededBuild(this BuildProjectConfiguration config, ICodeRepository code, BuildQueueEntry latestBuild)
        {
            var maxFailureCount = config.MaxFailureCount;
            var force           = false;
            var codeInfo        = await code.GetInfo(config.RepositoryPath);

            string currentCommitIdentifier = codeInfo?.RevisionIdentifier;

            if (force || latestBuild == null)
            {
                return(CodeCheckResult.Force(currentCommitIdentifier));
            }
            else if (currentCommitIdentifier.Equals(latestBuild.RevisionIdentifier))
            {
                return(CodeCheckResult.Skip());
            }
            else if (latestBuild.FailCount > maxFailureCount)
            {
                return(CodeCheckResult.Skip());
            }
            else
            {
                var changedFiles = await code.GetChangedFiles(config.RepositoryPath, latestBuild?.RevisionIdentifier, currentCommitIdentifier);

                if (changedFiles.Count() <= 0)
                {
                    //reason = $"The build was skipped because no files in the latest commit matched the effective change filter.";
                    // continue to the next build
                    return(CodeCheckResult.Skip());
                }

                return(CodeCheckResult.Changed(currentCommitIdentifier));
            }
        }