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 CHANGED
@@ -1,3 +1,4 @@
1
1
  output
2
- history.pdf
2
+ history.*
3
3
  pkg/
4
+ TODO
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git-dag (0.0.3)
4
+ git-dag (0.0.4)
5
5
  grit (~> 2.5.0)
6
6
 
7
7
  GEM
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
- Now you can open up 'history.svg' to see the DAG.
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.
@@ -2,6 +2,7 @@ require 'git-dag/application'
2
2
  require 'git-dag/git_graph'
3
3
  require 'git-dag/node'
4
4
  require 'git-dag/commit_node'
5
+ require 'git-dag/merge_node'
5
6
  require 'git-dag/fake_head'
6
7
  require 'git-dag/tag_node'
7
8
  require 'git-dag/legend'
@@ -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
- if merge?
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
@@ -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 = CommitNode.new(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 = CommitNode.new(parent)
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
@@ -0,0 +1,8 @@
1
+ module GitDag
2
+ class MergeNode < CommitNode
3
+ private
4
+ def color
5
+ "red"
6
+ end
7
+ end
8
+ end
@@ -2,7 +2,7 @@ module GitDag
2
2
  class TagNode < Node
3
3
  def initialize(id, dot_node, label, parents)
4
4
  @id = id
5
- @dot_node = dot_node
5
+ @dot_node = dot_node[0,6]
6
6
  @label = label
7
7
  @parents = parents
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module GitDag
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
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-08-06 00:00:00.000000000 Z
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