зеркало из https://github.com/microsoft/git.git
gitweb: ref markers link to named shortlogs
This patch turns ref markers for tags and heads into links to appropriate views for the ref name, depending on current context. For annotated tags, we link to the tag view, unless that's the current view, in which case we switch to shortlog. For other refs, we prefer the current view if it's history or (short)log, and default to shortlog otherwise. Appropriate changes are made in the CSS to prevent ref markers from being annoyingly blue and underlined, unless hovered. A visual indication of the target view difference is also implemented by making annotated tags show up in italic. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Acked-by: Petr Baudis <pasky@suse.cz> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
106db883b7
Коммит
4afbaefffa
|
@ -481,6 +481,19 @@ span.refs span {
|
|||
border-color: #ffccff #ff00ee #ff00ee #ffccff;
|
||||
}
|
||||
|
||||
span.refs span a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
span.refs span a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
span.refs span.indirect {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.refs span.ref {
|
||||
background-color: #aaaaff;
|
||||
border-color: #ccccff #0033cc #0033cc #ccccff;
|
||||
|
|
|
@ -1090,13 +1090,23 @@ sub format_log_line_html {
|
|||
}
|
||||
|
||||
# format marker of refs pointing to given object
|
||||
|
||||
# the destination action is chosen based on object type and current context:
|
||||
# - for annotated tags, we choose the tag view unless it's the current view
|
||||
# already, in which case we go to shortlog view
|
||||
# - for other refs, we keep the current view if we're in history, shortlog or
|
||||
# log view, and select shortlog otherwise
|
||||
sub format_ref_marker {
|
||||
my ($refs, $id) = @_;
|
||||
my $markers = '';
|
||||
|
||||
if (defined $refs->{$id}) {
|
||||
foreach my $ref (@{$refs->{$id}}) {
|
||||
# this code exploits the fact that non-lightweight tags are the
|
||||
# only indirect objects, and that they are the only objects for which
|
||||
# we want to use tag instead of shortlog as action
|
||||
my ($type, $name) = qw();
|
||||
my $indirect = ($ref =~ s/\^\{\}$//);
|
||||
# e.g. tags/v2.6.11 or heads/next
|
||||
if ($ref =~ m!^(.*?)s?/(.*)$!) {
|
||||
$type = $1;
|
||||
|
@ -1106,8 +1116,29 @@ sub format_ref_marker {
|
|||
$name = $ref;
|
||||
}
|
||||
|
||||
$markers .= " <span class=\"$type\" title=\"$ref\">" .
|
||||
esc_html($name) . "</span>";
|
||||
my $class = $type;
|
||||
$class .= " indirect" if $indirect;
|
||||
|
||||
my $dest_action = "shortlog";
|
||||
|
||||
if ($indirect) {
|
||||
$dest_action = "tag" unless $action eq "tag";
|
||||
} elsif ($action =~ /^(history|(short)?log)$/) {
|
||||
$dest_action = $action;
|
||||
}
|
||||
|
||||
my $dest = "";
|
||||
$dest .= "refs/" unless $ref =~ m!^refs/!;
|
||||
$dest .= $ref;
|
||||
|
||||
my $link = $cgi->a({
|
||||
-href => href(
|
||||
action=>$dest_action,
|
||||
hash=>$dest
|
||||
)}, $name);
|
||||
|
||||
$markers .= " <span class=\"$class\" title=\"$ref\">" .
|
||||
$link . "</span>";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1918,7 +1949,7 @@ sub git_get_references {
|
|||
|
||||
while (my $line = <$fd>) {
|
||||
chomp $line;
|
||||
if ($line =~ m!^([0-9a-fA-F]{40})\srefs/($type/?[^^]+)!) {
|
||||
if ($line =~ m!^([0-9a-fA-F]{40})\srefs/($type.*)$!) {
|
||||
if (defined $refs{$1}) {
|
||||
push @{$refs{$1}}, $2;
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче