jerith666 / git-graph Goto Github PK
View Code? Open in Web Editor NEWA Ruby script that creates a Graphviz graph showing the high-level structure of a repository's history
A Ruby script that creates a Graphviz graph showing the high-level structure of a repository's history
Thanks for fixing the other issue where the script wouldn't work if builder 3.0.0 was used. The script is in a usable state now.
I noticed another issue where the boring commits have the commit SHA1s in reverse order. I'd expect the older SHA1 on the left and the newer SHA1 on the right. I think the problem is on line 238 of the script. Do you see this as an issue?
PS: not everyone writes good commit messages. So there can be big commit messages (spanning multiple lines), which would make big ellipses in the output. If you can only the first 50 characters as the commit message, the output graph would look better.
The sample command doesn't work. I have the 'grit' gem installed.
./git-graph.rb ~/workspace/bender/| dot -Tsvg -ohistory.svg /dev/stdin
./git-graph.rb:163:in log_for': undefined method
to_xs' for "revving bender gem50dcc3\n":String (NoMethodError)
from ./git-graph.rb:197:in make_node' from ./git-graph.rb:50:in
plot_tree'
from ./git-graph.rb:289:in block in <main>' from ./git-graph.rb:288:in
each'
from ./git-graph.rb:288:in `
This tools doesn't work in default installation (at least on Cygwin). It just produces
#omitting #xxx that doesn't know its parents
for every item.
The command gem install gitlab-grit
solves this problem. It installs GitLab fork of Grit version 2.8.1 (for the moment).
Whereas by default Grit 2.5.0 is installed. But it seems that this version is outdated now and Grit is no longer maintained.
In default installation, ref.parents
throws NoMethodError on every item in filtering decorated
list:
decorated.reject!{|ref|
begin
ref.parents
false
rescue NoMethodError
puts "#omitting #{ref} that doesn't know its parents"
true
end}
Actually, repo.branches[0].commit.parents
throws error:
NoMethodError: undefined method `>>' for "x":String
When executing on this git repository: https://android.googlesource.com/kernel/goldfish.git
$ ./git-graph.rb /local/scratch/drt24/android/clones/kernel/goldfish
I get lots of lines like:
unknown header '' in commit de9c9f86be0dc3495de98dc65c80abe6e7c7d643
unknown header '' in commit de9c9f86be0dc3495de98dc65c80abe6e7c7d643
unknown header '' in commit de9c9f86be0dc3495de98dc65c80abe6e7c7d643
unknown header '' in commit de9c9f86be0dc3495de98dc65c80abe6e7c7d643
unknown header '' in commit de9c9f86be0dc3495de98dc65c80abe6e7c7d643
unknown header 'mergetag' in commit ce6fbaf160628df62ec953c701d5fc547484257a
And then:
/usr/lib/ruby/vendor_ruby/grit/commit.rb:152:in `list_from_string': undefined method `split' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/vendor_ruby/grit/commit.rb:125:in `find_all'
from /usr/lib/ruby/vendor_ruby/grit/commit.rb:93:in `lazy_source'
from /usr/lib/ruby/vendor_ruby/grit/lazy.rb:31:in `block (2 levels) in lazy_reader'
from ./git-graph.rb:22:in `find_children'
from ./git-graph.rb:301:in `block in <main>'
from ./git-graph.rb:299:in `each'
from ./git-graph.rb:299:in `<main>'
I am running Ubuntu 14.04.1 LTS 3.13.0-35-generic x86_64 with ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux], ruby-fast-xs 0.8.0-3build1 and ruby-grit 2.5.0-1.
Hi,
First of all, I am using your script and i love it.
But there's a bug i found i think you might want to fix, it's simple:)
you use fast_xs to escape the double qoutes, just for generate a VALID XML file, for the SVG, right?
but, when someone, like me, wants a PNG file, this script will make &, " shows in the text of the picture. which is not right.
e.g: i have a commit:
commit b5941e3ba596bae219299ca480c8c48683b5b644
Author: sunus <[email protected]>
Date: Tue Dec 10 21:19:38 2013 +0800
Revert "remove FILE"
This reverts commit 163a6d700226b780b7852a79fe1370a6d38c819a.
it shows Revert $quot; remove FILE $quot; (replace $ with &)
and i think it shouldn't
as far as i tested, you all just use this:
wrap_text(commit_msg + " [" + id_for(commit) + "]").gsub(%r|\n|, "
")
both PNG and SVG works fine.
efergcz@esekilxxen1814:~/git-graph> ls -lah
total 80K
drwxrwxr-x 3 efergcz rnd 4.0K Feb 13 12:07 .
drwxr-xr-x 119 efergcz rnd 24K Feb 13 11:13 ..
drwxrwxr-x 8 efergcz rnd 4.0K Feb 13 11:54 .git
-rw-rw-r-- 1 efergcz rnd 35 Feb 13 11:00 .gitignore
-rw-rw-r-- 1 efergcz rnd 84 Feb 13 11:00 Gemfile
-rw-rw-r-- 1 efergcz rnd 280 Feb 13 11:16 Gemfile.lock
-rw-rw-r-- 1 efergcz rnd 437 Feb 13 11:00 README
-rwxrwxr-x 1 efergcz rnd 8.4K Feb 13 11:00 git-graph.rb
-rw-rw-r-- 1 efergcz rnd 104 Feb 13 11:00 test.dot
efergcz@esekilxxen1814:~/git-graph> ./git-graph.rb ./
/home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/internal/pack.rb:135:in `block (2 levels) in init_pack': pack /home/efergcz/git-graph/.git/objects/pack/pack-6fb4fe8c8726ba422fa829803e80c27f33125f41.pack has discontinuous index 1 (Grit::GitRuby::Internal::PackFormatError)
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/internal/pack.rb:132:in `times'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/internal/pack.rb:132:in `block in init_pack'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/internal/pack.rb:73:in `with_idx'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/internal/pack.rb:130:in `init_pack'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/internal/pack.rb:46:in `initialize'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:763:in `new'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:763:in `block (2 levels) in load_packs'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:761:in `each'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:761:in `block in load_packs'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:760:in `open'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:760:in `load_packs'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:743:in `initpacks'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:89:in `get_raw_object_by_sha1'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:334:in `walk_log'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:287:in `log'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby/repository.rb:306:in `rev_list'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby.rb:70:in `block in rev_list'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby.rb:211:in `block in try_run'
from /app/ruby/2.0.0/LMWP3/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby.rb:210:in `try_run'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/git-ruby.rb:70:in `rev_list'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/commit.rb:120:in `find_all'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/commit.rb:93:in `lazy_source'
from /home/efergcz/gems/gems/grit-2.5.0/lib/grit/lazy.rb:31:in `block (2 levels) in lazy_reader'
from ./git-graph.rb:288:in `block in <main>'
from ./git-graph.rb:286:in `reject!'
from ./git-graph.rb:286:in `<main>'
efergcz@esekilxxen1814:~/git-graph> ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
$ ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
and, I installed grit-2.5.0 , builder-3.0.0
I can't run git-graph.rb
$ ruby -I/var/lib/gems/1.8/gems/grit-2.5.0/lib git-graph.rb . | dot -Tsvg -ohistory.svg /dev/stdin
git-graph.rb:8:in to_xs': undefined method
encode' for Builder::XChar:Module (NoMethodError)
from git-graph.rb:170:in log_for' from git-graph.rb:204:in
make_node'
from git-graph.rb:56:in plot_tree' from git-graph.rb:299 from git-graph.rb:298:in
each'
from git-graph.rb:298
Error: /dev/stdin:7: syntax error near line 7
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.