-about heads tags
-
-\$ git log --pretty=format:'%h %s (%cs)%d'
+\$ git log --pretty=format:'%h %s (%cs)%d'$tip_html
EOM
for (@r) {
my $d; # decorations
@@ -82,8 +107,10 @@ EOM
if ($bref) {
my $l = PublicInbox::Linkify->new;
$$bref =~ s/\s*\z//sm;
+ my (undef, $path) = split(/:/, $ref_path, 2); # HEAD:README
print $zfh "\n\$ " .
- "git cat-file blob ",
+ qq(git cat-file blob ).
ascii_html($ref_path), "\n",
$l->to_html($$bref), '
';
}
@@ -111,13 +138,28 @@ EOM
"%(refname:short) %(subject) (%(creatordate:short))'\n";
@r = split(/^/sm, shift(@x) // '');
$last = pop(@r) if scalar(@r) > $ctx->{wcr}->{summary_tags};
+ my @s = sort keys %{$ctx->{wcr}->{snapshots}};
+ my $n;
+ if (@s) {
+ $n = $ctx->{git}->local_nick // die "BUG: $ctx->{git_dir} nick";
+ $n =~ s/\.git\z/-/;
+ ($n) = ($n =~ m!([^/]+)\z!);
+ $n = ascii_html($n);
+ }
for (@r) {
my (undef, $oid, $ref, $s, $cd) = split(/\0/);
utf8::decode($_) for ($ref, $s);
chomp $cd;
my $align = length($ref) < 12 ? ' ' x (12 - length($ref)) : '';
print $zfh "", ascii_html($ref),
- "$align ", ascii_html($s), " ($cd)\n";
+ "$align ", ascii_html($s), " ($cd)";
+ if (@s) {
+ my $v = $ref;
+ $v =~ s/\A[vV]//;
+ print $zfh "\t", join(' ', map {
+ qq{$_} } @s);
+ }
+ print $zfh "\n";
}
print $zfh "# no tags yet...\n" if !@r;
print $zfh "...\n" if $last;
@@ -145,23 +187,27 @@ sub set_readme { # git->cat_async callback
sub summary {
my ($self, $ctx) = @_;
$ctx->{wcr} = $self;
+ my $tip = $ctx->{qp}->{h}; # same as cgit
+ if (defined $tip && $tip eq '') {
+ delete $ctx->{qp}->{h};
+ undef($tip);
+ }
my $nb = $self->{summary_branches} + 1;
my $nt = $self->{summary_tags} + 1;
my $nl = $self->{summary_log} + 1;
- my $qsp = PublicInbox::Qspawn->new([qw(/bin/sh -c),
+
+ my @cmd = (qw(/bin/sh -c),
"$EACH_REF --count=$nb refs/heads; echo && " .
"$EACH_REF --count=$nt refs/tags; echo && " .
- "git log -$nl --pretty=format:'%d %H %h %cs %s' --" ],
+ qq(git log -$nl --pretty=format:'%d %H %h %cs %s' "\$@" --));
+ push @cmd, '--', $tip if defined($tip);
+ my $qsp = PublicInbox::Qspawn->new(\@cmd,
{ GIT_DIR => $ctx->{git}->{git_dir} });
$qsp->{qsp_err} = \($ctx->{-qsp_err} = '');
- my @try = qw(HEAD:README HEAD:README.md); # TODO: configurable
+ $tip //= 'HEAD';
+ my @try = ("$tip:README", "$tip:README.md"); # TODO: configurable
$ctx->{-nr_readme_tries} = [ @try ];
- $ctx->{git}->cat_async($_, \&set_readme, $ctx) for @try;
- if ($ctx->{env}->{'pi-httpd.async'}) {
- PublicInbox::GitAsyncCat::watch_cat($ctx->{git});
- } else { # synchronous
- $ctx->{git}->cat_async_wait;
- }
+ PublicInbox::ViewVCS::do_cat_async($ctx, \&set_readme, @try);
sub { # $_[0] => PublicInbox::HTTP::{Identity,Chunked}
$ctx->{env}->{'qspawn.wcb'} = $_[0];
$qsp->psgi_qx($ctx->{env}, undef, \&capture_refs, $ctx);
@@ -173,25 +219,28 @@ sub srv { # endpoint called by PublicInbox::WWW
my $path_info = $ctx->{env}->{PATH_INFO};
my $git;
# handle clone requests
- if ($path_info =~ m!\A/(.+?)/($PublicInbox::GitHTTPBackend::ANY)\z!x) {
- $git = $self->{"\0$1"} and return
+ my $cr = $self->{pi_cfg}->{-code_repos};
+ if ($path_info =~ m!\A/(.+?)/($PublicInbox::GitHTTPBackend::ANY)\z!x and
+ ($git = $cr->{$1})) {
PublicInbox::GitHTTPBackend::serve($ctx->{env},$git,$2);
- }
- $path_info =~ m!\A/(.+?)/\z! and
- ($ctx->{git} = $self->{"\0$1"}) and return summary($self, $ctx);
- $path_info =~ m!\A/(.+?)/([a-f0-9]+)/s/\z! and
- ($ctx->{git} = $self->{"\0$1"}) and
- return PublicInbox::ViewVCS::show($ctx, $2);
-
- # snapshots:
- if ($path_info =~ m!\A/(.+?)/snapshot/([^/]+)\z! and
- ($ctx->{git} = $self->{"\0$1"})) {
- require PublicInbox::RepoSnapshot;
- return PublicInbox::RepoSnapshot::srv($ctx, $2) // r(404);
- }
-
- # enforce trailing slash:
- if ($path_info =~ m!\A/(.+?)\z! and ($git = $self->{"\0$1"})) {
+ } elsif ($path_info =~ m!\A/(.+?)/\z! and ($ctx->{git} = $cr->{$1})) {
+ summary($self, $ctx)
+ } elsif ($path_info =~ m!\A/(.+?)/([a-f0-9]+)/s/([^/]+)?\z! and
+ ($ctx->{git} = $cr->{$1})) {
+ $ctx->{lh} = $self->{log_fh};
+ PublicInbox::ViewVCS::show($ctx, $2, $3);
+ } elsif ($path_info =~ m!\A/(.+?)/tree/(.*)\z! and
+ ($ctx->{git} = $cr->{$1})) {
+ $ctx->{lh} = $self->{log_fh};
+ PublicInbox::RepoTree::srv_tree($ctx, $2) // r(404);
+ } elsif ($path_info =~ m!\A/(.+?)/snapshot/([^/]+)\z! and
+ ($ctx->{git} = $cr->{$1})) {
+ $ctx->{wcr} = $self;
+ PublicInbox::RepoSnapshot::srv($ctx, $2) // r(404);
+ } elsif ($path_info =~ m!\A/(.+?)/atom/(.*)\z! and
+ ($ctx->{git} = $cr->{$1})) {
+ PublicInbox::RepoAtom::srv_atom($ctx, $2) // r(404);
+ } elsif ($path_info =~ m!\A/(.+?)\z! and ($git = $cr->{$1})) {
my $qs = $ctx->{env}->{QUERY_STRING};
my $url = $git->base_url($ctx->{env});
$url .= "?$qs" if $qs ne '';