forked from redis/redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tcl program to show commits graphicaly.
Used to generate http://antirez.com/news/98.
- Loading branch information
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
This Tcl script is what I used in order to generate the graph you | ||
can find at http://antirez.com/news/98. It's really quick & dirty, more | ||
a trow away program than anything else, but probably could be reused or | ||
modified in the future in order to visualize other similar data or an | ||
updated version of the same data. | ||
|
||
The usage is trivial: | ||
|
||
./genhtml.tcl > output.html | ||
|
||
The generated HTML is quite broken but good enough to grab a screenshot | ||
from the browser. Feel free to improve it if you got time / interest. | ||
|
||
Note that the code filtering the tags, and the hardcoded branch name, does | ||
not make the script, as it is, able to analyze a different repository. | ||
However the changes needed are trivial. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env tclsh | ||
|
||
# Load commits history as "sha1 unixtime". | ||
set commits [exec git log unstable {--pretty="%H %at"}] | ||
set raw_tags [exec git tag] | ||
|
||
# Load all the tags that are about stable releases. | ||
foreach tag $raw_tags { | ||
if {[string match v*-stable $tag]} { | ||
set tag [string range $tag 1 end-7] | ||
puts $tag | ||
} | ||
if {[regexp {^[0-9]+.[0-9]+.[0-9]+$} $tag]} { | ||
lappend tags $tag | ||
} | ||
} | ||
|
||
# For each tag, create a list of "name unixtime" | ||
foreach tag $tags { | ||
set taginfo [exec git log $tag -n 1 "--pretty=\"$tag %at\""] | ||
set taginfo [string trim $taginfo {"}] | ||
lappend labels $taginfo | ||
} | ||
# For each commit, check the amount of code changed and create an array | ||
# mapping the commit to the number of lines affected. | ||
foreach c $commits { | ||
set stat [exec git show --oneline --numstat [lindex $c 0]] | ||
set linenum 0 | ||
set affected 0 | ||
foreach line [split $stat "\n"] { | ||
incr linenum | ||
if {$linenum == 1 || [string match *deps/* $line]} continue | ||
if {[catch {llength $line} numfields]} continue | ||
if {$numfields == 0} continue | ||
catch { | ||
incr affected [lindex $line 0] | ||
incr affected [lindex $line 1] | ||
} | ||
} | ||
set commit_to_affected([lindex $c 0]) $affected | ||
} | ||
set base_time [lindex [lindex $commits end] 1] | ||
puts [clock format $base_time] | ||
# Generate a graph made of HTML DIVs. | ||
puts {<html> | ||
<style> | ||
.box { | ||
position:absolute; | ||
width:10px; | ||
height:5px; | ||
border:1px black solid; | ||
background-color:#44aa33; | ||
opacity: 0.04; | ||
} | ||
.label { | ||
position:absolute; | ||
background-color:#dddddd; | ||
font-family:helvetica; | ||
font-size:12px; | ||
padding:2px; | ||
color:#666; | ||
border:1px #aaa solid; | ||
border-radius: 5px; | ||
} | ||
#outer { | ||
position:relative; | ||
width:1500; | ||
height:500; | ||
border:1px #aaa solid; | ||
} | ||
</style> | ||
<div id="outer"> | ||
} | ||
foreach c $commits { | ||
set sha [lindex $c 0] | ||
set t [expr {([lindex $c 1]-$base_time)/(3600*24*2)}] | ||
set affected [expr $commit_to_affected($sha)] | ||
set left $t | ||
set height [expr {log($affected)*20}] | ||
puts "<div class=\"box\" style=\"left:$left; bottom:0; height:$height\"></div>" | ||
} | ||
set bottom -30 | ||
foreach l $labels { | ||
set name [lindex $l 0] | ||
set t [expr {([lindex $l 1]-$base_time)/(3600*24*2)}] | ||
set left $t | ||
if {$left < 0} continue | ||
incr bottom -20 | ||
if {$bottom == -210} {set bottom -30} | ||
puts "<div class=\"label\" style=\"left:$left; bottom:$bottom\">$name</div>" | ||
} | ||
puts {</div></html>} |