ReinH-gitviz 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/LICENSE +20 -0
- data/Manifest +12 -0
- data/README.markdown +17 -0
- data/bin/gitviz +11 -0
- data/gitviz.gemspec +38 -0
- data/lib/gitviz.rb +3 -0
- data/lib/gitviz/digraph.rb +46 -0
- data/lib/gitviz/errors.rb +4 -0
- data/lib/gitviz/git_commands.rb +14 -0
- data/spec/gitviz_spec.rb +51 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- metadata +77 -0
data/CHANGELOG
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Rein Henrichs
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
GitViz
|
2
|
+
======
|
3
|
+
|
4
|
+
The GitViz library creates GraphViz .dot format graphs from your git commit history.
|
5
|
+
|
6
|
+
# From a git repository
|
7
|
+
$ gitviz master > master.dot
|
8
|
+
|
9
|
+
## Source Code ##
|
10
|
+
|
11
|
+
Main repository is at [http://github.com/ReinH/gitviz](http://github.com/ReinH/gitviz)
|
12
|
+
|
13
|
+
## Contributors: ##
|
14
|
+
* [Rein Henrichs](http://github.com/ReinH)
|
15
|
+
|
16
|
+
## Special Thanks ##
|
17
|
+
* jengelh on irc.freenode.com/git
|
data/bin/gitviz
ADDED
data/gitviz.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
# Gem::Specification for Gitviz-0.1.0
|
3
|
+
# Originally generated by Echoe
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{gitviz}
|
7
|
+
s.version = "0.1.0"
|
8
|
+
|
9
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = [""]
|
13
|
+
s.date = %q{2008-04-27}
|
14
|
+
s.default_executable = %q{gitviz}
|
15
|
+
s.description = %q{}
|
16
|
+
s.email = %q{}
|
17
|
+
s.executables = ["gitviz"]
|
18
|
+
s.extra_rdoc_files = ["bin/gitviz", "CHANGELOG", "lib/gitviz/digraph.rb", "lib/gitviz/errors.rb", "lib/gitviz/git_commands.rb", "lib/gitviz.rb", "LICENSE", "README.markdown"]
|
19
|
+
s.files = ["bin/gitviz", "CHANGELOG", "lib/gitviz/digraph.rb", "lib/gitviz/errors.rb", "lib/gitviz/git_commands.rb", "lib/gitviz.rb", "LICENSE", "Manifest", "README.markdown", "spec/gitviz_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "gitviz.gemspec"]
|
20
|
+
s.has_rdoc = true
|
21
|
+
s.homepage = %q{}
|
22
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gitviz", "--main", "README.markdown"]
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
s.rubyforge_project = %q{gitviz}
|
25
|
+
s.rubygems_version = %q{1.0.1}
|
26
|
+
s.summary = %q{}
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# # Original Rakefile source (requires the Echoe gem):
|
31
|
+
#
|
32
|
+
# require 'echoe'
|
33
|
+
# Echoe.new('gitviz')# do |p|
|
34
|
+
# # p.author = "Rein Henrichs"
|
35
|
+
# # p.email = "reinh@reinh.com"
|
36
|
+
# # p.summary = "GitViz generates DOT files from git commit graphs for GraphViz and great justice."
|
37
|
+
# # p.url = "http://github.com/reinh/gitviz"
|
38
|
+
# # end
|
data/lib/gitviz.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module GitViz
|
2
|
+
class Digraph
|
3
|
+
def initialize(ref = "master")
|
4
|
+
raise GitViz::InvalidGitRefError.new("#{ref} is not a valid ref") unless GitViz::GitCommands::valid_ref?(ref)
|
5
|
+
@ref = ref
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_dot_graph
|
9
|
+
str = digraph_head
|
10
|
+
|
11
|
+
heads_parents.each do |head, parents|
|
12
|
+
parents.each do |parent|
|
13
|
+
str << digraph_edge(head, parent)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
str << digraph_foot
|
18
|
+
end
|
19
|
+
alias_method :to_s, :to_dot_graph
|
20
|
+
|
21
|
+
# Pretty object inspection
|
22
|
+
def inspect
|
23
|
+
%Q{#<GitViz::Digraph "ref: #{@ref}">}
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def heads_parents
|
28
|
+
heads_parents_log = GitViz::GitCommands::git :log, @ref, "--pretty=format:\"<%h><%p>\""
|
29
|
+
heads_parents = heads_parents_log.map{|line| line.scan(/^<(.*?)><(.*?)>/).flatten}
|
30
|
+
heads_parents.map{|head, parents| [head, parents.split(' ')]}
|
31
|
+
end
|
32
|
+
|
33
|
+
def digraph_head
|
34
|
+
"digraph {\n\trankdir=RL;\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
def digraph_foot
|
38
|
+
"};\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
def digraph_edge(to, from)
|
42
|
+
"\t\"#{to}\" -> \"#{from}\";\n"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/spec/gitviz_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
class Git; include GitViz::GitCommands; end
|
4
|
+
|
5
|
+
describe GitViz::GitCommands do
|
6
|
+
before(:each) do
|
7
|
+
@g = Git.new
|
8
|
+
end
|
9
|
+
describe "git command" do
|
10
|
+
it "gets the git version" do
|
11
|
+
GitViz::GitCommands.git(:version).should =~ /^git version [\d\.a-z]*$/
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe GitViz::Digraph do
|
17
|
+
describe "initialized with a valid reference" do
|
18
|
+
before(:each) do
|
19
|
+
GitViz::GitCommands.should_receive(:valid_ref?).and_return(true)
|
20
|
+
@d = GitViz::Digraph.new
|
21
|
+
@log_string = "<123456><abcdef fedcba>"
|
22
|
+
@heads_parents = [["123456", ["abcdef", "fedcba"]]]
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has a pretty inspect" do
|
26
|
+
@d.inspect.should == %Q{#<GitViz::Digraph "ref: master">}
|
27
|
+
end
|
28
|
+
|
29
|
+
it "takes heads and their parents from the log" do
|
30
|
+
GitViz::GitCommands.should_receive(:git).with(:log, "master", "--pretty=format:\"<%h><%p>\"").and_return(@log_string)
|
31
|
+
@d.send(:heads_parents).should == @heads_parents
|
32
|
+
end
|
33
|
+
|
34
|
+
it "creates a dot graph from the heads and their parents" do
|
35
|
+
@d.should_receive(:heads_parents).and_return(@heads_parents)
|
36
|
+
|
37
|
+
@d.to_dot_graph.should == "digraph {\n\trankdir=TB;\n\t\"123456\" -> \"abcdef\";\n\t\"123456\" -> \"fedcba\";\n};\n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "initialized with an invalid reference" do
|
42
|
+
before(:each) do
|
43
|
+
GitViz::GitCommands.should_receive(:valid_ref?).and_return(false)
|
44
|
+
end
|
45
|
+
it "raises an error" do
|
46
|
+
initializing_invalid_digraph = lambda { GitViz::Digraph.new("invalid")}
|
47
|
+
|
48
|
+
initializing_invalid_digraph.should raise_error(GitViz::InvalidGitRefError)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ReinH-gitviz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ""
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-04-27 00:00:00 -07:00
|
13
|
+
default_executable: gitviz
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: ""
|
17
|
+
email: ""
|
18
|
+
executables:
|
19
|
+
- gitviz
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- bin/gitviz
|
24
|
+
- CHANGELOG
|
25
|
+
- lib/gitviz/digraph.rb
|
26
|
+
- lib/gitviz/errors.rb
|
27
|
+
- lib/gitviz/git_commands.rb
|
28
|
+
- lib/gitviz.rb
|
29
|
+
- LICENSE
|
30
|
+
- README.markdown
|
31
|
+
files:
|
32
|
+
- bin/gitviz
|
33
|
+
- CHANGELOG
|
34
|
+
- lib/gitviz/digraph.rb
|
35
|
+
- lib/gitviz/errors.rb
|
36
|
+
- lib/gitviz/git_commands.rb
|
37
|
+
- lib/gitviz.rb
|
38
|
+
- LICENSE
|
39
|
+
- Manifest
|
40
|
+
- README.markdown
|
41
|
+
- spec/gitviz_spec.rb
|
42
|
+
- spec/spec.opts
|
43
|
+
- spec/spec_helper.rb
|
44
|
+
- gitviz.gemspec
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: ""
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options:
|
49
|
+
- --line-numbers
|
50
|
+
- --inline-source
|
51
|
+
- --title
|
52
|
+
- Gitviz
|
53
|
+
- --main
|
54
|
+
- README.markdown
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: gitviz
|
72
|
+
rubygems_version: 1.0.1
|
73
|
+
signing_key:
|
74
|
+
specification_version: 2
|
75
|
+
summary: ""
|
76
|
+
test_files: []
|
77
|
+
|