Skip to content

Instantly share code, notes, and snippets.

@panike
Created February 4, 2011 16:51
Show Gist options
  • Save panike/811354 to your computer and use it in GitHub Desktop.
Save panike/811354 to your computer and use it in GitHub Desktop.
Convert a git log to html
sub new_hl {
my @l = ();
return \@l;
}
@args = @ARGV;
shift @args;
print "<html><body><pre>\n";
open REVLIST, "git log " . join(' ',@args) . " --cc --parents --topo-order|" || die "Cannot get log";
while(<REVLIST>){
chomp;
if(/^Merge: /){
next;
}
if(/^commit/){
@list = split / /;
@tlist = @list;
print "commit <a name=\"$list[1]\"></a>$list[1]\n";
@list = @list[2 .. $#list];
foreach $key (@list) {
print "parent <a href=\"\#$key\">$key</a>\n";
if(!$commits{$key}){
$commits{$key}=new_hl;
}
push @{$commits{$key}}, $tlist[1];
}
foreach $key (@{$commits{$tlist[1]}}){
print "child <a href=\"\#$key\">$key</a>\n";
}
}else{
s/</\&lt;/g;
s/>/\&gt;/g;
print;
print "\n";
}
}
print "</pre></body></html>\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment