예제 #1
0
            public void ReturnsTrueIfShasAreSame()
            {
                var commit = new CommitVertex("sha", "whatever");
                var other = new CommitVertex("sha", "doesn't matter");

                Assert.True(commit == other);
            }
예제 #2
0
            public void ReturnsFalseIfShasAreDifferent()
            {
                var commit = new CommitVertex("sha1", "whatever");
                var other = new CommitVertex("sha2", "doesn't matter");

                Assert.False(commit.Equals(other));
            }
예제 #3
0
            public void ReturnsTrueIfShasAreSame()
            {
                var commit = new CommitVertex("sha", "whatever");
                var other  = new CommitVertex("sha", "doesn't matter");

                Assert.True(commit == other);
            }
예제 #4
0
            public void ReturnsFalseIfShasAreDifferent()
            {
                var commit = new CommitVertex("sha1", "whatever");
                var other  = new CommitVertex("sha2", "doesn't matter");

                Assert.False(commit.Equals(other));
                Assert.False(object.Equals(commit, other));
            }
예제 #5
0
            public void SetsProperties()
            {
                var commit = new CommitVertex("shasha", "commit message");

                Assert.Equal("shasha", commit.Sha);
                Assert.Equal("commit message", commit.Message);
                Assert.NotNull(commit.Branches);
            }
예제 #6
0
            public void ReturnsFalseIfShasAreDifferent()
            {
                var commit = new CommitVertex("sha", "whatever");
                var other  = new CommitVertex("sha1", "doesn't matter");

                Assert.False(commit == other);
                Assert.True(commit != other);
            }
예제 #7
0
            public void SetsProperties()
            {
                var commit = new CommitVertex("shasha", "commit message");

                Assert.Equal("shasha", commit.Sha);
                Assert.Equal("commit message", commit.Message);
                Assert.NotNull(commit.Branches);
            }
예제 #8
0
            public void ReturnsFalseWhenComparedToNull()
            {
                var commit = new CommitVertex("sha", "message");
                CommitVertex other = null;

                Assert.False(commit.Equals(other));
                Assert.False(object.Equals(commit, other));
            }
예제 #9
0
            public void ReturnsFalseWhenComparedToNull()
            {
                var commit = new CommitVertex("sha", "message");
                const CommitVertex other = null;

                Assert.False(commit.Equals(other));
                Assert.False(object.Equals(commit, other));
            }
예제 #10
0
            public void SetsProperties()
            {
                var commit = new CommitVertex("shasha", "commit message");

                Assert.Equal("shasha", commit.Sha);
                Assert.Equal("commit message", commit.Message);
                Assert.NotNull(commit.Branches);
                Assert.Equal(8, commit.ShaLength);
                Assert.True(commit.AdornerMessageVisibility);    // expanded is false -> true
                Assert.False(commit.DescriptionShown);
            }
예제 #11
0
            public void SetsProperties()
            {
                var commit = new CommitVertex("shasha", "commit message");

                Assert.Equal("shasha", commit.Sha);
                Assert.Equal("commit message", commit.Message);
                Assert.NotNull(commit.Branches);
                Assert.Equal(8, commit.ShaLength);
                Assert.Equal(true, commit.AdornerMessageVisibility);    // expanded is false -> true
                Assert.Equal(false, commit.DescriptionShown);
            }
예제 #12
0
 private void AddCommit(Commit commit)
 {
     var commitVertex = new CommitVertex(commit);
     _contents.AddVertex(commitVertex);
     commit.Parents.ForEach(AddCommit);
     commit.Parents
           .Select(p => new GraphContents.Edge {Source = commit.Sha, Target = p.Sha})
           .ForEach(edge => _contents.AddEdge(edge));
     if (_parameters.IncludeCommitContent)
     {
         AddTree(commit.Tree);
         var edge = new GraphContents.Edge {Source = commit.Sha, Target = commit.Tree.Sha, Tag = "/"};
         _contents.AddEdge(edge);
     }
 }
예제 #13
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);
            }
        }
예제 #14
0
        private void AddCommit(Commit commit)
        {
            var commitVertex = new CommitVertex(commit);

            _contents.AddVertex(commitVertex);
            commit.Parents.ForEach(AddCommit);
            commit.Parents
            .Select(p => new GraphContents.Edge {
                Source = commit.Sha, Target = p.Sha
            })
            .ForEach(edge => _contents.AddEdge(edge));
            if (_parameters.IncludeCommitContent)
            {
                AddTree(commit.Tree);
                var edge = new GraphContents.Edge {
                    Source = commit.Sha, Target = commit.Tree.Sha, Tag = "/"
                };
                _contents.AddEdge(edge);
            }
        }
예제 #15
0
        private void AddCommitsToGraph(Commit commit, CommitVertex childVertex)
        {
            // KeyValuePair is faster than a Tuple in this case.
            // We create as many instances as we pass to the AddCommitToGraph.
            Queue<CommitWithChildVertex> queue = new Queue<CommitWithChildVertex>();
            CommitWithChildVertex commitIter;
            queue.Enqueue(new CommitWithChildVertex(commit, childVertex));

            while (queue.Count != 0)
            {
                commitIter = queue.Dequeue();
                if (!AddCommitToGraph(commitIter.Key, commitIter.Value))
                    continue;

                foreach (var parent in commitIter.Key.Parents)
                {
                    queue.Enqueue(new CommitWithChildVertex(parent, GetCommitVertex(commitIter.Key)));
                }
            }
        }
예제 #16
0
        private CommitVertex GetCommitVertex(Commit commit)
        {
            CommitVertex commitVertex;
            if (!_vertices.TryGetValue(commit.Sha, out commitVertex))
            {
                commitVertex = new CommitVertex(commit.Sha, commit.MessageShort)
                {
                    Description = commit.Message,
                    Author = commit.Author.Name,
                    CommitDate = commit.Author.When

                };
                _vertices.Add(commit.Sha, commitVertex);
            }

            return commitVertex;
        }
예제 #17
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;
        }
예제 #18
0
 private bool CommitIsNotInGraph(CommitVertex v)
 {
     return !_commitsInGraph.Contains(v.Sha);
 }
예제 #19
0
        private CommitVertex GetCommitVertex(Commit commit)
        {
            CommitVertex commitVertex;
            if (!_vertices.TryGetValue(commit.Sha, out commitVertex))
            {
                commitVertex = new CommitVertex(commit.Sha, commit.MessageShort) { Description = commit.Message };
                _vertices.Add(commit.Sha, commitVertex);
            }

            _commitsInGraph.Add(commit.Sha);

            return commitVertex;
        }
        private void HighlightCommitsOnCurrentBranch(Commit commit, CommitVertex commitVertex)
        {
            Queue<Commit> queue = new Queue<Commit>();
            queue.Enqueue(commit);

            while (queue.Count != 0)
            {
                commit = queue.Dequeue();
                if (!HighlightCommit(commit))
                    return;

                foreach (var parent in commit.Parents)
                {
                    queue.Enqueue(parent);
                }
            }
        }