Example #1
0
        public CommitInfo()
        {
            InitializeComponent();
            Translate();
            GitUICommandsSourceSet += (a, uiCommandsSource) =>
            {
                _sortedRefs = null;
            };

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

            var labelFormatter = new TabbedHeaderLabelFormatter();
            var headerRenderer = new TabbedHeaderRenderStyleProvider();

            _commitDataHeaderRenderer         = new CommitDataHeaderRenderer(labelFormatter, _dateFormatter, headerRenderer, _linkFactory);
            _commitDataBodyRenderer           = new CommitDataBodyRenderer(() => Module, _linkFactory);
            _externalLinksLoader              = new ExternalLinksLoader();
            _effectiveLinkDefinitionsProvider = new ConfiguredLinkDefinitionsProvider(_externalLinksLoader);
            _gitRemoteManager               = new GitRemoteManager(() => Module);
            _externalLinkRevisionParser     = new ExternalLinkRevisionParser(_gitRemoteManager);
            _gitRevisionExternalLinksParser = new GitRevisionExternalLinksParser(_effectiveLinkDefinitionsProvider, _externalLinkRevisionParser);
            _gitDescribeProvider            = new GitDescribeProvider(() => Module);

            RevisionInfo.Font = AppSettings.Font;
            using (Graphics g = CreateGraphics())
            {
                _RevisionHeader.Font = _commitDataHeaderRenderer.GetFont(g);
            }

            _RevisionHeader.SelectionTabs = _commitDataHeaderRenderer.GetTabStops().ToArray();

            Hotkeys = HotkeySettingsManager.LoadHotkeys(FormBrowse.HotkeySettingsName);
            addNoteToolStripMenuItem.ShortcutKeyDisplayString = GetShortcutKeys((int)FormBrowse.Commands.AddNotes).ToShortcutKeyDisplayString();
        }
 public RemoteRepoNode(Tree tree, string fullPath, IGitRemoteManager gitRemoteManager, Remote remote, bool isEnabled)
     : base(tree, fullPath)
 {
     _remote           = remote;
     Enabled           = isEnabled;
     _gitRemoteManager = gitRemoteManager;
 }
Example #3
0
        public FormPush(GitUICommands commands)
            : base(commands)
        {
            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 (commands != null)
            {
                _remoteManager = new GitRemoteManager(() => Module);
                Init();
            }
        }
Example #4
0
        protected override void Init(ISettingsPageHost pageHost)
        {
            base.Init(pageHost);

            _gitRemoteManager            = new GitRemoteManager(() => 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;
                BuildServerType.Enabled = true;

                BuildServerType.DataSource = new[] { _noneItem.Text }.Concat(buildServerTypes).ToArray();
                return(BuildServerType.DataSource);
            });
        }
Example #5
0
        public CommitInfo()
        {
            InitializeComponent();
            InitializeComplete();

            UICommandsSourceSet += delegate { this.InvokeAsync(() => ReloadCommitInfo()).FileAndForget(); };

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

            _commitDataBodyRenderer           = new CommitDataBodyRenderer(() => Module, _linkFactory);
            _externalLinksStorage             = new ExternalLinksStorage();
            _effectiveLinkDefinitionsProvider = new ConfiguredLinkDefinitionsProvider(_externalLinksStorage);
            _gitRemoteManager               = new GitRemoteManager(() => Module);
            _externalLinkRevisionParser     = new ExternalLinkRevisionParser(_gitRemoteManager);
            _gitRevisionExternalLinksParser = new GitRevisionExternalLinksParser(_effectiveLinkDefinitionsProvider, _externalLinkRevisionParser);
            _gitDescribeProvider            = new GitDescribeProvider(() => Module);

            RevisionInfo.Font = AppSettings.Font;
            var color = SystemColors.Window.MakeColorDarker(0.04);

            pnlCommitMessage.BackColor  = color;
            rtbxCommitMessage.BackColor = color;

            Hotkeys = HotkeySettingsManager.LoadHotkeys(FormBrowse.HotkeySettingsName);
            addNoteToolStripMenuItem.ShortcutKeyDisplayString = GetShortcutKeys((int)FormBrowse.Command.AddNotes).ToShortcutKeyDisplayString();
        }
Example #6
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       = label1.MaximumSize = widestLabelMinSize;       // Name
            label2.MinimumSize       = label2.MaximumSize = widestLabelMinSize;       // Url
            labelPushUrl.MinimumSize = labelPushUrl.MaximumSize = widestLabelMinSize; // Push URL

            if (Module == null)
            {
                return;
            }

            _remoteManager = new GitRemoteManager(() => Module);

            // load the data for the very first time
            Initialize(PreselectRemoteOnLoad);
        }
Example #7
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

            _remoteManager = new GitRemoteManager(() => Module);

            // load the data for the very first time
            Initialize(PreselectRemoteOnLoad, PreselectLocalOnLoad);
        }
        public void Setup()
        {
            _linkDef = Parse(GetGithubIssuesXmlDef()).First();

            _revision = new GitRevision(null, "");

            _remoteManager = Substitute.For <IGitRemoteManager>();
            _remoteManager.LoadRemotes(false).Returns(GetDefaultRemotes());
        }
        public void Setup()
        {
            _configFile = Substitute.For <IConfigFileSettings>();

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

            _controller = new GitRemoteManager(() => _module);
        }
        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);
        }
        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 GitRemoteManager(() => _referenceRepository.Module);
        }
Example #12
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);
        }
Example #13
0
        public CommitInfo()
        {
            InitializeComponent();
            InitializeComplete();

            UICommandsSourceSet += delegate
            {
                this.InvokeAsync(() =>
                {
                    UICommandsSource.UICommandsChanged += UICommandsSource_UICommandsChanged;
                    RefreshSortedRefs();
                    ReloadCommitInfo();
                }).FileAndForget();
            };

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

            _commitDataBodyRenderer           = new CommitDataBodyRenderer(() => Module, _linkFactory);
            _externalLinksStorage             = new ExternalLinksStorage();
            _effectiveLinkDefinitionsProvider = new ConfiguredLinkDefinitionsProvider(_externalLinksStorage);
            _gitRemoteManager               = new GitRemoteManager(() => Module);
            _externalLinkRevisionParser     = new ExternalLinkRevisionParser(_gitRemoteManager);
            _gitRevisionExternalLinksParser = new GitRevisionExternalLinksParser(_effectiveLinkDefinitionsProvider, _externalLinkRevisionParser);
            _gitDescribeProvider            = new GitDescribeProvider(() => Module);

            var color = SystemColors.Window.MakeColorDarker(0.04);

            pnlCommitMessage.BackColor  = color;
            rtbxCommitMessage.BackColor = color;
            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 #14
0
        public FormPull(GitUICommands commands, string defaultRemoteBranch, string defaultRemote)
            : base(commands)
        {
            InitializeComponent();
            InitializeComplete();

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

            _remoteManager = new GitRemoteManager(() => Module);
            _branch        = Module.GetSelectedBranch();
            BindRemotesDropDown(defaultRemote);

            if (AppSettings.DefaultPullAction == AppSettings.PullAction.Merge)
            {
                Merge.Checked = true;
            }
            else if (AppSettings.DefaultPullAction == AppSettings.PullAction.Rebase)
            {
                Rebase.Checked = true;
            }
            else
            {
                // Set to fetch for Fetch, FetchAll, FetchPruneAll and None
                Fetch.Checked = true;
            }

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

            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);
        }
Example #15
0
        public FormPull(GitUICommands aCommands, string defaultRemoteBranch, string defaultRemote)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

            if (aCommands == null)
            {
                return;
            }

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

            _remoteManager = new GitRemoteManager(() => 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
            // 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;
            }

            _fullPathResolver = new FullPathResolver(() => Module.WorkingDir);
        }
Example #16
0
        internal IEnumerable <ExternalLink> Parse(GitRevision revision, IGitRemoteManager remoteManager)
        {
            IEnumerable <Match> remoteMatches = ParseRemotes(remoteManager);

            return(remoteMatches.SelectMany(remoteMatch => ParseRevision(remoteMatch, revision)));
        }
Example #17
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);
                }
            }
        }
Example #18
0
        public FormPull(GitUICommands commands, string defaultRemoteBranch, string defaultRemote, AppSettings.PullAction pullAction)
            : base(commands)
        {
            InitializeComponent();
            InitializeComplete();

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

            _remoteManager = new GitRemoteManager(() => Module);
            _branch        = Module.GetSelectedBranch();
            BindRemotesDropDown(defaultRemote);

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

            switch (pullAction)
            {
            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);
        }
Example #19
0
 public ExternalLinkRevisionParser(IGitRemoteManager gitRemoteManager)
 {
     _gitRemoteManager = gitRemoteManager;
 }