コード例 #1
0
        public void DisplayAheadBehindInformation_should_display_default_text_image_if_ahead_behind_data_null(IDictionary <string, AheadBehindData> data)
        {
            var branchName = "who_cares";

            _aheadBehindDataProvider.GetData(branchName).Returns(x => data);

            _sut.DisplayStyle.Should().Be(ToolStripItemDisplayStyle.Image);
            _sut.ToolTipText.Should().Be("Push");
            _sut.Image.RawFormat.GetHashCode().Should().Be(PushImageHashCode);
        }
コード例 #2
0
            private Nodes FillBranchTree(IReadOnlyList <IGitRef> branches, CancellationToken token)
            {
                #region example

                // (input)
                // a-branch
                // develop/crazy-branch
                // develop/features/feat-next
                // develop/features/feat-next2
                // develop/issues/iss444
                // develop/wild-branch
                // issues/iss111
                // master
                //
                // ->
                // (output)
                // 0 a-branch
                // 0 develop/
                // 1   features/
                // 2      feat-next
                // 2      feat-next2
                // 1   issues/
                // 2      iss444
                // 1   wild-branch
                // 1   wilds/
                // 2      card
                // 0 issues/
                // 1     iss111
                // 0 master

                #endregion

                Nodes nodes           = new(this);
                var   aheadBehindData = _aheadBehindDataProvider?.GetData();

                var currentBranch = Module.GetSelectedBranch();
                Dictionary <string, BaseBranchNode> pathToNode = new();
                foreach (IGitRef branch in branches)
                {
                    token.ThrowIfCancellationRequested();

                    Validates.NotNull(branch.ObjectId);

                    bool            isVisible       = !IsFiltering.Value || _refsSource.Contains(branch.ObjectId);
                    LocalBranchNode localBranchNode = new(this, branch.ObjectId, branch.Name, branch.Name == currentBranch, isVisible);

                    if (aheadBehindData is not null && aheadBehindData.ContainsKey(localBranchNode.FullPath))
                    {
                        localBranchNode.UpdateAheadBehind(aheadBehindData[localBranchNode.FullPath].ToDisplay());
                    }

                    var parent = localBranchNode.CreateRootNode(pathToNode, (tree, parentPath) => new BranchPathNode(tree, parentPath));
                    if (parent is not null)
                    {
                        nodes.AddNode(parent);
                    }
                }

                return(nodes);
            }
コード例 #3
0
            private Nodes FillBranchTree(IEnumerable <string> branches, CancellationToken token)
            {
                #region ex

                // (input)
                // a-branch
                // develop/crazy-branch
                // develop/features/feat-next
                // develop/features/feat-next2
                // develop/issues/iss444
                // develop/wild-branch
                // issues/iss111
                // master
                //
                // ->
                // (output)
                // 0 a-branch
                // 0 develop/
                // 1   features/
                // 2      feat-next
                // 2      feat-next2
                // 1   issues/
                // 2      iss444
                // 1   wild-branch
                // 1   wilds/
                // 2      card
                // 0 issues/
                // 1     iss111
                // 0 master

                #endregion

                var nodes           = new Nodes(this);
                var aheadBehindData = _aheadBehindDataProvider?.GetData();

                var currentBranch = Module.GetSelectedBranch();
                var pathToNode    = new Dictionary <string, BaseBranchNode>();
                foreach (var branch in branches)
                {
                    token.ThrowIfCancellationRequested();
                    var localBranchNode = new LocalBranchNode(this, branch, branch == currentBranch);

                    if (aheadBehindData != null && aheadBehindData.ContainsKey(localBranchNode.FullPath))
                    {
                        localBranchNode.UpdateAheadBehind(aheadBehindData[localBranchNode.FullPath].ToDisplay());
                    }

                    var parent = localBranchNode.CreateRootNode(pathToNode, (tree, parentPath) => new BranchPathNode(tree, parentPath));
                    if (parent != null)
                    {
                        nodes.AddNode(parent);
                    }
                }

                return(nodes);
            }