private void RemotesComboboxControl_Load(object sender, EventArgs e)
        {
            if (Site != null && Site.DesignMode)
            {
                return;
            }

            var remoteManager = new GitRemoteManager(() => Module);

            comboBoxRemotes.DataSource = remoteManager.LoadRemotes(false).Select(x => x.Name).ToList();
        }
Пример #2
0
            public void ToggleRemoteState_should_not_fail_if_deactivate_repeatedly()
            {
                using (var helper = new GitModuleTestHelper())
                {
                    var manager = new GitRemoteManager(() => helper.Module);

                    const string remoteName = "active";
                    helper.Module.AddRemote(remoteName, "http://localhost/remote/repo.git");
                    manager.ToggleRemoteState(remoteName, true);

                    helper.Module.AddRemote(remoteName, "http://localhost/remote/repo.git");
                    manager.ToggleRemoteState(remoteName, true);
                }
            }
            private async Task <Nodes> LoadNodesAsync(CancellationToken token)
            {
                await TaskScheduler.Default;

                token.ThrowIfCancellationRequested();
                var nodes       = new Nodes(this);
                var pathToNodes = new Dictionary <string, BaseBranchNode>();

                var branches = Module.GetRefs(tags: true, branches: true, noLocks: true)
                               .Where(branch => branch.IsRemote && !branch.IsTag)
                               .OrderBy(branch => branch.Name)
                               .Select(branch => branch.Name);

                token.ThrowIfCancellationRequested();

                var enabledRemoteRepoNodes = new List <RemoteRepoNode>();
                var remoteByName           = Module.GetRemotes().ToDictionary(r => r.Name);

                var gitRemoteManager = new GitRemoteManager(() => Module);

                // Create nodes for enabled remotes with branches
                foreach (var branchPath in branches)
                {
                    token.ThrowIfCancellationRequested();
                    var remoteName = branchPath.SubstringUntil('/');
                    if (remoteByName.TryGetValue(remoteName, out var remote))
                    {
                        var remoteBranchNode = new RemoteBranchNode(this, branchPath);
                        var parent           = remoteBranchNode.CreateRootNode(
                            pathToNodes,
                            (tree, parentPath) => CreateRemoteBranchPathNode(tree, parentPath, remote));

                        if (parent != null)
                        {
                            enabledRemoteRepoNodes.Add((RemoteRepoNode)parent);
                        }
                    }
                }

                // Create nodes for enabled remotes without branches
                var enabledRemotesNoBranches = gitRemoteManager.GetEnabledRemoteNamesWithoutBranches();

                foreach (var remoteName in enabledRemotesNoBranches)
                {
                    if (remoteByName.TryGetValue(remoteName, out var remote))
                    {
                        var node = new RemoteRepoNode(this, remoteName, gitRemoteManager, remote, true);
                        enabledRemoteRepoNodes.Add(node);
                    }
                }

                // Add enabled remote nodes in order
                enabledRemoteRepoNodes
                .OrderBy(node => node.FullPath)
                .ForEach(node => nodes.AddNode(node));

                // Add disabled remotes, if any
                var disabledRemotes = gitRemoteManager.GetDisabledRemotes();

                if (disabledRemotes.Count > 0)
                {
                    var disabledRemoteRepoNodes = new List <RemoteRepoNode>();
                    foreach (var remote in disabledRemotes.OrderBy(remote => remote.Name))
                    {
                        var node = new RemoteRepoNode(this, remote.Name, gitRemoteManager, remote, false);
                        disabledRemoteRepoNodes.Add(node);
                    }

                    var disabledFolderNode = new RemoteRepoFolderNode(this, _inactiveRemoteNodeLabel.Text);
                    disabledRemoteRepoNodes
                    .OrderBy(node => node.FullPath)
                    .ForEach(node => disabledFolderNode.Nodes.AddNode(node));

                    nodes.AddNode(disabledFolderNode);
                }

                return(nodes);

                BaseBranchNode CreateRemoteBranchPathNode(Tree tree, string parentPath, Remote remote)
                {
                    if (parentPath == remote.Name)
                    {
                        return(new RemoteRepoNode(tree, parentPath, gitRemoteManager, remote, true));
                    }

                    return(new BasePathNode(tree, parentPath));
                }
            }
Пример #4
0
        public IEnumerable <ExternalLink> Parse(GitRevision revision)
        {
            GitRemoteManager remoteManager = new GitRemoteManager(revision.Module);

            return(Parse(revision, remoteManager));
        }