Exemple #1
0
        /// <summary>
        /// gets changesets for all work items of the specified state
        /// </summary>
        /// <param name="project"></param>
        /// <param name="state"></param>
        /// <param name="environment"></param>
        /// <returns></returns>
        public IEnumerable <Changeset> GetChangesetsByWorkItemState(Project project, string state, MergeEnvironment environment)
        {
            var tfs       = TfsTeamDataAccess.GetTfsTeamProjectCollection();
            var workItems = TfsTrackingDataAccess.GetTfsWorkItemsByState(tfs, project, state);

            return(workItems.SelectMany(w => GetTfsChangesetsBySource(tfs, w, environment)).ToList());
        }
Exemple #2
0
        /// <summary>
        /// get merge candidates for a project and environment
        /// </summary>
        /// <param name="project"></param>
        /// <param name="environment"></param>
        /// <returns></returns>
        public IEnumerable <Changeset> GetMergeCandidates(Project project, MergeEnvironment environment)
        {
            var tfs            = TfsTeamDataAccess.GetTfsTeamProjectCollection();
            var projects       = TfsTeamDataAccess.GetTfsProjects().ToList();
            var versionControl = tfs.GetService <VersionControlServer>();

            var mergeCandidates = new List <Changeset>();

            projects.ForEach(tfsProject => environment.Relationships.ToList().ForEach(relationship =>
            {
                var projectName = !tfsProject.ServerItem.EndsWith("/") ? tfsProject.ServerItem + "/" : tfsProject.Name;
                var sourcePath  = string.Format("{0}{1}/", projectName, relationship.Source.Name);
                var targetPath  = string.Format("{0}{1}/", projectName, relationship.Target.Name);
                try
                {
                    var candidates = versionControl.GetMergeCandidates(sourcePath, targetPath, RecursionType.Full).ToList();
                    candidates.ForEach(candidate =>
                    {
                        var workItems =
                            candidate.Changeset.WorkItems.Where(
                                workItem =>
                                workItem.State != "Active" &&
                                workItem.State != "In Review" &&
                                workItem.Type != workItem.Project.WorkItemTypes["Task"] &&                                                         // ignore changesets associated with task. Will create another audit that checks for changesets ONLY associated to task.
                                string.Compare(project.Name, workItem.Project.Name, StringComparison.OrdinalIgnoreCase) == 0);
                        if (workItems.Any())
                        {
                            mergeCandidates.Add(MapChangeset(candidate.Changeset, relationship.Source));
                        }
                    });
                }
                catch (Exception e)
                {
                }
            }));

            return(mergeCandidates);
        }