private ProjectStatus CheckActiveProject(Guid projectId, string targetTeamProject) { ProjectStatus status = new ProjectStatus(); status.ProjectName = GetProjectName(projectId.ToString()); if (string.IsNullOrEmpty(status.ProjectName)) { status.IsDeletedRepo = true; status.IsDestroyedRepo = true; status.IsTargetingExpectedRepo = false; status.IsTargetingExpectedProject = false; } else { if (GetProjectDetails(targetTeamProject).Result.Id == projectId) { status.IsTargetingExpectedProject = true; } } return(status); }
private ArtifactLinkRecord ValidatePullRequestLink(WorkItem item, string targetTeamProject, string targetRepoName, GitArtifactLinkDetails linkDetails) { ProjectStatus projStatus = CheckProjecStatus(targetTeamProject, targetRepoName, linkDetails); ArtifactLinkRecord record = new ArtifactLinkRecord { WorkItemID = item.Id, WorkItemUrl = item.Url, ArtifactUri = linkDetails.Url, PullRequestID = linkDetails.PullRequestID, IsDeletedRepo = projStatus.IsDeletedRepo, isDestroyedRepo = projStatus.IsDestroyedRepo, isTargetingExpectedProject = projStatus.IsTargetingExpectedProject, isTargetingExpectedRepo = projStatus.IsTargetingExpectedRepo, LinkedProjectName = projStatus.ProjectName, LinkedRepoId = linkDetails.RepositoryID, LinkedRepoName = projStatus.RepoName, Rev = item.Rev.Value, ArtifactLinkIndex = linkDetails.Index }; return(record); }
private ProjectStatus CheckActiveRepos(string targetRepoName, Guid projectId, Guid repositoryID, ProjectStatus status) { string repoName = string.Empty; var activeProjectRepos = gitClient.GetRepositoriesAsync(projectId).Result; var linkedActiveRepo = (from r in activeProjectRepos where r.Id == repositoryID select r).SingleOrDefault(); if (linkedActiveRepo == null) { var deletedRepos = gitClient.GetDeletedRepositoriesAsync(projectId).Result; var deletedLinkedRepo = (from r in deletedRepos where r.Id == repositoryID select r).SingleOrDefault(); if (deletedLinkedRepo != null) { status.RepoName = deletedLinkedRepo.Name; status.IsDeletedRepo = true; } else { status.IsDestroyedRepo = true; } } else { status.RepoName = linkedActiveRepo.Name; if (status.RepoName == targetRepoName) { status.IsTargetingExpectedRepo = true; } } return(status); }