コード例 #1
0
ファイル: FormPull.cs プロジェクト: zouxuewei/gitextensions
        public FormPull(GitUICommands commands, string defaultRemoteBranch, string defaultRemote, AppSettings.PullAction pullAction)
            : base(commands)
        {
            InitializeComponent();
            InitializeComplete();

            helpImageDisplayUserControl1.Visible = !AppSettings.DontShowHelpImages;
            helpImageDisplayUserControl1.IsOnHoverShowImage2NoticeText = _hoverShowImageLabelText.Text;

            _remotesManager = new ConfigFileRemoteSettingsManager(() => Module);
            _branch         = Module.GetSelectedBranch();
            BindRemotesDropDown(defaultRemote);

            if (pullAction == AppSettings.PullAction.None)
            {
                pullAction = AppSettings.DefaultPullAction;
            }

            switch (pullAction)
            {
            case AppSettings.PullAction.None:
            case AppSettings.PullAction.Merge:
                Merge.Checked = true;
                Prune.Enabled = true;
                break;

            case AppSettings.PullAction.Rebase:
                Rebase.Checked = true;
                break;

            case AppSettings.PullAction.Fetch:
                Fetch.Checked = true;
                Prune.Enabled = true;
                break;

            case AppSettings.PullAction.FetchAll:
                Fetch.Checked = true;
                _NO_TRANSLATE_Remotes.Text = AllRemotes;
                break;

            case AppSettings.PullAction.FetchPruneAll:
                Fetch.Checked = true;
                Prune.Checked = true;
                if (defaultRemote.IsNullOrEmpty())
                {
                    _NO_TRANSLATE_Remotes.Text = AllRemotes;
                }
                else
                {
                    _NO_TRANSLATE_Remotes.Text = defaultRemote;
                }

                break;

            case AppSettings.PullAction.Default:
                Debug.Assert(false, "pullAction is not a valid action");
                break;
            }

            localBranch.Enabled = Fetch.Checked;
            AutoStash.Checked   = AppSettings.AutoStash;

            ErrorOccurred = false;

            if (!string.IsNullOrEmpty(defaultRemoteBranch))
            {
                Branches.Text = defaultRemoteBranch;
            }

            // If this repo is shallow, show an option to Unshallow
            // Detect by presence of the shallow file, not 100% sure it's the best way, but it's created upon shallow cloning and removed upon unshallowing
            bool isRepoShallow = File.Exists(commands.Module.ResolveGitInternalPath("shallow"));

            if (isRepoShallow)
            {
                Unshallow.Visible = true;
            }

            _fullPathResolver = new FullPathResolver(() => Module.WorkingDir);
        }
コード例 #2
0
        public DialogResult PullAndShowDialogWhenFailed(IWin32Window owner, string remote, AppSettings.PullAction pullAction)
        {
            // Special case for "Fetch and prune" and "Fetch and prune all" to make sure user confirms the action.
            if (pullAction == AppSettings.PullAction.FetchPruneAll)
            {
                string messageBoxTitle = null;
                if (string.IsNullOrEmpty(remote))
                {
                    messageBoxTitle = string.Format(_pruneFromCaption.Text, AllRemotes);
                }
                else
                {
                    messageBoxTitle = string.Format(_pruneFromCaption.Text, remote);
                }

                bool isActionConfirmed = AppSettings.DontConfirmFetchAndPruneAll ||
                                         MessageBox.Show(
                    owner,
                    _pullFetchPruneAllConfirmation.Text,
                    messageBoxTitle,
                    MessageBoxButtons.YesNo) == DialogResult.Yes;

                if (!isActionConfirmed)
                {
                    return(DialogResult.Cancel);
                }
            }

            DialogResult result = PullChanges(owner);

            if (result == DialogResult.No)
            {
                result = ShowDialog(owner);
            }
            else
            {
                Close();
            }

            return(result);
        }
コード例 #3
0
 private void RunFormTest(Action <FormPull> testDriver, string remoteBranch, string remote, AppSettings.PullAction pullAction)
 {
     RunFormTest(
         form =>
     {
         testDriver(form);
         return(Task.CompletedTask);
     },
         remoteBranch, remote, pullAction);
 }
コード例 #4
0
 private void RunFormTest(Func <FormPull, Task> testDriverAsync, string remoteBranch, string remote, AppSettings.PullAction pullAction)
 {
     UITest.RunForm(
         () =>
     {
         // False because we haven't performed any actions
         Assert.False(_commands.StartPullDialog(owner: null, remoteBranch: remoteBranch, remote: remote, pullAction: pullAction));
     },
         testDriverAsync);
 }
コード例 #5
0
        public void Should_remember_user_choice_upon_pull(bool mergeChecked, bool rebaseChecked, bool fetchChecked, AppSettings.PullAction expectedFormPullAction)
        {
            RunFormTest(
                form =>
            {
                var accessor = form.GetTestAccessor();

                accessor.Merge.Checked  = mergeChecked;
                accessor.Rebase.Checked = rebaseChecked;
                accessor.Fetch.Checked  = fetchChecked;

                accessor.UpdateSettingsDuringPull();

                AppSettings.FormPullAction.Should().Be(expectedFormPullAction);
            },
                null, null,
                //// select an action different from None/fetch
                AppSettings.PullAction.Merge);
        }