Commits

Michele Bini committed f600dd0

Add options --all and --max-depth

Comments (0)

Files changed (2)

 
 Software required: Ruby, Ruby/Git, Graphviz, Eye-of-Gnome
 
+Usage: git digraph OPTIONS* OBJECT*
+
+Options:
+  --all          Include all local branches
+  --max-depth N  Show branch history up to N commits deep
+  --graphviz     Raw graphviz output, no display via eog
+  -v, --verbose  Verbose operations
+  -h, --help     Display this help screen
+
 Copyright (c) 2012 Michele Bini <michele.bini@gmail.com>
 
 This program is free software: you can redistribute it and/or modify
 end
 
 class Options < ClassyCLI
-  def _h
-    self.__help
-  end
+  def _h; self.__help; end
   def __help
     puts "git digraph OPTIONS* OBJECT*"
     puts
     puts "Display directed graph of Git commits"
     puts
     puts "Options:"
-    puts "  --graphviz  Raw graphviz output, no display"
+    puts "  --all          Include all local branches"
+    puts "  --max-depth N  Show branch history up to N commits deep"
+    puts "  --graphviz     Raw graphviz output, no display via eog"
     # puts "  --svg       SVG output"
-    puts "  -a, --all   Include all local branches"
-    puts "  -h, --help  Display this help screen"
+    puts "  -v, --verbose  Verbose operations"
+    puts "  -h, --help     Display this help screen"
     exit
   end
+  def _v; self.__verbose; end
   def __verbose
     $verbose = true
   end
+  def __all
+    $all_branches = true
+  end
   def __graphviz
     $raw_graphviz = true
   end
-  def __word(x)
-    $stderr.puts("Printing a word") if $verbose
-    puts(x)
+  def __max_depth(d)
+    $max_depth = d.to_i
   end
 end
 
 end
 
 def processlog(x)
-  (x.log(nil)).each do |commit|
+  (x.log($max_depth)).each do |commit|
     break unless @processcommit.call(commit)
   end
 end
 #   end
 # end
 
-if (ARGV.empty?)
+if $all_branches
+  g.branches.local.each do |o|
+    processlog(o.gcommit)
+  end
+  ARGV.each do |o|
+    processlog(g.gcommit(o))
+  end
+elsif (ARGV.empty?)
   processlog(g)
 else
   ARGV.each do |o|
-    processlog(g.gcommit(o, depth))
+    processlog(g.gcommit(o))
   end
 end