private void OnCloneBuilds()
        {
            try
            {
                var items = this.view.SelectedItems.ToList();
                if (items.Count() != 1)
                {
                    return;
                }

                var item = items.First();
                using (new WaitCursor())
                {
                    var projects = this.repository.GetProjectsToBuild(item.Uri).ToList();
                    if (!projects.Any())
                    {
                        this.ShowInvalidActionMessage("Clone Build to Branch", "Could not locate any projects in the selected build(s)");
                        return;
                    }

                    var project      = projects.First();
                    var branchObject = this.repository.GetBranchObjectForItem(project);
                    if (branchObject == null)
                    {
                        this.ShowNoBranchMessage(project);
                        return;
                    }

                    var childBranches = this.repository.GetChildBranchObjectsForItem(branchObject.ServerPath).ToList();
                    if (!childBranches.Any())
                    {
                        MessageBox.Show(this.owner, "No branch exist for " + branchObject.ServerPath, "Clone Build To Branch", MessageBoxButton.OK, MessageBoxImage.Stop);
                        return;
                    }

                    var  dlg = new SelectTargetBranchWindow(item.Name, childBranches, item.TeamProject, this.repository);
                    bool?res = dlg.ShowDialog();
                    if (res.HasValue && res.Value)
                    {
                        this.repository.CloneBuild(item.Uri, dlg.NewBuildDefinitionName, branchObject, dlg.SelectedTargetBranch);
                    }

                    this.OnRefresh(new EventArgs());
                }
            }
            catch (Exception ex)
            {
                this.view.DisplayError(ex);
            }
        }
예제 #2
0
        private void OnCloneBuilds()
        {
            try
            {
                var items = this.view.SelectedItems.ToList();
                if (items.Count() != 1)
                {
                    return;
                }

                var item = items.First();
                if (item.BuildDefinition.SourceProviders.Any(s => s.Name == "TFGIT"))
                {
                    return;
                }

                using (new WaitCursor())
                {
                    var projects = this.repository.GetProjectsToBuild(item.Uri).ToList();
                    if (!projects.Any())
                    {
                        this.ShowInvalidActionMessage("Clone Build to Branch", "Could not locate any projects in the selected build(s)");
                        return;
                    }

                    var project = projects.First();
                    var branchObject = this.repository.GetBranchObjectForItem(project);
                    if (branchObject == null)
                    {
                        this.ShowNoBranchMessage(project);
                        return;
                    }

                    var childBranches = this.repository.GetChildBranchObjectsForItem(branchObject.ServerPath).ToList();
                    if (!childBranches.Any())
                    {
                        MessageBox.Show(this.owner, "No branch exist for " + branchObject.ServerPath, "Clone Build To Branch", MessageBoxButton.OK, MessageBoxImage.Stop);
                        return;
                    }

                    var dlg = new SelectTargetBranchWindow(item.Name, childBranches, item.TeamProject, this.repository);
                    bool? res = dlg.ShowDialog();
                    if (res.HasValue && res.Value)
                    {
                        this.repository.CloneBuild(item.Uri, dlg.NewBuildDefinitionName, branchObject, dlg.SelectedTargetBranch);
                    }

                    this.OnRefresh(new EventArgs());
                }
            }
            catch (Exception ex)
            {
                this.view.DisplayError(ex);
            }
        }