$project_list = "/srv/gitosis/gitosis/projects.list";
$size = 20;
+$header_height = false; //false = dynamic
$tile_size = 20; /* do not edit */
$max_branches = 30;
$colors = array(
NULL,
array(255, 0, 0),
- array(0, 255, 0),
+ array(array(0, 255, 0), array(0, 192, 0)),
array(0, 0, 255),
array(128, 128, 128),
array(128, 128, 0),
$data['branches'] = array();
$data['ubranches'] = array();
$brach_id = 1;
-$brach_uid = 1;
+$branch_uid = 1;
$graph_commit = NULL;
$first_commit = true;
$branch['id'] = $brach_id++;
$branch['uid'] = $branch_uid++;
$branch['active'] = true;
+ $branch['sticky'] = true;
$branch['next'] = $head['id'];
unset($branch);
if($use_local_branches) {
$head_list = shell_exec($cmd);
foreach(explode("\n", str_replace("\r", "", $head_list)) as $head) {
$head = explode(" ", $head);
+ $name = explode("/", $head[1]);
+ $name = $name[count($name)-1];
if(!$head[0])
continue;
$existing = false;
- foreach($data['branches'] as $branch) {
+ foreach($data['branches'] as &$branch) {
if($branch['next'] == $head[0]) {
$existing = true;
+ $branch['name'][] = $name;
break;
}
}
+ unset($branch);
if($existing)
continue;
$data['branches'][count($data['branches'])] = array(
"id" => $brach_id++,
- "uid" => $brach_uid++,
+ "uid" => $branch_uid++,
"active" => true,
+ "sticky" => true,
+ "name" => array($name),
"next" => $head[0]
);
}
$head_list = shell_exec($cmd);
foreach(explode("\n", str_replace("\r", "", $head_list)) as $head) {
$head = explode(" ", $head);
+ $name = explode("/", $head[1]);
+ $name = $name[count($name)-2];
if(!$head[0])
continue;
$existing = false;
- foreach($data['branches'] as $branch) {
+ foreach($data['branches'] as &$branch) {
if($branch['next'] == $head[0]) {
$existing = true;
+ $branch['name'][] = $name;
break;
}
}
+ unset($branch);
if($existing)
continue;
$data['branches'][count($data['branches'])] = array(
"id" => $brach_id++,
- "uid" => $brach_uid++,
+ "uid" => $branch_uid++,
"active" => true,
+ "sticky" => true,
+ "name" => array($name),
"next" => $head[0]
);
}
}
}
+if($_GET['c'] == "header") {
+ $count = count($data['branches']);
+ if($count > $max_branches)
+ $count = $max_branches;
+ if(!$header_height) {
+ $maxlen = 0;
+ foreach($data['branches'] as $branch) {
+ if($branch['sticky'] && count($branch['name'])) {
+ if(strlen($branch['name'][0]) > $maxlen)
+ $maxlen = strlen($branch['name'][0]);
+ }
+ }
+ $header_height = $maxlen * 2 + 15;
+ }
+ $image = imagecreatetruecolor($count * $size + 60, $header_height);
+ $transparentIndex = imagecolorallocate($image, 217, 216, 209);
+ imagefill($image, 0, 0, $transparentIndex);
+ $branches = 0;
+ foreach($data['branches'] as $branch) {
+ if($branch['sticky'] && count($branch['name'])) {
+ $branches++;
+ $color = get_color($branch['id'], true);
+ $color = imagecolorallocatealpha($image, $color[0], $color[1], $color[2], 0);
+ imagettftext($image, 8, 28, ($branch['id']-1) * $size + 10, $header_height-2, $color, $_SERVER['DOCUMENT_ROOT']."/arial.ttf", $branch['name'][0]);
+ }
+ }
+ if(!$branches) die();
+ imagecolortransparent($image, $transparentIndex);
+ header('Content-Type: image/png');
+ imagepng($image);
+ imagedestroy($image);
+ die();
+}
+
for($i = 0; $i <= intval($_GET['to']); $i++) {
//for($i = 0; $i < count($data['commits']); $i++) {
$commit = &$data['commits'][$i];
}
}
-if($graph_commit == NULL)
- die("ERROR 0x07");
-
//DEV Breakpoint
//print_r($data);
//die();
//generate image
+
+if($graph_commit == NULL)
+ die("ERROR 0x07");
+
$count = count($data['branches']);
if($count > $max_branches)
$count = $max_branches;
imagecopyresampled($image, $image2, $left, 0, 0, 0, $size, $size, $tile_size, $tile_size);
}
-function get_color($id) {
+function get_color($id, $text = false) {
global $colors, $graph_commit, $data;
if($graph_commit['branches'][($id-1)]['pre_merge']) {
$branch = $data['ubranches'][$graph_commit['branches'][($id-1)]['uid']];
if($branch['pre_merge'] && $branch['pre_merge_start'])
$id = $branch['pre_merge_id'];
}
- return $colors[($id - 1) % count($colors)];
+ $color_array = $colors[($id - 1) % count($colors)];
+ if($text && is_array($color_array[0]) && $color_array[1])
+ return $color_array[1];
+ return (is_array($color_array[0]) ? $color_array[0] : $color_array);
}
foreach($graph_commit['branches'] as $branch) {
--- index.cgi 2012-08-29 01:30:10 +0000
-+++ index-graph.cgi 2012-09-06 11:08:23 +0000
-@@ -4764,13 +4768,26 @@
++++ index-graph.cgi 2012-09-07 19:06:10 +0000
+@@ -4764,13 +4768,33 @@
sub git_shortlog_body {
# uses global variable $project
+ if (!defined $page) {
+ $page = 0;
+ }
++
++ print "<tr class=\"header\">\n";
++ print "<td colspan=\"2\"><img class=\"graph\" src=\"git_graph.php?r=".$graph_rand.";p=".$project.";h=".$hash.";from=".($from + (100 * $page)).";to=".($to + (100 * $page)).";c=header\" /></td>\n";
++ print "<td valign=\"bottom\"><b>Author</b></td>\n";
++ print "<td valign=\"bottom\"><b>Commit</b></td>\n";
++ print "<td></td>\n";
++ print "</tr>\n";
+
for (my $i = $from; $i <= $to; $i++) {
my %co = %{$commitlist->[$i]};
my $commit = $co{'id'};
-@@ -4781,6 +4798,7 @@
+@@ -4781,6 +4805,7 @@
print "<tr class=\"light\">\n";
}
$alternate ^= 1;
# git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
format_author_html('td', \%co, 10) . "<td>";
-@@ -5167,12 +5187,12 @@
+@@ -5167,12 +5194,12 @@
# we need to request one more than 16 (0..15) to check if
# those 16 are all
}
if (@taglist) {
-@@ -5847,8 +5867,10 @@
+@@ -5847,8 +5874,10 @@
my ($fmt_name, $body_subr, $base, $parent, $file_name, $file_hash) = @_;
my $head = git_get_head_hash($project);
}
if (!defined $page) {
$page = 0;
-@@ -5856,7 +5878,10 @@
+@@ -5856,7 +5885,10 @@
my $refs = git_get_references();
my $commit_hash = $base;
$commit_hash = "$parent..$base";
}
my @commitlist =
-@@ -5912,7 +5937,7 @@
+@@ -5912,7 +5944,7 @@
if (defined $file_name);
$body_subr->(\@commitlist, 0, 99, $refs, $next_link,