Exemplo n.º 1
0
        private void loadBranchMergeFromBranch_DataSet()
        {
            List <GitConfigs.Branch> branchList = new List <GitConfigs.Branch>();

            if (dgvRepositories.SelectedRows.Count > 0)
            {
                GitConfigs.Repository repository = getRepository();
                branchList = settingsXml.BranchList.FindAll(x => x.EntityGuid.Equals(from branchItem in repository.repositoryBranchOrderList
                                                                                     where repository.EntityGuid.Equals(repository.EntityGuid)
                                                                                     select branchItem.BranchGuid.FirstOrDefault()));
            }
            else
            {
                branchList = settingsXml.BranchList;
            }

            if (dgvBranches.SelectedRows.Count > 0)
            {
                GitConfigs.Branch branch = settingsXml.BranchList.Find(x => x.EntityGuid == dgvBranches.SelectedRows[0].Cells["BranchGuid"].Value.ToString());

                if (branch != null)
                {
                    branchList.Remove(branch);
                }
            }

            BindingSource bBranceMergeSource = new BindingSource();

            bBranceMergeSource.DataSource      = branchList;
            cbBranchMergeFromBranch.DataSource = bBranceMergeSource;
            bBranceMergeSource.ResetBindings(true);
        }
Exemplo n.º 2
0
        private void btnSaveRepository_Click(object sender, EventArgs e)
        {
            GitConfigs.Repository recordObj;
            bool newRecord = false;

            GitConfigs.Project project = settingsXml.ProjectList.Find(x => x.EntityGuid == dgvProjects.SelectedRows[0].Cells["ProjectGuid"].Value.ToString());

            if (project.RepositoryList.Count > 0 && txtRepositoryGuid.Text == String.Empty)
            {
                List <GitConfigs.Repository> repositoriesFound = project.RepositoryList.FindAll(x => x.EntityName == txtRepositoryName.Text || x.FolderPath == txtRepositoryFolderPath.Text);
                if (repositoriesFound.Count > 1)
                {
                    MessageBox.Show("There are duplicate records with that Name and Folder Path");
                    return;
                }

                if (repositoriesFound.Count == 1)
                {
                    txtRepositoryGuid.Text = repositoriesFound[0].EntityGuid;
                }
            }

            if (project.RepositoryList.Count == 0 || txtRepositoryGuid.Text == String.Empty)
            {
                newRecord = true;
                recordObj = new GitConfigs.Repository();
            }
            else
            {
                recordObj = project.RepositoryList.Find(x => x.EntityGuid == txtRepositoryGuid.Text);
                if (recordObj == null)
                {
                    newRecord = true;
                    recordObj = new GitConfigs.Repository();
                }
            }

            recordObj.EntityName        = txtRepositoryName.Text;
            recordObj.FolderPath        = txtRepositoryFolderPath.Text;
            recordObj.PerformPruneAtEnd = chkRepositoryPerformPruneAtEnd.Checked;
            recordObj.Active            = chkRepositoryActive.Checked;

            if (newRecord)
            {
                if (txtRepositoryGuid.Text == String.Empty)
                {
                    btnRepositoryGuidGenerator_Click(null, null);
                }

                recordObj.EntityGuid = txtRepositoryGuid.Text;
                project.RepositoryList.Add(recordObj);
            }

            saveSettings();
            btnRepositoryClear_Click(null, null);
            bRepositorySource.ResetBindings(true);
            enableDisableBranches(project);
        }
Exemplo n.º 3
0
        private DataTable getBranchesByRepository(DataTable dtBranches, GitConfigs.Repository repository)
        {
            foreach (GitConfigs.RepositoryBranchOrder repositoryBranchOrderItem in repository.repositoryBranchOrderList)
            {
                GitConfigs.Branch branch = settingsXml.BranchList.Find(x => x.EntityGuid == repositoryBranchOrderItem.BranchGuid);

                if (branch.Active)
                {
                    var newRow = dtBranches.NewRow();

                    newRow["Repository"] = repository.EntityName;
                    newRow["Name"]       = branch.EntityName;
                    newRow["Guid"]       = branch.EntityGuid;

                    dtBranches.Rows.Add(newRow);
                }
            }

            return(dtBranches);
        }
Exemplo n.º 4
0
        private void dgvRepositories_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvRepositories.SelectedRows.Count > 0)
            {
                GitConfigs.Repository repository = getRepository();

                txtRepositoryGuid.Text                 = repository.EntityGuid;
                txtRepositoryName.Text                 = repository.EntityName;
                txtRepositoryFolderPath.Text           = repository.FolderPath;
                chkRepositoryPerformPruneAtEnd.Checked = repository.PerformPruneAtEnd;
                chkRepositoryActive.Checked            = repository.Active;

                txtRepositoryGuid.Enabled = false;

                bBranchSource.DataSource = getBranches();
                bBranchSource.ResetBindings(true);
                dgvBranches.ClearSelection();

                loadBranchMergeFromBranch_DataSet();
            }
        }
Exemplo n.º 5
0
        private void btnSaveBranch_Click(object sender, EventArgs e)
        {
            var branchGuid = saveBranch();

            if (rdBranchAppliesToAllRepositoriesAllProjects.Checked)
            {
                foreach (GitConfigs.Project project in settingsXml.ProjectList)
                {
                    foreach (GitConfigs.Repository repository in project.RepositoryList)
                    {
                        if (!repository.repositoryBranchOrderList.Exists(x => x.BranchGuid == branchGuid))
                        {
                            GitConfigs.RepositoryBranchOrder repositoryBranchOrderItem = new GitConfigs.RepositoryBranchOrder();
                            repositoryBranchOrderItem.OrderBy    = repository.repositoryBranchOrderList.Count + 1;
                            repositoryBranchOrderItem.BranchGuid = branchGuid;
                            repository.repositoryBranchOrderList.Add(repositoryBranchOrderItem);
                        }
                    }
                }
            }
            else if (rdBranchAppliesToAllRepositoriesInCurrentProject.Checked)
            {
                GitConfigs.Project project = settingsXml.ProjectList.Find(x => x.EntityGuid == dgvProjects.SelectedRows[0].Cells["ProjectGuid"].Value.ToString());

                foreach (GitConfigs.Repository repository in project.RepositoryList)
                {
                    if (!repository.repositoryBranchOrderList.Exists(x => x.BranchGuid == branchGuid))
                    {
                        GitConfigs.RepositoryBranchOrder repositoryBranchOrderItem = new GitConfigs.RepositoryBranchOrder();
                        repositoryBranchOrderItem.OrderBy    = repository.repositoryBranchOrderList.Count + 1;
                        repositoryBranchOrderItem.BranchGuid = branchGuid;
                        repository.repositoryBranchOrderList.Add(repositoryBranchOrderItem);
                    }
                }
            }
            else if (rdBranchAppliesToSpecificRepositories.Checked)
            {
                foreach (DataRowView view in chklBranchesAppliesToSpecificRepositories.CheckedItems)
                {
                    var checkedItem = view[chklBranchesAppliesToSpecificRepositories.ValueMember].ToString();
                    GitConfigs.Repository repository = settingsXml.ProjectList.Find(x => x.EntityGuid == dgvProjects.SelectedRows[0].Cells["ProjectGuid"].Value.ToString()).RepositoryList.Find(x => x.EntityGuid == checkedItem);

                    if (!repository.repositoryBranchOrderList.Exists(x => x.BranchGuid == branchGuid))
                    {
                        GitConfigs.RepositoryBranchOrder repositoryBranchOrderItem = new GitConfigs.RepositoryBranchOrder();
                        repositoryBranchOrderItem.OrderBy    = repository.repositoryBranchOrderList.Count + 1;
                        repositoryBranchOrderItem.BranchGuid = branchGuid;
                        repository.repositoryBranchOrderList.Add(repositoryBranchOrderItem);
                    }
                }
            }
            else if (rdBranchAppliesToClearRepositoryBranches.Checked)
            {
                foreach (GitConfigs.Project project in settingsXml.ProjectList)
                {
                    foreach (GitConfigs.Repository repository in project.RepositoryList)
                    {
                        GitConfigs.RepositoryBranchOrder repositoryBranchOrderItem = repository.repositoryBranchOrderList.Find(x => x.BranchGuid == branchGuid);
                        if (repositoryBranchOrderItem != null)
                        {
                            foreach (GitConfigs.RepositoryBranchOrder repositoryBranchOrderItemUpdate in repository.repositoryBranchOrderList)
                            {
                                repository.repositoryBranchOrderList.Remove(repositoryBranchOrderItem);
                                if (repositoryBranchOrderItemUpdate.OrderBy >= repositoryBranchOrderItem.OrderBy)
                                {
                                    repositoryBranchOrderItemUpdate.OrderBy = -1;
                                }
                            }
                        }
                    }
                }
            }

            saveSettings();
            btnBranchClear_Click(null, null);
            dgvBranches.DataSource = settingsXml.BranchList;
        }