use strict;
use warnings;
use base qw(Exporter);
-our @EXPORT_OK = qw(git_unquote git_commit_title);
+our @EXPORT_OK = qw(git_unquote git_commit_title git_dec_links);
+use PublicInbox::Hval qw(utf8_html);
my %GIT_ESC = (
a => "\a",
$rv;
}
+# example inputs: "HEAD -> master", "tag: v1.0.0",
+sub git_dec_links {
+ my ($rel, $D) = @_;
+ my @l;
+ foreach (split /, /, $D) {
+ if (/\A(\S+) -> (\S+)/) { # 'HEAD -> master'
+ my ($s, $h) = ($1, $2);
+ $s = utf8_html($s);
+ $h = PublicInbox::Hval->utf8($h);
+ my $r = $h->as_href;
+ $h = $h->as_html;
+ push @l, qq($s -> <a\nhref="${rel}log?h=$r">$h</a>);
+ } elsif (s/\Atag: //) {
+ my $h = PublicInbox::Hval->utf8($_);
+ my $r = $h->as_href;
+ $h = $h->as_html;
+ push @l, qq(<a\nhref="${rel}tag?h=$r"><b>$h</b></a>);
+ } else {
+ my $h = PublicInbox::Hval->utf8($_);
+ my $r = $h->as_href;
+ $h = $h->as_html;
+ push @l, qq(<a\nhref="${rel}log?h=$r">$h</a>);
+ }
+ }
+ @l;
+}
+
1;
use warnings;
use PublicInbox::Hval qw(utf8_html);
use base qw(PublicInbox::RepoBrowseBase);
+use PublicInbox::RepoBrowseGit qw(git_dec_links);
# enable if we can speed it up..., over 100ms is unnacceptable
my @graph; # = qw(--graph);
$s =~ s/\As//;
$s = utf8_html($s);
-
- # TODO: handle $D (decorate)
$s = qq(<a\nhref="${rel}commit?id=$id">$s</a>);
+
+ if ($D =~ /\AD(.+)/) {
+ $s .= ' ('. join(', ', git_dec_links($rel, $1)) . ')';
+ }
+
if (defined $b) {
$an =~ s/\Aa//;
$b =~ s/\Ab//;
$gr =~ s/([^\n]+)\z/($1."\n") x $nl/es;
}
$b = utf8_html($b);
- $b = "<b>$s</b>\n- $ah @ $ai\n\n$b";
+ $b = "$s\n- $ah @ $ai\n\n$b";
if (@graph) {
$fh->write('<table><tr><td><pre>'. $gr .
'</pre></td><td><pre>' . $b .