コード例 #1
0
        public void GetChild_Test()
        {
            var existingBuildStatus = new GitRepositoryBuildStatus("repo-1", "dev")
            {
                DependingRepositories = new List <GitRepositoryBuildStatus>()
                {
                    new GitRepositoryBuildStatus("repo-2", "dev")
                    {
                        DependingRepositories = new List <GitRepositoryBuildStatus>()
                        {
                            new GitRepositoryBuildStatus("repo-3", "dev")
                        }
                    },
                    new GitRepositoryBuildStatus("repo-4", "dev")
                }
            };

            existingBuildStatus.GetChild("repo-3").RepositoryName.ShouldBe("repo-3");
            existingBuildStatus.GetChild("repo-4").RepositoryName.ShouldBe("repo-4");
        }
コード例 #2
0
        public void Add_New_Build_Status_For_Child_Repository_Test()
        {
            var existingBuildStatus = new GitRepositoryBuildStatus("volo", "dev")
            {
                DependingRepositories = new List <GitRepositoryBuildStatus>()
                {
                    new GitRepositoryBuildStatus("abp", "dev")
                    {
                        SucceedProjects = new List <DotNetProjectBuildStatus>
                        {
                            new DotNetProjectBuildStatus
                            {
                                CsProjPath = "project1.csproj",
                                CommitId   = "1"
                            }
                        }
                    }
                }
            };

            var newBuildStatus = new GitRepositoryBuildStatus(
                existingBuildStatus.RepositoryName,
                existingBuildStatus.BranchName
                )
            {
                DependingRepositories = new List <GitRepositoryBuildStatus>()
                {
                    new GitRepositoryBuildStatus("abp", "dev")
                    {
                        SucceedProjects = new List <DotNetProjectBuildStatus>
                        {
                            new DotNetProjectBuildStatus
                            {
                                CsProjPath = "project2.csproj",
                                CommitId   = "2"
                            }
                        }
                    }
                }
            };

            existingBuildStatus.MergeWith(newBuildStatus);
            existingBuildStatus.GetChild("abp").SucceedProjects.Count.ShouldBe(2);
        }
コード例 #3
0
        public void MergeWith(GitRepositoryBuildStatus newBuildStatus)
        {
            if (!newBuildStatus.CommitId.IsNullOrEmpty())
            {
                CommitId = newBuildStatus.CommitId;
            }

            foreach (var succeedProject in newBuildStatus.SucceedProjects)
            {
                AddOrUpdateProjectStatus(succeedProject);
            }

            foreach (var dependingRepositoryBuildStatus in newBuildStatus.DependingRepositories)
            {
                var existingDependingRepositoryBuildStatus = GetChild(dependingRepositoryBuildStatus.RepositoryName);
                var newDependingRepositoryBuildStatus      = newBuildStatus.GetChild(
                    dependingRepositoryBuildStatus.RepositoryName
                    );

                existingDependingRepositoryBuildStatus.MergeWith(newDependingRepositoryBuildStatus);
            }
        }
コード例 #4
0
        private void MarkProjectsForBuild(
            GitRepository repository,
            GitRepositoryBuildStatus repositoryBuildStatus,
            bool forceBuild,
            List <DotNetProjectInfo> allProjectList)
        {
            if (forceBuild || repositoryBuildStatus == null || repositoryBuildStatus.CommitId.IsNullOrEmpty())
            {
                // Mark all projects for build
                allProjectList.ForEach(e => e.ShouldBuild = true);
            }
            else
            {
                MarkChangedProjectsForBuild(
                    repository,
                    repositoryBuildStatus,
                    allProjectList
                    );
            }

            if (!repository.DependingRepositories.Any())
            {
                return;
            }

            foreach (var dependingRepository in repository.DependingRepositories)
            {
                var dependingRepositoryBuildStatus = repositoryBuildStatus?.GetChild(dependingRepository.Name);
                MarkProjectsForBuild(
                    dependingRepository,
                    dependingRepositoryBuildStatus,
                    forceBuild,
                    allProjectList
                    );
            }
        }
コード例 #5
0
        public void AddOrUpdateProjectStatus_Test()
        {
            var existingBuildStatus = new GitRepositoryBuildStatus("repo-1", "dev")
            {
                DependingRepositories = new List <GitRepositoryBuildStatus>()
                {
                    new GitRepositoryBuildStatus("repo-2", "dev")
                    {
                        SucceedProjects = new List <DotNetProjectBuildStatus>
                        {
                            new DotNetProjectBuildStatus
                            {
                                CsProjPath = "A.csproj",
                                CommitId   = "42"
                            }
                        },
                        DependingRepositories = new List <GitRepositoryBuildStatus>
                        {
                            new GitRepositoryBuildStatus("repo-3", "dev")
                            {
                                SucceedProjects = new List <DotNetProjectBuildStatus>
                                {
                                    new DotNetProjectBuildStatus
                                    {
                                        CsProjPath = "B.csproj",
                                        CommitId   = "42"
                                    }
                                }
                            }
                        }
                    },
                    new GitRepositoryBuildStatus("repo-4", "dev")
                    {
                        SucceedProjects = new List <DotNetProjectBuildStatus>()
                        {
                            new DotNetProjectBuildStatus
                            {
                                CsProjPath = "C.csproj",
                                CommitId   = "42"
                            }
                        }
                    }
                }
            };

            var repo2 = existingBuildStatus.GetChild("repo-2");

            repo2.AddOrUpdateProjectStatus(new DotNetProjectBuildStatus
            {
                CommitId   = "21",
                CsProjPath = "A.csproj"
            });

            var repo3 = existingBuildStatus.GetChild("repo-3");

            repo3.AddOrUpdateProjectStatus(new DotNetProjectBuildStatus
            {
                CommitId   = "21",
                CsProjPath = "X.csproj"
            });

            repo2.SucceedProjects.Count.ShouldBe(1);
            repo2.SucceedProjects.ShouldContain(e => e.CsProjPath == "A.csproj" && e.CommitId == "21");

            repo3.SucceedProjects.Count.ShouldBe(2);
            repo3.SucceedProjects.ShouldContain(e => e.CsProjPath == "X.csproj" && e.CommitId == "21");
        }