Example #1
0
 /// <summary>
 /// Insert an <paramref name="itemString"/> into <see cref="PullRequestListBox"/>
 /// </summary>
 /// <param name="itemString">The <see cref="string"/> to insert</param>
 /// <param name="prioritize">If this or <paramref name="checkState"/> is not <see cref="CheckState.Unchecked"/>, <paramref name="itemString"/> will be inserted at the top of <see cref="PullRequestListBox"/> as opposed to the bottom</param>
 /// <param name="checkState">The <see cref="CheckState"/> of the item</param>
 void InsertItem(string itemString, bool prioritize, CheckState checkState)
 {
     prioritize = prioritize || checkState != CheckState.Unchecked;
     if (prioritize)
     {
         PullRequestListBox.Items.Insert(0, itemString);
         PullRequestListBox.SetItemCheckState(0, checkState);
     }
     else
     {
         PullRequestListBox.Items.Add(itemString, checkState);
     }
 }
Example #2
0
 /// <summary>
 /// Insert an <paramref name="itemString"/> into <see cref="PullRequestListBox"/>
 /// </summary>
 /// <param name="itemString">The <see cref="string"/> to insert</param>
 /// <param name="prioritize">If this or <paramref name="isChecked"/> is <see langword="true"/>, <paramref name="itemString"/> will be inserted at the top of <see cref="PullRequestListBox"/> as opposed to the bottom</param>
 /// <param name="isChecked">If the item should be checked</param>
 void InsertItem(string itemString, bool prioritize, bool isChecked)
 {
     prioritize = prioritize || isChecked;
     if (prioritize)
     {
         PullRequestListBox.Items.Insert(0, itemString);
         if (isChecked)
         {
             PullRequestListBox.SetItemChecked(0, true);
         }
     }
     else
     {
         PullRequestListBox.Items.Add(itemString, isChecked);
     }
 }
Example #3
0
        /// <summary>
        /// Called when an item in <see cref="PullRequestListBox"/> is checked or unchecked. Unchecks opposing PRs
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The <see cref="ItemCheckEventArgs"/></param>
        void PullRequestListBox_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.NewValue != CheckState.Checked)
            {
                return;
            }
            //let's uncheck the opposing PR# if this is one of the outdated/updated testmerge
            var item   = (string)PullRequestListBox.Items[e.Index];
            var prefix = item.Split(' ')[0];

            for (var I = 0; I < PullRequestListBox.Items.Count; ++I)
            {
                var S = (string)PullRequestListBox.Items[I];
                if (S.Split(' ')[0] == prefix && S != item)
                {
                    PullRequestListBox.SetItemChecked(I, false);
                    break;
                }
            }
        }
 private void PullRequestListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     PullRequestListBox.UnselectAll();
 }
Example #5
0
        /// <summary>
        /// Called when the <see cref="ApplyButton"/> is clicked. Calls <see cref="ITGRepository.Update(bool)"/> if necessary, merge pull requests, and call <see cref="ITGCompiler.Compile(bool)"/>. Closes the <see cref="TestMergeManager"/> if appropriate
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The <see cref="EventArgs"/></param>
        async void ApplyButton_Click(object sender, EventArgs e)
        {
            Enabled       = false;
            UseWaitCursor = true;
            ApplyingPullRequestsLabel.Visible       = true;
            ApplyingPullRequestsProgressBar.Visible = true;
            PullRequestListBox.Visible = false;
            try
            {
                //so first collect a list of pulls that are checked
                var pulls = new List <PullRequestInfo>();
                foreach (int I in PullRequestListBox.CheckedIndices)
                {
                    var    S              = (string)PullRequestListBox.Items[I];
                    string mergedSha      = null;
                    var    splits         = S.Split(' ');
                    var    mergedOnRemote = S.Contains(" - MERGED ON REMOTE: ");
                    if (mergedOnRemote && UpdateToRemoteRadioButton.Checked)
                    {
                        continue;
                    }
                    if ((S.Contains(" - OUTDATED: ") || mergedOnRemote) && PullRequestListBox.GetItemCheckState(I) == CheckState.Indeterminate)
                    {
                        mergedSha = splits[splits.Length - 1];
                    }
                    var key = Convert.ToInt32((splits[0].Substring(1)));
                    try
                    {
                        pulls.Add(new PullRequestInfo(key, mergedSha));
                    }
                    catch
                    {
                        MessageBox.Show(String.Format("Checked both keep and update option for #{0}", key), "Error");
                        return;
                    }
                }

                var repo = currentInterface.Repository;

                string error = null;
                //Do standard repo updates
                if (UpdateToRemoteRadioButton.Checked)
                {
                    await WrapServerOp(() => error = repo.Update(true));
                }
                else if (UpdateToOriginRadioButton.Checked)
                {
                    await WrapServerOp(() => error = repo.Reset(true));
                }

                if (error != null)
                {
                    MessageBox.Show(String.Format("Error updating repository: {0}", error));
                    return;
                }

                if (UpdateToRemoteRadioButton.Checked)
                {
                    GenerateChangelog(repo);
                    error = await Task.Run(() => repo.SynchronizePush());
                }

                //Merge the PRs, collect errors
                var errors = await Task.Run(() => repo.MergePullRequests(pulls, false));

                if (errors != null)
                {
                    //Show any errors
                    for (var I = 0; I < errors.Count(); ++I)
                    {
                        var err = errors.ElementAt(I);
                        if (err != null)
                        {
                            MessageBox.Show(err, String.Format("Error merging PR #{0}", pulls[I].Number));
                        }
                    }
                    return;
                }

                if (pulls.Count > 0)
                {
                    //regen the changelog
                    GenerateChangelog(repo);
                }

                //Start the compile
                var compileStarted = await Task.Run(() => currentInterface.Compiler.Compile(pulls.Count == 1));

                if (error != null)
                {
                    MessageBox.Show(String.Format("Error sychronizing repo: {0}", error));
                }

                if (!compileStarted)
                {
                    MessageBox.Show("Could not start compilation!");
                }
                else
                {
                    MessageBox.Show("Test merges updated and compilation started!");
                }
            }
            finally
            {
                Enabled       = true;
                UseWaitCursor = false;
                ApplyingPullRequestsLabel.Visible       = false;
                ApplyingPullRequestsProgressBar.Visible = false;
                PullRequestListBox.Visible = true;
            }
        }