show tags in lists
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Kay Sievers committed
Dec 7, 2005 at 09:44 UTC
6a928415e25da49b0f19b6924b6d9bbf1f8d5a4b
1 file changed
+45
-14
gitweb.cgi
+45
-14
@@ -311,6 +311,10 @@ a.rss_logo {
311
text-align:center; text-decoration:none;
312
}
313
a.rss_logo:hover { background-color:#ee5500; }
314
+span.tag {
315
+ padding:0px 4px; font-size:10px;
316
+ background-color:#ffffaa; border:1px solid; border-color:#ffffcc #ffee00 #ffee00 #ffffcc;
317
+}
318
</style>
319
</head>
320
<body>
@@ -901,6 +905,20 @@ sub git_project_list {
905
git_footer_html();
906
}
907
908
+sub read_info_ref {
909
+ my %refs;
910
+ # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
911
+ # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
912
+ open my $fd, "$projectroot/$project/info/refs" or return;
913
+ while (my $line = <$fd>) {
914
+ if ($line =~ m/^([0-9a-fA-F]{40})\t.*\/([^\^]+)/) {
915
+ $refs{$1} = $2;
916
+ }
917
+ }
918
+ close $fd or return;
919
+ return \%refs;
920
+}
921
+
922
sub git_read_refs {
923
my $ref_dir = shift;
924
my @reflist;
@@ -989,6 +1007,7 @@ sub git_summary {
1007
$owner = get_file_owner("$projectroot/$project");
1008
}
1009
1010
+ my $refs = read_info_ref();
1011
git_header_html();
1012
print "<div class=\"page_nav\">\n" .
1013
"summary".
@@ -1034,6 +1053,9 @@ sub git_summary {
1053
print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"},
1054
"<b>" . esc_html($co{'title'}) . "</b>");
1055
}
1056
+ if (defined $refs->{$commit}) {
1057
+ print " <span class=\"tag\">$refs->{$commit}</span>";
1058
+ }
1059
print "</td>\n" .
1060
"<td class=\"link\">" .
1061
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
@@ -1556,6 +1578,7 @@ sub git_log {
1578
if (!defined $page) {
1579
$page = 0;
1580
}
1581
+ my $refs = read_info_ref();
1582
git_header_html();
1583
print "<div class=\"page_nav\">\n";
1584
print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -1598,13 +1621,17 @@ sub git_log {
1621
}
1622
for (my $i = ($page * 100); $i <= $#revlist; $i++) {
1623
my $commit = $revlist[$i];
1624
+ my $ref = "";
1625
+ if (defined $refs->{$commit}) {
1626
+ $ref = " <span class=\"tag\">$refs->{$commit}</span>";
1627
+ }
1628
my %co = git_read_commit($commit);
1629
next if !%co;
1630
my %ad = date_str($co{'author_epoch'});
1631
print "<div>\n" .
1632
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "title"},
1606
- "<span class=\"age\">$co{'age_string'}</span>" . esc_html($co{'title'})) . "\n" .
1607
- "</div>\n";
1633
+ "<span class=\"age\">$co{'age_string'}</span>" . esc_html($co{'title'}) . $ref) . "\n";
1634
+ print "</div>\n";
1635
print "<div class=\"title_text\">\n" .
1636
"<div class=\"log_link\">\n" .
1637
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
@@ -1981,23 +2008,18 @@ sub git_commitdiff_plain {
2008
2009
# try to figure out the next tag after this commit
2010
my $tagname;
1984
- my %taghash;
1985
- my $tags = git_read_refs("refs/tags");
1986
- foreach my $entry (@$tags) {
1987
- my %tag = %$entry;
1988
- $taghash{$tag{'refid'}} = $tag{'name'};
1989
- }
2011
+ my $refs = read_info_ref();
2012
open $fd, "-|", "$gitbin/git-rev-list HEAD";
1991
- while (my $commit = <$fd>) {
1992
- chomp $commit;
1993
- if ($taghash{$commit}) {
1994
- $tagname = $taghash{$commit};
2013
+ chomp (my (@commits) = <$fd>);
2014
+ close $fd;
2015
+ foreach my $commit (@commits) {
2016
+ if (defined $refs->{$commit}) {
2017
+ $tagname = $refs->{$commit}
2018
}
2019
if ($commit eq $hash) {
2020
last;
2021
}
2022
}
2000
- close $fd;
2023
2024
print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
2025
my %co = git_read_commit($hash);
@@ -2041,6 +2063,7 @@ sub git_history {
2063
if (!%co) {
2064
die_error(undef, "Unknown commit object.");
2065
}
2066
+ my $refs = read_info_ref();
2067
git_header_html();
2068
print "<div class=\"page_nav\">\n" .
2069
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -2070,6 +2093,10 @@ sub git_history {
2093
if (!%co) {
2094
next;
2095
}
2096
+ my $ref = "";
2097
+ if (defined $refs->{$commit}) {
2098
+ $ref = " <span class=\"tag\">$refs->{$commit}</span>";
2099
+ }
2100
if ($alternate) {
2101
print "<tr class=\"dark\">\n";
2102
} else {
@@ -2079,7 +2106,7 @@ sub git_history {
2106
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2107
"<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" .
2108
"<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" .
2082
- esc_html(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" .
2109
+ esc_html(chop_str($co{'title'}, 50)) . "</b>") . "$ref</td>\n" .
2110
"<td class=\"link\">" .
2111
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
2112
" | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
@@ -2254,6 +2281,7 @@ sub git_shortlog {
2281
if (!defined $page) {
2282
$page = 0;
2283
}
2284
+ my $refs = read_info_ref();
2285
git_header_html();
2286
print "<div class=\"page_nav\">\n" .
2287
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -2312,6 +2340,9 @@ sub git_shortlog {
2340
print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"},
2341
"<b>" . esc_html($co{'title_short'}) . "</b>");
2342
}
2343
+ if (defined $refs->{$commit}) {
2344
+ print " <span class=\"tag\">$refs->{$commit}</span>";
2345
+ }
2346
print "</td>\n" .
2347
"<td class=\"link\">" .
2348
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .