Exemplo n.º 1
0
        private void RunFormTest(Func <FormCommit, Task> testDriverAsync, CommitKind commitKind = CommitKind.Normal)
        {
            UITest.RunForm(
                () =>
            {
                switch (commitKind)
                {
                case CommitKind.Normal:
                    Assert.True(_commands.StartCommitDialog(owner: null));
                    break;

                case CommitKind.Squash:
                    Assert.True(_commands.StartSquashCommitDialog(owner: null, _referenceRepository.Module.GetRevision()));
                    break;

                case CommitKind.Fixup:
                    Assert.True(_commands.StartFixupCommitDialog(owner: null, _referenceRepository.Module.GetRevision()));
                    break;

                default:
                    throw new ArgumentException($"Unsupported commit kind: {commitKind}", nameof(commitKind));
                }
            },
                testDriverAsync);
        }
Exemplo n.º 2
0
 private void RunFormTest(Action <FormCommit> testDriver, CommitKind commitKind = CommitKind.Normal)
 {
     RunFormTest(
         form =>
     {
         testDriver(form);
         return(Task.CompletedTask);
     },
         commitKind);
 }
Exemplo n.º 3
0
 private void RunFormTest(Func <FormCommit, Task> testDriverAsync, CommitKind commitKind = CommitKind.Normal)
 {
     UITest.RunForm(
         showForm: () =>
     {
         Assert.True(commitKind switch
         {
             CommitKind.Normal => _commands.StartCommitDialog(owner: null),
             CommitKind.Squash => _commands.StartSquashCommitDialog(owner: null, _referenceRepository.Module.GetRevision()),
             CommitKind.Fixup => _commands.StartFixupCommitDialog(owner: null, _referenceRepository.Module.GetRevision()),
             _ => throw new ArgumentException($"Unsupported commit kind: {commitKind}", nameof(commitKind))
         });
     },
Exemplo n.º 4
0
        public void DoNotPreserveCommitMessageOnReopenFromSpecialCommit(CommitKind commitKind)
        {
            var generatedCommitMessage = Guid.NewGuid().ToString();

            RunFormTest(
                form =>
            {
                string prefix = commitKind.ToString().ToLowerInvariant();
                Assert.AreEqual($"{prefix}! A commit message", form.GetTestAccessor().Message.Text);
                form.GetTestAccessor().Message.Text = generatedCommitMessage;
            },
                commitKind);

            RunFormTest(form =>
            {
                Assert.IsEmpty(form.GetTestAccessor().Message.Text);
            });
        }
Exemplo n.º 5
0
        public FormCommit(GitUICommands aCommands, CommitKind commitKind, GitRevision editedCommit)
            : base(true, aCommands)
        {
            _taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            _unstagedLoader = new AsyncLoader(_taskScheduler);

            _useFormCommitMessage = Settings.UseFormCommitMessage;

            InitializeComponent();
            Message.TextChanged += Message_TextChanged;
            Message.TextAssigned += Message_TextAssigned;

            Loading.Image = Properties.Resources.loadingpanel;

            Translate();

            SolveMergeconflicts.Font = new Font(SystemFonts.MessageBoxFont, FontStyle.Bold);

            SelectedDiff.ExtraDiffArgumentsChanged += SelectedDiffExtraDiffArgumentsChanged;

            if (IsUICommandsInitialized)
                StageInSuperproject.Visible = Module.SuperprojectModule != null;
            StageInSuperproject.Checked = Settings.StageInSuperprojectAfterCommit;
            closeDialogAfterEachCommitToolStripMenuItem.Checked = Settings.CloseCommitDialogAfterCommit;
            closeDialogAfterAllFilesCommittedToolStripMenuItem.Checked = Settings.CloseCommitDialogAfterLastCommit;
            refreshDialogOnFormFocusToolStripMenuItem.Checked = Settings.RefreshCommitDialogOnFormFocus;

            Unstaged.SetNoFilesText(_noUnstagedChanges.Text);
            Staged.SetNoFilesText(_noStagedChanges.Text);

            Message.Enabled = _useFormCommitMessage;

            commitMessageToolStripMenuItem.Enabled = _useFormCommitMessage;
            commitTemplatesToolStripMenuItem.Enabled = _useFormCommitMessage;

            Message.WatermarkText = _useFormCommitMessage
                ? _enterCommitMessageHint.Text
                : _commitMessageDisabled.Text;

            _commitKind = commitKind;
            _editedCommit = editedCommit;

            Unstaged.SelectedIndexChanged += UnstagedSelectionChanged;
            Staged.SelectedIndexChanged += StagedSelectionChanged;

            Unstaged.DoubleClick += Unstaged_DoubleClick;
            Staged.DoubleClick += Staged_DoubleClick;

            HotkeysEnabled = true;
            Hotkeys = HotkeySettingsManager.LoadHotkeys(HotkeySettingsName);

            SelectedDiff.AddContextMenuSeparator();
            _stageSelectedLinesToolStripMenuItem = SelectedDiff.AddContextMenuEntry(_stageSelectedLines.Text, StageSelectedLinesToolStripMenuItemClick);
            _stageSelectedLinesToolStripMenuItem.ShortcutKeyDisplayString = GetShortcutKeys((int)Commands.StageSelectedFile).ToShortcutKeyDisplayString();
            _resetSelectedLinesToolStripMenuItem = SelectedDiff.AddContextMenuEntry(_resetSelectedLines.Text, ResetSelectedLinesToolStripMenuItemClick);
            _resetSelectedLinesToolStripMenuItem.ShortcutKeyDisplayString = GetShortcutKeys((int)Commands.ResetSelectedFiles).ToShortcutKeyDisplayString();
            _resetSelectedLinesToolStripMenuItem.Image = Reset.Image;
            resetChanges.ShortcutKeyDisplayString = _resetSelectedLinesToolStripMenuItem.ShortcutKeyDisplayString;
        }
Exemplo n.º 6
0
        public FormCommit(CommitKind commitKind, GitRevision editedCommit)
        {
            _syncContext = SynchronizationContext.Current;

            InitializeComponent();

            splitRight.Panel2MinSize = 130;
            Translate();

            SolveMergeconflicts.Font = new Font(SystemFonts.MessageBoxFont, FontStyle.Bold);

            SelectedDiff.ExtraDiffArgumentsChanged += SelectedDiffExtraDiffArgumentsChanged;

            closeDialogAfterEachCommitToolStripMenuItem.Checked = Settings.CloseCommitDialogAfterCommit;
            closeDialogAfterAllFilesCommittedToolStripMenuItem.Checked = Settings.CloseCommitDialogAfterLastCommit;

            Unstaged.SetNoFilesText(_noUnstagedChanges.Text);
            Staged.SetNoFilesText(_noStagedChanges.Text);
            Message.SetEmptyMessage(_enterCommitMessageHint.Text);

            _commitKind = commitKind;
            _editedCommit = editedCommit;

            Unstaged.SelectedIndexChanged += UntrackedSelectionChanged;
            Staged.SelectedIndexChanged += TrackedSelectionChanged;

            Unstaged.DoubleClick += Unstaged_DoubleClick;
            Staged.DoubleClick += Staged_DoubleClick;

            Unstaged.Focus();

            SelectedDiff.AddContextMenuEntry(null, null);
            _StageSelectedLinesToolStripMenuItem = SelectedDiff.AddContextMenuEntry(_stageSelectedLines.Text, StageSelectedLinesToolStripMenuItemClick);
            _ResetSelectedLinesToolStripMenuItem = SelectedDiff.AddContextMenuEntry(_resetSelectedLines.Text, ResetSelectedLinesToolStripMenuItemClick);

            splitMain.SplitterDistance = Settings.CommitDialogSplitter;

            this.HotkeysEnabled = true;
            this.Hotkeys = HotkeySettingsManager.LoadHotkeys(HotkeySettingsName);

            SelectedDiff.ContextMenuOpening += SelectedDiff_ContextMenuOpening;

            Commit.Focus();
        }
Exemplo n.º 7
0
        private void PrepareCorrectionCommit(CommitKind commitKind)
        {
            if (Revisions.RowCount <= LastRow || LastRow < 0)
                return;

            using (var frm = new FormCommit(UICommands, commitKind, GetRevision(LastRow))) frm.ShowDialog(this);

            ForceRefreshRevisions();
            OnActionOnRepositoryPerformed();
        }
        public FormCommit(CommitKind commitKind, GitRevision editedCommit)
            : base(true)
        {
            _syncContext = SynchronizationContext.Current;

            InitializeComponent();

            FormCommitInialize();

            _commitKind = commitKind;
            _editedCommit = editedCommit;

            Unstaged.SelectedIndexChanged += UntrackedSelectionChanged;
            Staged.SelectedIndexChanged += TrackedSelectionChanged;

            Unstaged.DoubleClick += Unstaged_DoubleClick;
            Staged.DoubleClick += Staged_DoubleClick;

            SelectedDiff.AddContextMenuEntry(null, null);
            _StageSelectedLinesToolStripMenuItem = SelectedDiff.AddContextMenuEntry(_stageSelectedLines.Text, StageSelectedLinesToolStripMenuItemClick);
            _ResetSelectedLinesToolStripMenuItem = SelectedDiff.AddContextMenuEntry(_resetSelectedLines.Text, ResetSelectedLinesToolStripMenuItemClick);

            splitMain.SplitterDistance = Settings.CommitDialogSplitter;
            splitRight.SplitterDistance = Settings.CommitDialogRightSplitter;

            HotkeysEnabled = true;
            Hotkeys = HotkeySettingsManager.LoadHotkeys(HotkeySettingsName);

            SelectedDiff.ContextMenuOpening += SelectedDiff_ContextMenuOpening;
        }
Exemplo n.º 9
0
        public FormCommit(CommitKind commitKind, GitRevision editedCommit)
            : base(true)
        {
            _syncContext = SynchronizationContext.Current;

            _useFormCommitMessage = Settings.UseFormCommitMessage;

            InitializeComponent();

            Loading.Image = Properties.Resources.loadingpanel;

            splitRight.Panel2MinSize = 130;
            Translate();

            SolveMergeconflicts.Font = new Font(SystemFonts.MessageBoxFont, FontStyle.Bold);

            SelectedDiff.ExtraDiffArgumentsChanged += SelectedDiffExtraDiffArgumentsChanged;

            closeDialogAfterEachCommitToolStripMenuItem.Checked = Settings.CloseCommitDialogAfterCommit;
            closeDialogAfterAllFilesCommittedToolStripMenuItem.Checked = Settings.CloseCommitDialogAfterLastCommit;
            refreshDialogOnFormFocusToolStripMenuItem.Checked = Settings.RefreshCommitDialogOnFormFocus;

            Unstaged.SetNoFilesText(_noUnstagedChanges.Text);
            Staged.SetNoFilesText(_noStagedChanges.Text);

            Message.Enabled = _useFormCommitMessage;

            commitMessageToolStripMenuItem.Enabled = _useFormCommitMessage;
            commitTemplatesToolStripMenuItem.Enabled = _useFormCommitMessage;

            Message.WatermarkText = _useFormCommitMessage
                ? _enterCommitMessageHint.Text
                : _commitMessageDisabled.Text;

            _commitKind = commitKind;
            _editedCommit = editedCommit;

            Unstaged.SelectedIndexChanged += UntrackedSelectionChanged;
            Staged.SelectedIndexChanged += TrackedSelectionChanged;

            Unstaged.DoubleClick += Unstaged_DoubleClick;
            Staged.DoubleClick += Staged_DoubleClick;

            SelectedDiff.AddContextMenuEntry(null, null);
            _StageSelectedLinesToolStripMenuItem = SelectedDiff.AddContextMenuEntry(_stageSelectedLines.Text, StageSelectedLinesToolStripMenuItemClick);
            _ResetSelectedLinesToolStripMenuItem = SelectedDiff.AddContextMenuEntry(_resetSelectedLines.Text, ResetSelectedLinesToolStripMenuItemClick);

            splitMain.SplitterDistance = Settings.CommitDialogSplitter;
            splitRight.SplitterDistance = Settings.CommitDialogRightSplitter;

            HotkeysEnabled = true;
            Hotkeys = HotkeySettingsManager.LoadHotkeys(HotkeySettingsName);

            SelectedDiff.ContextMenuOpening += SelectedDiff_ContextMenuOpening;
        }