Exemple #1
0
        private void Init()
        {
            _gitRefs = Module.GetRefs();
            if (GitCommandHelpers.VersionInUse.SupportPushWithRecursiveSubmodulesCheck)
            {
                RecursiveSubmodules.Enabled       = true;
                RecursiveSubmodules.SelectedIndex = AppSettings.RecursiveSubmodules;
                if (!GitCommandHelpers.VersionInUse.SupportPushWithRecursiveSubmodulesOnDemand)
                {
                    RecursiveSubmodules.Items.RemoveAt(2);
                }
            }
            else
            {
                RecursiveSubmodules.Enabled       = false;
                RecursiveSubmodules.SelectedIndex = 0;
            }

            _currentBranchName = Module.GetSelectedBranch();

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

            UpdateBranchDropDown();
            UpdateRemoteBranchDropDown();

            Push.Focus();

            if (AppSettings.AlwaysShowAdvOpt)
            {
                ShowOptions_LinkClicked(null, null);
            }
        }
        private void Initialize(string preselectRemote = null)
        {
            // refresh registered git remotes
            UserGitRemotes = _remoteManager.LoadRemotes(true).ToList();

            InitialiseTabRemotes(preselectRemote);
            InitialiseTabBehaviors();
        }
        public void Setup()
        {
            _linkDef = Parse(GetGithubIssuesXmlDef()).First();

            _revision = new GitRevision(null, "");

            _remoteManager = Substitute.For <IGitRemoteManager>();
            _remoteManager.LoadRemotes(false).Returns(GetDefaultRemotes());
        }
Exemple #4
0
        private void OpenRemotesDialogAndRefreshList(string selectedRemoteName)
        {
            if (!UICommands.StartRemotesDialog(this, selectedRemoteName))
            {
                return;
            }

            _remoteManager.LoadRemotes(false);
            BindRemotesDropDown(selectedRemoteName);
        }
        public void Setup()
        {
            _linkDef = Parse(GetGitHubIssuesXmlDef()).First();

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

            _remoteManager = Substitute.For <IGitRemoteManager>();
            _remoteManager.LoadRemotes(false).Returns(GetDefaultRemotes());

            _parser = new ExternalLinkRevisionParser(_remoteManager);
        }
Exemple #6
0
        private void Initialize(string preselectRemote = null, string preselectLocal = null)
        {
            // refresh registered git remotes
            UserGitRemotes = _remoteManager.LoadRemotes(true).ToList();

            InitialiseTabRemotes(preselectRemote);

            if (preselectLocal != null && UserGitRemotes.Count != 0)
            {
                ActivateTabDefaultPullBehaviors();
            }

            InitialiseTabDefaultPullBehaviors(preselectLocal);
        }
Exemple #7
0
        private IEnumerable <Match> ParseRemotes(ExternalLinkDefinition definition)
        {
            IList <Match> allMatches = new List <Match>();

            if (definition.RemoteSearchPattern.IsNullOrWhiteSpace() || definition.RemoteSearchPatternRegex.Value == null)
            {
                allMatches.Add(null);
                return(allMatches);
            }

            IList <string> remoteUrls = new List <string>();

            var remotes         = _gitRemoteManager.LoadRemotes(false);
            var matchingRemotes = GetMatchingRemotes(definition, remotes);

            foreach (var remote in matchingRemotes)
            {
                if (definition.RemoteSearchInParts.Contains(ExternalLinkDefinition.RemotePart.URL))
                {
                    if (remote.Url.IsNotNullOrWhitespace())
                    {
                        remoteUrls.Add(remote.Url.ToLower());
                    }
                }

                if (definition.RemoteSearchInParts.Contains(ExternalLinkDefinition.RemotePart.PushURL))
                {
                    if (remote.PushUrl.IsNotNullOrWhitespace())
                    {
                        remoteUrls.Add(remote.PushUrl.ToLower());
                    }
                }
            }

            foreach (var url in remoteUrls.Distinct())
            {
                var matches = definition.RemoteSearchPatternRegex.Value.Matches(url);
                for (var i = 0; i < matches.Count; i++)
                {
                    var match = matches[i];
                    if (match.Success)
                    {
                        allMatches.Add(match);
                    }
                }
            }

            return(allMatches);
        }
Exemple #8
0
        private IEnumerable <Match> ParseRemotes(IGitRemoteManager remoteManager)
        {
            IList <Match> allMatches = new List <Match>();

            if (RemoteSearchPattern.IsNullOrWhiteSpace() || RemoteSearchPatternRegex.Value == null)
            {
                allMatches.Add(null);
            }
            else
            {
                IList <string> remoteUrls = new List <string>();

                var remotes = remoteManager.LoadRemotes(false);
                IEnumerable <GitRemote> matchingRemotes = GetMatchingRemotes(remotes);

                foreach (GitRemote remote in matchingRemotes)
                {
                    if (RemoteSearchInParts.Contains(RemotePart.URL))
                    {
                        if (remote.Url.IsNotNullOrWhitespace())
                        {
                            remoteUrls.Add(remote.Url.ToLower());
                        }
                    }
                    if (RemoteSearchInParts.Contains(RemotePart.PushURL))
                    {
                        if (remote.PushUrl.IsNotNullOrWhitespace())
                        {
                            remoteUrls.Add(remote.PushUrl.ToLower());
                        }
                    }
                }

                foreach (string url in remoteUrls.Distinct())
                {
                    MatchCollection matches = RemoteSearchPatternRegex.Value.Matches(url);
                    for (var i = 0; i < matches.Count; i++)
                    {
                        Match match = matches[i];
                        if (match.Success)
                        {
                            allMatches.Add(match);
                        }
                    }
                }
            }

            return(allMatches);
        }
Exemple #9
0
        private IBuildServerSettingsUserControl CreateBuildServerSettingsUserControl()
        {
            if (BuildServerType.SelectedIndex == 0 || string.IsNullOrEmpty(Module.WorkingDir))
            {
                return(null);
            }

            var defaultProjectName = Module.WorkingDir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries).Last();

            var exports        = ManagedExtensibility.GetExports <IBuildServerSettingsUserControl, IBuildServerTypeMetadata>();
            var selectedExport = exports.SingleOrDefault(export => export.Metadata.BuildServerType == GetSelectedBuildServerType());

            if (selectedExport != null)
            {
                var buildServerSettingsUserControl = selectedExport.Value;
                var remoteUrls = _gitRemoteManager.LoadRemotes(false).Select(r => string.IsNullOrEmpty(r.PushUrl) ? r.Url : r.PushUrl);

                buildServerSettingsUserControl.Initialize(defaultProjectName, remoteUrls);
                return(buildServerSettingsUserControl);
            }

            return(null);
        }
Exemple #10
0
        private void BindRemotesDropDown(string selectedRemoteName)
        {
            // refresh registered git remotes
            var remotes = _remoteManager.LoadRemotes(false);

            _NO_TRANSLATE_Remotes.Sorted     = false;
            _NO_TRANSLATE_Remotes.DataSource = new[] { new GitRemote {
                                                           Name = AllRemotes
                                                       } }.Union(remotes).ToList();
            _NO_TRANSLATE_Remotes.DisplayMember = nameof(GitRemote.Name);
            _NO_TRANSLATE_Remotes.SelectedIndex = -1;
            _NO_TRANSLATE_Remotes.ResizeDropDownWidth(AppSettings.BranchDropDownMinWidth, AppSettings.BranchDropDownMaxWidth);

            if (selectedRemoteName.IsNullOrEmpty())
            {
                selectedRemoteName = Module.GetSetting(string.Format(SettingKeyString.BranchRemote, _branch));
            }

            var currentBranchRemote = remotes.FirstOrDefault(x => x.Name.Equals(selectedRemoteName, StringComparison.OrdinalIgnoreCase));

            if (currentBranchRemote != null)
            {
                _NO_TRANSLATE_Remotes.SelectedItem = currentBranchRemote;
            }
            else if (remotes.Any())
            {
                // we couldn't find the default assigned remote for the selected branch
                // it is usually gets mapped via FormRemotes -> "default pull behavior" tab
                // so pick the default user remote
                _NO_TRANSLATE_Remotes.SelectedIndex = 1;
            }
            else
            {
                _NO_TRANSLATE_Remotes.SelectedIndex = 0;
            }
        }
Exemple #11
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
            _remoteManager = new GitRemoteManager(() => 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 = _remoteManager.LoadRemotes(false).ToList();
                BindRemotesDropDown(null);

                UpdateBranchDropDown();
                UpdateRemoteBranchDropDown();

                Push.Focus();

                if (AppSettings.AlwaysShowAdvOpt)
                {
                    ShowOptions_LinkClicked(null, null);
                }
            }
        }
        public void LoadRemotes_should_not_throw_if_module_is_null()
        {
            _module = null;

            ((Action)(() => _controller.LoadRemotes(true))).Should().NotThrow();
        }