protected override void Init(ISettingsPageHost pageHost)
        {
            base.Init(pageHost);

            _remotesManager = new ConfigFileRemoteSettingsManager(() => Module);
            _populateBuildServerTypeTask = ThreadHelper.JoinableTaskFactory.RunAsync(
                async() =>
            {
                await TaskScheduler.Default.SwitchTo(alwaysYield: true);

                var exports          = ManagedExtensibility.GetExports <IBuildServerAdapter, IBuildServerTypeMetadata>();
                var buildServerTypes = exports.Select(export =>
                {
                    var canBeLoaded = export.Metadata.CanBeLoaded;
                    return(export.Metadata.BuildServerType.Combine(" - ", canBeLoaded));
                }).ToArray();

                await this.SwitchToMainThreadAsync();

                checkBoxEnableBuildServerIntegration.Enabled = true;
                checkBoxShowBuildResultPage.Enabled          = true;
                BuildServerType.Enabled = true;

                BuildServerType.DataSource = new[] { _noneItem.Text }.Concat(buildServerTypes).ToArray();
                return(BuildServerType.DataSource);
            });
        }
 public RemoteRepoNode(Tree tree, string fullPath, IConfigFileRemoteSettingsManager remotesManager, Remote remote, bool isEnabled)
     : base(tree, fullPath, visible: true)
 {
     _remote         = remote;
     Enabled         = isEnabled;
     _remotesManager = remotesManager;
 }
Example #3
0
        private void application_Idle(object sender, EventArgs e)
        {
            // we need this event only once, so unwire
            Application.Idle -= application_Idle;

            // make sure only single load option is given
            if (PreselectRemoteOnLoad != null && PreselectLocalOnLoad != null)
            {
                throw new ArgumentException($"Only one option allowed:" +
                                            $" Either {nameof(PreselectRemoteOnLoad)} or {nameof(PreselectLocalOnLoad)}");
            }

            pnlMgtPuttySsh.Visible = GitCommandHelpers.Plink();

            // if Putty SSH isn't enabled, reduce the minimum height of the form
            MinimumSize = new Size(MinimumSize.Width, pnlMgtPuttySsh.Visible ? MinimumSize.Height : MinimumSize.Height - pnlMgtPuttySsh.Height);

            // adjust width of the labels if required
            // this may be necessary if the translated labels require more space than English versions
            // the longest label is likely to be label3 (Private key file), so use it as a guide
            var widestLabelMinSize = new Size(label3.Width, 0);

            label1.MinimumSize       = label1.MaximumSize = widestLabelMinSize;       // Name
            label2.MinimumSize       = label2.MaximumSize = widestLabelMinSize;       // Url
            labelPushUrl.MinimumSize = labelPushUrl.MaximumSize = widestLabelMinSize; // Push URL

            _remotesManager = new ConfigFileRemoteSettingsManager(() => Module);

            // load the data for the very first time
            Initialize(PreselectRemoteOnLoad, PreselectLocalOnLoad);
        }
        public void Setup()
        {
            _configFile = Substitute.For <IConfigFileSettings>();

            _module = Substitute.For <IVsrModule>();
            _module.LocalConfigFile.Returns(_configFile);

            _remotesManager = new ConfigFileRemoteSettingsManager(() => _module);
        }
        public void Setup()
        {
            _linkDef = Parse(GetGitHubIssuesXmlDef()).First();

            _revision = new GitRevision(ObjectId.Random());

            _remotesManager = Substitute.For <IConfigFileRemoteSettingsManager>();
            _remotesManager.LoadRemotes(false).Returns(GetDefaultRemotes());

            _parser = new ExternalLinkRevisionParser(_remotesManager);
        }
Example #6
0
        public CommitInfo()
        {
            InitializeComponent();
            InitializeComplete();

            UICommandsSourceSet += delegate
            {
                this.InvokeAsync(() =>
                {
                    UICommandsSource.UICommandsChanged += delegate { RefreshSortedTags(); };

                    // call this event handler also now (necessary for "Contained in branches/tags")
                    RefreshSortedTags();
                }).FileAndForget();
            };

            _commitDataManager = new CommitDataManager(() => Module);

            _commitDataBodyRenderer           = new CommitDataBodyRenderer(() => Module, _linkFactory);
            _externalLinksStorage             = new ExternalLinksStorage();
            _effectiveLinkDefinitionsProvider = new ConfiguredLinkDefinitionsProvider(_externalLinksStorage);
            _remotesManager                 = new ConfigFileRemoteSettingsManager(() => Module);
            _externalLinkRevisionParser     = new ExternalLinkRevisionParser(_remotesManager);
            _gitRevisionExternalLinksParser = new GitRevisionExternalLinksParser(_effectiveLinkDefinitionsProvider, _externalLinkRevisionParser);
            _gitDescribeProvider            = new GitDescribeProvider(() => Module);
            _refsFormatter = new RefsFormatter(_linkFactory);

            var messageBackground = KnownColor.Window.MakeBackgroundDarkerBy(0.04);

            pnlCommitMessage.BackColor  = messageBackground;
            rtbxCommitMessage.BackColor = messageBackground;

            rtbxCommitMessage.Font = AppSettings.CommitFont;
            RevisionInfo.Font      = AppSettings.Font;

            Hotkeys = HotkeySettingsManager.LoadHotkeys(FormBrowse.HotkeySettingsName);
            addNoteToolStripMenuItem.ShortcutKeyDisplayString = GetShortcutKeys((int)FormBrowse.Command.AddNotes).ToShortcutKeyDisplayString();

            _commitMessageResizedSubscription = subscribeToContentsResized(rtbxCommitMessage, CommitMessage_ContentsResized);
            _revisionInfoResizedSubscription  = subscribeToContentsResized(RevisionInfo, RevisionInfo_ContentsResized);

            IDisposable subscribeToContentsResized(RichTextBox richTextBox, Action <ContentsResizedEventArgs> handler) =>
            Observable
            .FromEventPattern <ContentsResizedEventHandler, ContentsResizedEventArgs>(
                h => richTextBox.ContentsResized += h,
                h => richTextBox.ContentsResized -= h)
            .Throttle(TimeSpan.FromMilliseconds(100))
            .ObserveOn(MainThreadScheduler.Instance)
            .Subscribe(_ => handler(_.EventArgs));

            commitInfoHeader.SetContextMenuStrip(commitInfoContextMenuStrip);
        }
Example #7
0
        public void SetUp()
        {
            // we will be modifying .git/config and need to completely reset each time
            _referenceRepository = new ReferenceRepository();

            foreach (var name in RemoteNames)
            {
                _referenceRepository.Module.AddRemote(name, $"http://localhost/remotes/{name}.git");
            }

            _commands       = new GitUICommands(_referenceRepository.Module);
            _remotesManager = new ConfigFileRemoteSettingsManager(() => _referenceRepository.Module);
        }
Example #8
0
        public void SetUp()
        {
            // we will be modifying .git/config and need to completely reset each time
            _referenceRepository = new ReferenceRepository();

            foreach (var name in RemoteNames)
            {
                _referenceRepository.Module.AddRemote(name, $"http://localhost/remotes/{name}.git");
            }

            _commands       = new GitUICommands(_referenceRepository.Module);
            _remotesManager = new ConfigFileRemoteSettingsManager(() => _referenceRepository.Module);

            var composition = TestComposition.Empty
                              .AddParts(typeof(MockWindowsJumpListManager))
                              .AddParts(typeof(MockRepositoryDescriptionProvider))
                              .AddParts(typeof(MockAppTitleGenerator));
            ExportProvider mefExportProvider = composition.ExportProviderFactory.CreateExportProvider();

            ManagedExtensibility.SetTestExportProvider(mefExportProvider);
        }
Example #9
0
        public FormPush([NotNull] GitUICommands commands)
            : base(commands)
        {
            InitializeComponent();

            NewColumn.Width    = DpiUtil.Scale(97);
            PushColumn.Width   = DpiUtil.Scale(36);
            ForceColumn.Width  = DpiUtil.Scale(101);
            DeleteColumn.Width = DpiUtil.Scale(108);

            InitializeComplete();

            if (!GitVersion.Current.SupportPushForceWithLease)
            {
                ckForceWithLease.Visible = false;
                ForcePushTags.DataBindings.Add("Checked", ForcePushBranches, "Checked",
                                               formattingEnabled: false, updateMode: DataSourceUpdateMode.OnPropertyChanged);
            }
            else
            {
                ForcePushTags.DataBindings.Add("Checked", ckForceWithLease, "Checked",
                                               formattingEnabled: false, updateMode: DataSourceUpdateMode.OnPropertyChanged);
                toolTip1.SetToolTip(ckForceWithLease, _forceWithLeaseTooltips.Text);
            }

            // can't be set in OnLoad, because after PushAndShowDialogWhenFailed()
            // they are reset to false
            _remotesManager = new ConfigFileRemoteSettingsManager(() => Module);
            Init();

            void Init()
            {
                _gitRefs = Module.GetRefs();
                if (GitVersion.Current.SupportPushWithRecursiveSubmodulesCheck)
                {
                    RecursiveSubmodules.Enabled       = true;
                    RecursiveSubmodules.SelectedIndex = AppSettings.RecursiveSubmodules;
                    if (!GitVersion.Current.SupportPushWithRecursiveSubmodulesOnDemand)
                    {
                        RecursiveSubmodules.Items.RemoveAt(2);
                    }
                }
                else
                {
                    RecursiveSubmodules.Enabled       = false;
                    RecursiveSubmodules.SelectedIndex = 0;
                }

                _currentBranchName = Module.GetSelectedBranch();

                // refresh registered git remotes
                UserGitRemotes = _remotesManager.LoadRemotes(false).ToList();
                BindRemotesDropDown(null);

                UpdateBranchDropDown();
                UpdateRemoteBranchDropDown();

                Push.Focus();

                if (AppSettings.AlwaysShowAdvOpt)
                {
                    ShowOptions_LinkClicked(null, null);
                }
            }
        }
Example #10
0
        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 (string.IsNullOrEmpty(defaultRemote))
                {
                    _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);
        }
 public ExternalLinkRevisionParser(IConfigFileRemoteSettingsManager remotesManager)
 {
     _remotesManager = remotesManager;
 }