private ArtifactLinkRecord ValidateArtifactLink(WorkItem item, GitArtifactLinkDetails details, string targetTeamProject, string targetRepoName) { if (details.LinkType == GitLinkType.Commit) { return(ValidateTheGitCommitLink(item, targetTeamProject, targetRepoName, details)); } else if (details.LinkType == GitLinkType.PullRequest) { return(ValidatePullRequestLink(item, targetTeamProject, targetRepoName, details)); } return(null); }
private List <ArtifactLinkRecord> GetWorkItemRangeArtifactLinks(List <int> workItemIds /*, string workitemSource*/, string targetTeamProject, string targetRepoName) { List <ArtifactLinkRecord> records = new List <ArtifactLinkRecord>(); foreach (var item in workItemTrackingHttpClient.GetWorkItemsAsync(workItemIds, expand: WorkItemExpand.Relations).Result) { var artifactWorkItemLinks = item.Relations.Where(element => element.Rel == "ArtifactLink"); foreach (var artifactLink in artifactWorkItemLinks) { GitArtifactLinkDetails details = new GitArtifactLinkDetails(artifactLink, item.Relations.IndexOf(artifactLink)); if (details.IsGitLink) { ArtifactLinkRecord record = ValidateArtifactLink(item, details, targetTeamProject, targetRepoName); records.Add(record); } } Console.WriteLine($"Analyzing workItemID={item.Id}"); } return(records); }
private ProjectStatus CheckProjecStatus(string targetTeamProject, string targetRepoName, GitArtifactLinkDetails linkDetails) { ProjectStatus projStatus = CheckActiveProject(linkDetails.ProjectId, targetTeamProject); if (!string.IsNullOrEmpty(projStatus.ProjectName)) { projStatus = CheckActiveRepos(targetRepoName, linkDetails.ProjectId, linkDetails.RepositoryID, projStatus); } return(projStatus); }
private ArtifactLinkRecord ValidateTheGitCommitLink(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, commitID = linkDetails.CommitID, IsDeletedRepo = projStatus.IsDeletedRepo, isDestroyedRepo = projStatus.IsDestroyedRepo, isTargetingExpectedProject = projStatus.IsTargetingExpectedProject, isTargetingExpectedRepo = projStatus.IsTargetingExpectedRepo, LinkedProjectName = projStatus.ProjectName, LinkedRepoId = linkDetails.RepositoryID, LinkedRepoName = projStatus.RepoName, shortCommitID = linkDetails.CommitID.Substring(0, 8), Rev = item.Rev.Value, ArtifactLinkIndex = linkDetails.Index }; return(record); }