git-dag 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/README.md +7 -1
- data/lib/git-dag.rb +1 -0
- data/lib/git-dag/commit_node.rb +1 -11
- data/lib/git-dag/git_graph.rb +9 -6
- data/lib/git-dag/merge_node.rb +8 -0
- data/lib/git-dag/tag_node.rb +1 -1
- data/lib/git-dag/version.rb +1 -1
- metadata +3 -2
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,9 @@ git-dag is a ruby script that generates a DAG tree (in the 'dot' format) for a
|
|
4
4
|
given Git repository.
|
5
5
|
|
6
6
|
## Preprequisite
|
7
|
+
You need to have Ruby installed. Try [RVM](https://rvm.io) or
|
8
|
+
[rbenv](http://rbenv.org) if you don't have one installed.
|
9
|
+
|
7
10
|
You need to have [Graphviz](http://graphviz.org/) installed if you want
|
8
11
|
to render the DAG visually. You can install it using the package manager
|
9
12
|
provided by your OS.
|
@@ -30,7 +33,10 @@ You can pipe the 2 commands together:
|
|
30
33
|
|
31
34
|
$ git-dag <path_to_git_repo> | dot -Tsvg -o history.svg
|
32
35
|
|
33
|
-
|
36
|
+
Note that if it take a good amount of time if your repository has a long history
|
37
|
+
of commits.
|
38
|
+
|
39
|
+
Now you can open up 'history.svg' in your browser to see the DAG.
|
34
40
|
|
35
41
|
Graphviz supports a lot of other formats, such as jpg, pdf, png, ps2 etc. Please
|
36
42
|
see [Graphviz](http://graphviz.org/) for more info.
|
data/lib/git-dag.rb
CHANGED
data/lib/git-dag/commit_node.rb
CHANGED
@@ -14,9 +14,7 @@ module GitDag
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_parent(parent)
|
17
|
-
#puts "commit #{id} add parent #{parent.id}"
|
18
17
|
@parents << parent
|
19
|
-
#puts "parents: #{@parents}" if id =~ /07da/
|
20
18
|
end
|
21
19
|
|
22
20
|
def dot_node
|
@@ -25,19 +23,11 @@ module GitDag
|
|
25
23
|
|
26
24
|
private
|
27
25
|
def color
|
28
|
-
|
29
|
-
"red"
|
30
|
-
else
|
31
|
-
"black"
|
32
|
-
end
|
26
|
+
"black"
|
33
27
|
end
|
34
28
|
|
35
29
|
def short_sha1
|
36
30
|
@grit_commit.id[0,6]
|
37
31
|
end
|
38
|
-
|
39
|
-
def merge?
|
40
|
-
@parents.size > 1
|
41
|
-
end
|
42
32
|
end
|
43
33
|
end
|
data/lib/git-dag/git_graph.rb
CHANGED
@@ -9,12 +9,13 @@ module GitDag
|
|
9
9
|
|
10
10
|
def output_dot_file
|
11
11
|
all_commits = build_entire_graph
|
12
|
-
add_tag_nodes(all_commits)
|
12
|
+
#add_tag_nodes(all_commits)
|
13
13
|
get_dot_str(all_commits)
|
14
14
|
end
|
15
15
|
|
16
|
+
private
|
17
|
+
|
16
18
|
def get_dot_str(all_commits)
|
17
|
-
#puts "all_commits: #{all_commits.size}"
|
18
19
|
dot_str = "digraph G {\n"
|
19
20
|
all_commits.each do |id, node|
|
20
21
|
node.parents.each do |parent|
|
@@ -32,13 +33,11 @@ module GitDag
|
|
32
33
|
@all_branches.each do |branch|
|
33
34
|
commits = find_commits_per_branch(branch.name)
|
34
35
|
commits.each do |commit|
|
35
|
-
my_commit =
|
36
|
+
my_commit = create_commit_node(commit)
|
36
37
|
all_commits[commit.id] = my_commit unless all_commits.has_key? commit.id
|
37
|
-
#puts "adding #{commit.id} to hash"
|
38
38
|
commit.parents.each do |parent|
|
39
|
-
parent_commit =
|
39
|
+
parent_commit = create_commit_node(parent)
|
40
40
|
my_commit.add_parent(parent_commit)
|
41
|
-
#all_commits[parent.id] = parent_commit unless all_commits.has_key? parent.id
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
@@ -71,5 +70,9 @@ module GitDag
|
|
71
70
|
def find_commits_per_branch(branch)
|
72
71
|
@repo.commits(branch, false) # false indicates all commits
|
73
72
|
end
|
73
|
+
|
74
|
+
def create_commit_node(commit)
|
75
|
+
commit.parents.size > 1 ? MergeNode.new(commit) : CommitNode.new(commit)
|
76
|
+
end
|
74
77
|
end
|
75
78
|
end
|
data/lib/git-dag/tag_node.rb
CHANGED
data/lib/git-dag/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-dag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: grit
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/git-dag/fake_head.rb
|
50
50
|
- lib/git-dag/git_graph.rb
|
51
51
|
- lib/git-dag/legend.rb
|
52
|
+
- lib/git-dag/merge_node.rb
|
52
53
|
- lib/git-dag/node.rb
|
53
54
|
- lib/git-dag/tag_node.rb
|
54
55
|
- lib/git-dag/version.rb
|