コード例 #1
0
        public RepositoryGraph Graph()
        {
            var graph   = new RepositoryGraph();
            var commits = new[]
            {
                new CommitVertex("c34173273", "Wrote some code")
                {
                    Description = "This is a long form description of the commit"
                },
                new CommitVertex("b1ae7a123", "Initial commit"),
                new CommitVertex("aa3823ca1", "Added readme"),
                new CommitVertex("9e21435fa", "Branching")
                {
                    Description = "This is a long form description of the commit"
                }
            };

            commits.First().Branches.Merge(new BranchReference {
                Name = "Master"
            });
            commits.First().Branches.Merge(new BranchReference {
                Name = "remotes/origin/master", IsRemote = true
            });

            graph.AddVertexRange(commits);
            graph.AddEdge(new CommitEdge(commits[1], commits[2]));
            graph.AddEdge(new CommitEdge(commits[0], commits[1]));
            graph.AddEdge(new CommitEdge(commits[3], commits[2]));
            graph.LayoutAlgorithmType = "EfficientSugiyama";
            return(graph);
        }
コード例 #2
0
        public RepositoryGraph Graph(GraphParameters graphParameters)
        {
            var graph   = new RepositoryGraph();
            var commits = new GitVertex[]
            {
                new CommitVertex("c34173273", "Wrote some code")
                {
                    Message = "This is a long form description of the commit"
                },
                new CommitVertex("b1ae7a123", "Initial commit"),
                new CommitVertex("aa3823ca1", "Added readme"),
                new CommitVertex("9e21435fa", "Branching")
                {
                    Message = "This is a long form description of the commit"
                },
                new ReferenceVertex("refs/head/master", "c34173273"),
                new ReferenceVertex("remotes/origin/master", "c34173273"),
            };

            graph.AddVertexRange(commits);
            graph.AddEdge(new GitEdge(commits[1], commits[2], null));
            graph.AddEdge(new GitEdge(commits[0], commits[1], null));
            graph.AddEdge(new GitEdge(commits[3], commits[2], null));
            graph.LayoutAlgorithmType = "EfficientSugiyama";
            return(graph);
        }
コード例 #3
0
        private bool AddCommitToGraph(Commit commit, CommitVertex childVertex)
        {
            var commitVertex = GetCommitVertex(commit);

            _graph.AddVertex(commitVertex);
            if (childVertex != null)
            {
                var edge = new CommitEdge(childVertex, commitVertex);
                if (_edges.ContainsKey(edge.Id))
                {
                    return(false);
                }

                _graph.AddEdge(edge);
                _edges.Add(edge.Id, edge);
            }
            return(true);
        }
コード例 #4
0
        private void AddCommitsToGraph(Commit commit, CommitVertex childVertex)
        {
            var commitVertex = GetCommitVertex(commit);

            _graph.AddVertex(commitVertex);
            if (childVertex != null)
            {
                var edge = new CommitEdge(childVertex, commitVertex);
                if (_edges.ContainsKey(edge.Id))
                {
                    return;
                }
                _graph.AddEdge(edge);
                _edges.Add(edge.Id, edge);
            }

            foreach (var parent in commit.Parents)
            {
                AddCommitsToGraph(parent, commitVertex);
            }
        }