public void ParseGithubIssueForAllRemotesLink()
        {
            GitExtLinkDef linkDef = GetGithubIssuesLinkDef();

            linkDef.UseRemotesPattern  = string.Empty;
            linkDef.UseOnlyFirstRemote = false;
            GitRevision revision = new GitRevision(null, "");

            revision.Body = "Merge pull request #3657 from RussKie/tweak_FormRemotes_tooltips";
            IGitRemoteController remoteController = Substitute.For <IGitRemoteController>();

            remoteController.Remotes.Returns(GetDefaultRemotes());
            IEnumerable <GitExtLink> actualLinks   = linkDef.Parse(revision, remoteController);
            IEnumerable <GitExtLink> expectedLinks = new GitExtLink[]
            {
                new GitExtLink()
                {
                    Caption = "Issue 3657",
                    URI     = "https://github.com/jbialobr/gitextensions/issues/3657"
                },
                new GitExtLink()
                {
                    Caption = "Issue 3657",
                    URI     = "https://github.com/gitextensions/gitextensions/issues/3657"
                },
                new GitExtLink()
                {
                    Caption = "Issue 3657",
                    URI     = "https://github.com/russkie/gitextensions/issues/3657"
                }
            };

            actualLinks.Should().Equal(expectedLinks);
        }
Exemple #2
0
        private void application_Idle(object sender, EventArgs e)
        {
            // we need this event only once, so unwire
            Application.Idle -= application_Idle;

            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 lebel3 (Private key file), so use it as a guide
            var widestLabelMinSize = new Size(label3.Width, 0);

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

            if (Module == null)
            {
                return;
            }
            _gitRemoteController = new GitRemoteController(Module);
            // load the data for the very first time
            Initialize(PreselectRemoteOnLoad);
        }
Exemple #3
0
        public FormPush(GitUICommands aCommands)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

            if (!GitCommandHelpers.VersionInUse.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
            if (aCommands != null)
            {
                _gitRemoteController = new GitRemoteController(Module);
                Init();
            }
        }
        public void Setup()
        {
            _configFile = Substitute.For <IConfigFileSettings>();

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

            _controller = new GitRemoteController(_module);
        }
        public IEnumerable <Match> ParseRemotes(IGitRemoteController remoteController)
        {
            IList <Match> allMatches = new List <Match>();

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

                remoteController.LoadRemotes(loadDisabled: false);

                IEnumerable <GitRemote> matchingRemotes = GetMatchingRemotes(remoteController.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);
        }
        public void ParseLinkWithEmptyRemotePart()
        {
            GitExtLinkDef linkDef  = GitExtLinksParser.LoadFromXmlString(GetEmptyRemotePartXmlDef()).First();
            GitRevision   revision = new GitRevision(null, "");

            revision.Body = "Merge pull request #3657 from RussKie/tweak_FormRemotes_tooltips";
            IGitRemoteController remoteController = Substitute.For <IGitRemoteController>();

            remoteController.Remotes.Returns(GetDefaultRemotes());
            IEnumerable <GitExtLink> actualLinks   = linkDef.Parse(revision, remoteController);
            IEnumerable <GitExtLink> expectedLinks = new GitExtLink[]
            {
                new GitExtLink()
                {
                    Caption = "Issue 3657",
                    URI     = "https://github.com/gitextensions/gitextensions/issues/3657"
                }
            };

            actualLinks.Should().Equal(expectedLinks);
        }
Exemple #7
0
        public FormPull(GitUICommands aCommands, string defaultRemoteBranch, string defaultRemote)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

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

            if (aCommands != null)
            {
                _gitRemoteController = new GitRemoteController(Module);
                Init(defaultRemote);
            }

            Merge.Checked       = AppSettings.FormPullAction == AppSettings.PullAction.Merge;
            Rebase.Checked      = AppSettings.FormPullAction == AppSettings.PullAction.Rebase;
            Fetch.Checked       = AppSettings.FormPullAction == AppSettings.PullAction.Fetch;
            localBranch.Enabled = Fetch.Checked;
            AutoStash.Checked   = AppSettings.AutoStash;
            Prune.Enabled       = AppSettings.FormPullAction == AppSettings.PullAction.Merge || AppSettings.FormPullAction == AppSettings.PullAction.Fetch;

            ErrorOccurred = false;

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

            // If this repo is shallow, show an option to Unshallow
            if (aCommands != null)
            {
                // 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(aCommands.Module.ResolveGitInternalPath("shallow"));
                if (isRepoShallow)
                {
                    Unshallow.Visible = true;
                }
            }
        }
Exemple #8
0
        public void Setup()
        {
            _module = Substitute.For <IGitModule>();

            _controller = new GitRemoteController(_module);
        }
        public void Setup()
        {
            _module = Substitute.For<IGitModule>();

            _controller = new GitRemoteController(_module);
        }
        public IEnumerable <GitExtLink> Parse(GitRevision revision, IGitRemoteController remoteController)
        {
            IEnumerable <Match> remoteMatches = ParseRemotes(remoteController);

            return(remoteMatches.Select(remoteMatch => ParseRevision(remoteMatch, revision)).Unwrap());
        }
Exemple #11
0
        public FormPull(GitUICommands aCommands, string defaultRemoteBranch, string defaultRemote)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

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

            if (aCommands != null)
            {
                _gitRemoteController = new GitRemoteController(Module);
                Init(defaultRemote);
            }

            Merge.Checked = AppSettings.FormPullAction == AppSettings.PullAction.Merge;
            Rebase.Checked = AppSettings.FormPullAction == AppSettings.PullAction.Rebase;
            Fetch.Checked = AppSettings.FormPullAction == AppSettings.PullAction.Fetch;
            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
            if (aCommands != null)
            {
                // 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(Path.Combine(aCommands.Module.GetGitDirectory(), "shallow"));
                if (isRepoShallow)
                    Unshallow.Visible = true;
            }
        }
Exemple #12
0
        public FormPush(GitUICommands aCommands)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

            if (!GitCommandHelpers.VersionInUse.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
            if (aCommands != null)
            {
                _gitRemoteController = new GitRemoteController(Module);
                Init();
            }
        }
Exemple #13
0
        private void application_Idle(object sender, EventArgs e)
        {
            // we need this event only once, so unwire
            Application.Idle -= application_Idle;

            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 lebel3 (Private key file), so use it as a guide
            var widestLabelMinSize = new Size(label3.Width, 0);
            label1.MinimumSize = widestLabelMinSize;        // Name
            label2.MinimumSize = widestLabelMinSize;        // Url
            labelPushUrl.MinimumSize = widestLabelMinSize;  // Push URL

            if (Module == null)
            {
                return;
            }
            _gitRemoteController = new GitRemoteController(Module);
            // load the data for the very first time
            Initialize(PreselectRemoteOnLoad);
        }