package PublicInbox::RepoBase;
use strict;
use warnings;
-require PublicInbox::RepoGitQuery;
use PublicInbox::Hval;
our %MIME_TYPE_WHITELIST = ('application/pdf' => 1);
$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>);
+ push @l, qq($s -> <a\nhref="${rel}log/$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>);
+ push @l, qq(<a\nhref="${rel}tag/$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>);
+ push @l, qq(<a\nhref="${rel}log/$r">$h</a>);
}
}
@l;
$$dst .= '</published>';
$$dst .= qq(<link\nrel="alternate"\ntype="text/html"\nhref=");
$$dst .= $url;
- $$dst .= '/commit?id=';
+ $$dst .= '/commit/';
my $H = $hdr->{H};
$$dst .= $H;
my $rel = $req->{relcmd};
my $repo_info = $req->{repo_info};
my $title = join('/', $repo_info->{repo}, @{$req->{extra}});
- $title = utf8_html("$title, branch $req->{q}->{h}");
+ $title = utf8_html("$title, $req->{-tip}");
my $url = repo_root_url($self, $req);
my $hdr = {};
my $subtitle = $repo_info->desc_html;
qq(<title>$title</title>) .
qq(<subtitle>$subtitle</subtitle>) .
qq(<link\nrel="alternate"\ntype="text/html"\nhref="$url"\n/>);
- my ($plinks, $id, $ai);
+ my ($plinks, $ai);
my $end = '';
my $blines;
sub {
my $git = $repo_info->{git};
my $env = $req->{env};
- my $q =$req->{'q'} = PublicInbox::RepoGitQuery->new($env);
- my $h = $q->{h};
+ my $tip = $req->{-tip};
my $read_log = sub {
my $cmd = $git->cmd(qw(log --no-notes --no-color
--abbrev-commit), $git->abbrev,
- $ATOM_FMT, "-$max", $h, '--');
+ $ATOM_FMT, "-$max", $tip, '--');
my $expath = $req->{expath};
push @$cmd, $expath if $expath ne '';
my $rdr = { 2 => $git->err_begin };
sub {
$env->{'qspawn.response'} = $_[0];
- return $read_log->() if $h ne '';
+ return $read_log->() if $tip ne '';
my $cmd = $git->cmd(qw(symbolic-ref --short HEAD));
my $rdr = { 2 => $git->err_begin };
my $qsp = PublicInbox::Qspawn->new($cmd, undef, undef, $rdr);
$qsp->psgi_qx($env, undef, sub {
- chomp($h = ${$_[0]});
+ chomp($tip = ${$_[0]});
$read_log->();
})
}
sub call_git_blob {
my ($self, $req) = @_;
my $git = $req->{repo_info}->{git};
- my $q = PublicInbox::RepoGitQuery->new($req->{env});
- my $id = $q->{id};
- $id eq '' and $id = 'HEAD';
- $id .= ":$req->{expath}";
+ my $id = $req->{-tip} . ':' . $req->{expath};
my ($cat, $hex, $type, $size) = $git->cat_file_begin($id);
return unless defined $cat;
my @p = split(' ', $p);
my $rel = $req->{relcmd};
- my $q = $req->{'q'};
- my $qs = $req->{qs} = $q->qs(id => $h);
my $x = $self->html_start($req, $s) . "\n" .
- qq( commit $H (<a\nhref="${rel}patch$qs">patch</a>)\n) .
- qq( tree <a\nrel=nofollow\nhref="${rel}tree?id=$h">$t</a>);
+ qq( commit $H (<a\nhref="${rel}patch/$h">patch</a>)\n) .
+ qq( tree <a\nrel=nofollow\nhref="${rel}tree/$h">$t</a>);
my $git = $req->{repo_info}->{git};
# extra show path information, if any
my $e = PublicInbox::Hval->utf8($_, join('/', @t));
$ep = $e->as_path;
my $eh = $e->as_html;
- $ep = "${rel}tree/$ep?id=$h";
+ $ep = "${rel}tree/$ep/$h";
qq(<a\nrel=nofollow\nhref="$ep">$eh</a>);
} @$extra);
$path = "/$ep";
my $np = scalar @p;
if ($np == 1) {
my $p = $p[0];
- $x .= git_parent_line(' parent', $p, $q, $git, $rel, $path);
+ $x .= git_parent_line(' parent', $p, $git, $rel);
} elsif ($np > 1) {
$req->{mhelp} = CC_MERGE;
- my @common = ($q, $git, $rel, $path);
+ my @common = ($git, $rel);
my @t = @p;
my $p = shift @t;
$x .= git_parent_line(' parents', $p, @common);
sub call_git_commit { # RepoBase calls this
my ($self, $req) = @_;
my $env = $req->{env};
- my $q = PublicInbox::RepoGitQuery->new($env);
- my $id = $q->{id};
- $id eq '' and $id = 'HEAD';
+ my $tip = $req->{-tip};
my $expath = $req->{expath};
if ($expath ne '') {
my $relup = join('', map { '../' } @{$req->{extra}});
- my $qs = $q->qs;
- return $self->r(301, $req, "$relup$qs#".to_attr($expath));
+ return $self->r(301, $req, "$relup#".to_attr($expath));
}
my $git = $req->{repo_info}->{git};
my $cmd = $git->cmd(qw(show -z --numstat -p --encoding=UTF-8
--no-notes --no-color -c),
- $git->abbrev, GIT_FMT, $id, '--');
+ $git->abbrev, GIT_FMT, $tip, '--');
my $rdr = { 2 => $git->err_begin };
my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr);
- $req->{'q'} = $q;
$env->{'qspawn.quiet'} = 1;
$qsp->psgi_return($env, undef, sub { # parse header
my ($r, $bref) = @_;
my $try = 'try';
$x = "<html><head><title>$x</title></head><body><pre><b>$x</b>\n\n";
- my $qs = $req->{'q'}->qs(id => '');
- $x .= "<a\nhref=\"$pfx$qs\">$try the latest commit in HEAD</a>\n";
+ $x .= "<a\nhref=\"$pfx\">$try the latest commit in HEAD</a>\n";
$x .= '</pre></body>';
[404, ['Content-Type'=>'text/html'], [ $x ]];
# FIXME: horrifically expensive...
sub git_parent_line {
- my ($pfx, $p, $q, $git, $rel, $path) = @_;
- my $qs = $q->qs(id => $p);
+ my ($pfx, $p, $git, $rel) = @_;
my $t = git_commit_title($git, $p);
$t = defined $t ? utf8_html($t) : '';
- $pfx . qq( <a\nid=P\nhref="${rel}commit$path$qs">$p</a> $t\n);
+ $pfx . qq( <a\nid=P\nhref="${rel}commit/$p">$p</a> $t\n);
}
# do not break anchor links if the combined diff doesn't show changes:
qq( See the <a\nhref="#P">parents</a>, ) .
"or view final state(s) below:\n\n";
my $rel = $req->{relcmd};
- my $qs = $req->{qs};
foreach my $anchor (@unchanged) {
my $fn = $anchors->{$anchor};
my $p = PublicInbox::Hval->utf8(git_unquote($fn));
$p = $p->as_path;
$fn = utf8_html($fn);
$$dst .= qq(\t<a\nrel=nofollow);
- $$dst .= qq(\nid="$anchor"\nhref="${rel}tree/$p$qs">);
+ $$dst .= qq(\nid="$anchor"\nhref="${rel}tree/$p">);
$$dst .= "$fn</a>\n";
}
}
sub call_git_diff {
my ($self, $req) = @_;
+ my ($id, $id2) = split(/\.\./, $req->{h});
my $env = $req->{env};
- my $q = PublicInbox::RepoGitQuery->new($env);
- my $id = $q->{id};
- my $id2 = $q->{id2};
-
my $git = $req->{repo_info}->{git};
my $cmd = $git->cmd(qw(diff-tree -z --numstat -p --encoding=UTF-8
--no-color -M -B -D -r), $id2, $id, '--');
$na = defined $na ? "#n$na" : '';
my $p = $req->{p}->[0];
$rv .= qq(<a\nrel=nofollow);
- $rv .= qq(\nhref="${rel}tree/$req->{path_a}?id=$p$na">);
+ $rv .= qq(\nhref="${rel}tree/$p/$req->{path_a}$na">);
$rv .= "$ca</a>";
}
$rv .= ' ';
if (defined($nb) && $nb == 0) { # deleted file
$rv .= $cb;
} else {
- my $h = $req->{h};
$nb = defined $nb ? "#n$nb" : '';
$rv .= qq(<a\nrel=nofollow);
- $rv .= qq(\nhref="${rel}tree/$req->{path_b}?id=$h$nb">);
+ $rv .= qq(\nhref="${rel}tree/$req->{-tip}/$req->{path_b}$nb">);
$rv .= "$cb</a>";
}
$rv . ' @@' . utf8_html($ctx);
} else {
my $h = $req->{h};
$rv .= qq( <a\nrel=nofollow);
- $rv .= qq(\nhref="${rel}tree/$path?id=$h#n$n">$last</a>);
+ $rv .= qq(\nhref="${rel}tree/$h/$path#n$n">$last</a>);
}
$rv .= " $at" . utf8_html($ctx);
}
sub flush_log_hdr ($$$) {
my ($req, $dst, $hdr) = @_;
- my $rel = $req->{relcmd};
+ my $lpfx = $req->{lpfx};
my $seen = $req->{seen};
$$dst .= '<hr /><pre>' if scalar keys %$seen;
my $id = $hdr->{h};
$seen->{$id} = 1;
$$dst .= qq(<a\nid=p$id\n);
- $$dst .= qq(href="${rel}commit?id=$id"><b>);
+ $$dst .= qq(href="${lpfx}commit/$id"><b>);
$$dst .= utf8_html($hdr->{'s'}); # FIXME may still OOM
$$dst .= '</b></a>';
my $D = $hdr->{D}; # FIXME: thousands of decorations may OOM us
if ($D ne '') {
- $$dst .= ' (' . join(', ', git_dec_links($rel, $D)) . ')';
+ $$dst .= ' (' . join(', ', git_dec_links($lpfx, $D)) . ')';
}
my @p = split(/ /, $hdr->{p});
push @{$req->{parents}}, @p;
my $np = 0;
my $seen = $req->{seen};
my $git = $req->{repo_info}->{git};
- my $rel = $req->{relcmd};
+ my $lpfx = $req->{lpfx};
foreach my $p (@{$req->{parents}}) {
next if $seen->{$p};
$seen->{$p} = ++$np;
my $s = git_commit_title($git, $p);
- $m .= qq(\n<a\nid=p$p\nhref="?h=$p">$p</a>\t);
+ $m .= qq(\n<a\nid=p$p\nhref="$p">$p</a>\t);
$s = defined($s) ? utf8_html($s) : '';
- $m .= qq(<a\nhref="${rel}commit?id=$p">$s</a>);
+ $m .= qq(<a\nhref="${lpfx}commit/$p">$s</a>);
}
if ($np == 0) {
$$dst .= "No commits follow";
my ($self, $req) = @_;
my $repo_info = $req->{repo_info};
my $max = $repo_info->{max_commit_count} || 50;
+ my $h = $req->{h};
$max = int($max);
$max = 50 if $max == 0;
my $env = $req->{env};
- my $q = $req->{'q'} = PublicInbox::RepoGitQuery->new($env);
- my $h = $q->{h};
- $h eq '' and $h = 'HEAD';
my $git = $repo_info->{git};
my $cmd = $git->cmd(qw(log --no-notes --no-color --abbrev-commit),
- $git->abbrev, $LOG_FMT, "-$max", $h, '--');
+ $git->abbrev, $LOG_FMT, "-$max",
+ $req->{-tip}, '--');
my $rdr = { 2 => $git->err_begin };
- my $title = "log: $repo_info->{repo} (" . utf8_html($h). ')';
+ my $title = "log: $repo_info->{repo}";
+ if (defined $h) {
+ $title .= ' ('. utf8_html($h). ')';
+ $req->{lpfx} = $req->{relcmd};
+ } else {
+ $req->{lpfx} = $req->{relcmd}.$req->{-tip};
+ }
$req->{lhtml} = $self->html_start($req, $title) . "\n\n";
my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr);
$qsp->psgi_return($env, undef, sub {
my ($self, $req) = @_;
my $git = $req->{repo_info}->{git};
my $env = $req->{env};
- my $q = PublicInbox::RepoGitQuery->new($env);
- my $id = $q->{id};
- $id =~ /\A[\w-]+([~\^][~\^\d])*\z/ or $id = 'HEAD';
+ my $tip = $req->{-tip};
+ $tip =~ /\A[\w-]+([~\^][~\^\d])*\z/;
# limit scope, don't take extra args to avoid wasting server
# resources buffering:
- my $range = "$id~1..$id^0";
+ my $range = "$tip~1..$tip^0";
my $cmd = $git->cmd(@CMD, $sig." $range", $range, '--');
my $expath = $req->{expath};
push @$cmd, $expath if $expath ne '';
sub call_git_plain {
my ($self, $req) = @_;
my $git = $req->{repo_info}->{git};
- my $q = PublicInbox::RepoGitQuery->new($req->{env});
- my $id = $q->{id};
- $id eq '' and $id = 'HEAD';
- $id .= ":$req->{expath}";
+ my $id = $req->{-tip} . ':' . $req->{expath};
my ($cat, $hex, $type, $size) = $git->cat_file_begin($id);
return unless defined $cat;
use warnings;
use PublicInbox::Hval;
use URI::Escape qw(uri_unescape);
-my @KNOWN_PARAMS = qw(id id2 h ofs);
+my @KNOWN_PARAMS = qw(id id2 ofs);
sub new {
my ($class, $env) = @_;
sub call_git_snapshot ($$) { # invoked by PublicInbox::RepoBase::call
my ($self, $req) = @_;
- my @extra = @{$req->{extra}};
- my $ref = shift @extra;
- return $self->r(404) if (!defined $ref) || scalar(@extra);
+ my $ref = $req->{-tip};
my $orig_fn = $ref;
# just in case git changes refname rules, don't allow wonky filenames
my $sref;
if ($type eq 'tag') {
$h = "<b>$h</b>";
- $sref = $ref = $rel . 'tag?h=' . $ref;
+ $sref = $ref = $rel . 'tag/' . $ref;
} elsif ($type eq 'commit') {
- $sref = $rel . 'commit?h=' . $ref;
- $ref = $rel . 'log?h=' . $ref;
+ $sref = $rel . 'commit/' . $ref;
+ $ref = $rel . 'log/' . $ref;
} else {
# no point in wasting code to support tagged
# trees/blobs...
foreach my $r (@$readme) {
my $doc = $git->cat_file('HEAD:'.$r);
defined $doc or next;
- $fh->write('<pre>' . readme_path_links($rel, $r) .
+ $fh->write('<pre>' . readme_path_links($req, $rel, $r) .
" (HEAD)\n\n" . utf8_html($$doc) . '</pre>');
}
$fh->write('</body></html>');
}
sub readme_path_links {
- my ($rel, $readme) = @_;
+ my ($req, $rel, $readme) = @_;
my @path = split(m!/+!, $readme);
- my $s = "tree <a\nhref=\"${rel}tree\">root</a>/";
+ my $s = "tree <a\nhref=\"${rel}tree/$req->{-tip}\">root</a>/";
my @t;
$s .= join('/', (map {
push @t, $_;
my $e = PublicInbox::Hval->utf8($_, join('/', @t));
my $ep = $e->as_path;
my $eh = $e->as_html;
- $e = "<a\nhref=\"${rel}tree/$ep\">$eh</a>";
+ $e = "<a\nhref=\"${rel}tree/$req->{-tip}/$ep\">$eh</a>";
# bold the last one
scalar(@t) == scalar(@path) ? "<b>$e</b>" : $e;
} @path));
sub call_git_tag {
my ($self, $req) = @_;
- my $q = PublicInbox::RepoGitQuery->new($req->{env});
- my $h = $q->{h};
- $h eq '' and return git_tag_list($self, $req);
+ my $h = $req->{h};
+ defined $h or return git_tag_list($self, $req);
sub {
my ($res) = @_;
git_tag_show($self, $req, $h, $res);
my $label = "$type $obj";
my $cmd = $cmd_map{$type} || 'show';
my $rel = $req->{relcmd};
- my $obj_link = qq(<a\nhref="$rel$cmd?id=$obj">$label</a>);
+ my $obj_link = qq(<a\nhref="$rel$cmd/$obj">$label</a>);
$head = $h . "\n\n tag <b>$tag</b>\nobject $obj_link\n";
if (my $tagger = $h{tagger}) {
$head .= 'tagger ' . join("\t", creator_split($tagger)) . "\n";
my $h = $ref->as_html;
$ref = $ref->as_href;
$dst .= qq(<tr><td><tt>) .
- qq(<a\nhref="?h=$ref"><b>$h</b></a>) .
+ qq(<a\nhref="tag/$ref"><b>$h</b></a>) .
qq(</tt></td><td><tt>$date</tt></td><td><tt>) .
utf8_html($s) . '</tt></td></tr>';
}
my $rel = $req->{relcmd};
my $label = "$type $hex";
my $cmd = $cmd_map{$type} || 'show';
- my $obj_link = qq(<a\nhref="$rel$cmd?id=$hex">$label</a>\n);
+ my $obj_link = qq(<a\nhref="$rel$cmd/$hex">$label</a>\n);
$fh->write($self->html_start($req,
"$repo_info->{repo}: ref: $h") .
my ($self, $req) = @_;
my @extra = @{$req->{extra}};
my $git = $req->{repo_info}->{git};
- my $q = PublicInbox::RepoGitQuery->new($req->{env});
- my $id = $q->{id};
- if ($id eq '') {
- chomp($id = $git->qx(qw(rev-parse --short=10 HEAD)));
- $q->{id} = $id;
- }
-
- my $obj = "$id:$req->{expath}";
+ my $obj = "$req->{-tip}:$req->{expath}";
my ($hex, $type, $size) = $git->check($obj);
unless (defined($type)) {
if ($type eq 'tree') {
$opts->{noindex} = 1;
$req->{thtml} = $self->html_start($req, $title, $opts) . "\n";
- git_tree_show($req, $hex, $q);
+ git_tree_show($req, $hex);
} elsif ($type eq 'blob') {
sub {
my $res = $_[0];
['Content-Type','text/html; charset=UTF-8']]);
$fh->write($self->html_start($req, $title, $opts) .
"\n");
- git_blob_show($req, $fh, $git, $hex, $q);
+ git_blob_show($req, $fh, $git, $hex);
$fh->write('</body></html>');
$fh->close;
}
}
sub cur_path {
- my ($req, $q) = @_;
- my $qs = $q->qs;
+ my ($req) = @_;
my @ex = @{$req->{extra}} or return '<b>root</b>';
my $s;
+ my $tip = $req->{-tip};
my $rel = $req->{relcmd};
# avoid relative paths, here, we don't want to propagate
# trailing-slash URLs although we tolerate them
- $s = "<a\nhref=\"${rel}tree$qs\">root</a>/";
+ $s = "<a\nhref=\"${rel}tree/$tip\">root</a>/";
my $cur = pop @ex;
my @t;
$s .= join('/', (map {
my $e = PublicInbox::Hval->utf8($_, join('/', @t));
my $ep = $e->as_path;
my $eh = $e->as_html;
- "<a\nhref=\"${rel}tree/$ep$qs\">$eh</a>";
+ "<a\nhref=\"${rel}tree/$tip/$ep\">$eh</a>";
} @ex), '<b>'.utf8_html($cur).'</b>');
}
sub git_blob_show {
- my ($req, $fh, $git, $hex, $q) = @_;
+ my ($req, $fh, $git, $hex) = @_;
# ref: buffer_is_binary in git.git
my $to_read = 8000; # git uses this size to detect binary files
my $text_p;
my $n = 0;
+ my $tip = $req->{-tip};
my $rel = $req->{relcmd};
- my $plain = join('/', "${rel}plain", @{$req->{extra}});
- $plain = PublicInbox::Hval->utf8($plain)->as_path . $q->qs;
- my $t = cur_path($req, $q);
- my $h = qq{\npath: $t\n\nblob $hex};
+ my $plain = join('/', "${rel}plain/$tip", @{$req->{extra}});
+ $plain = PublicInbox::Hval->utf8($plain)->as_path;
+ my $t = cur_path($req);
+ my $s = qq{\npath: $t\n\nblob $hex};
my $end = '';
$git->cat_file($hex, sub {
my ($cat, $left) = @_; # $$left == $size
- $h .= qq{\t$$left bytes (<a\nhref="$plain">raw</a>)};
+ $s .= qq{\t$$left bytes (<a\nhref="$plain">raw</a>)};
$to_read = $$left if $to_read > $$left;
my $r = read($cat, my $buf, $to_read);
return unless defined($r) && $r > 0;
$$left -= $r;
if (index($buf, "\0") >= 0) {
- $fh->write("$h\n$BINARY_MSG</pre>");
+ $fh->write("$s\n$BINARY_MSG</pre>");
return;
}
- $fh->write($h."</pre><hr/><table\nsummary=blob><tr><td><pre>");
+ $fh->write($s."</pre><hr/><table\nsummary=blob><tr><td><pre>");
$text_p = 1;
while (1) {
my ($req) = @_;
my @lines;
my $buf = '';
- my $qs = $req->{qs};
my $pfx = $req->{tpfx};
my $end;
sub {
# 'plain' and 'log' links intentionally omitted
# for brevity and speed
$dst .= qq($m\t).
- qq($s\t<a\nhref="$pfx$ref$qs">$path</a>\n);
+ qq($s\t<a\nhref="$pfx/$ref">$path</a>\n);
}
$dst;
}
}
sub git_tree_show {
- my ($req, $hex, $q) = @_;
+ my ($req, $hex) = @_;
my $git = $req->{repo_info}->{git};
my $cmd = $git->cmd(qw(ls-tree -l -z), $git->abbrev, $hex);
my $rdr = { 2 => $git->err_begin };
my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr);
- my $t = cur_path($req, $q);
+ my $t = cur_path($req);
my $pfx;
$req->{thtml} .= "\npath: $t\n\n<b>mode\tsize\tname</b>\n";
- $req->{qs} = $q->qs;
if ($req->{tslash}) {
- $pfx = './';
+ $pfx = '../';
} elsif (defined(my $last = $req->{extra}->[-1])) {
- $pfx = PublicInbox::Hval->utf8($last)->as_path . '/';
+ $pfx = PublicInbox::Hval->utf8($last)->as_path;
+ } elsif (defined $req->{h}) {
+ $pfx = $req->{-tip};
} else {
- $pfx = 'tree/';
+ $pfx = 'tree/' . $req->{-tip};
}
$req->{tpfx} = $pfx;
my $env = $req->{env};
my $method = $env->{REQUEST_METHOD};
return r(405, 'Method Not Allowed') if ($method !~ /\AGET|HEAD|POST\z/);
- # URL syntax: / repo [ / cmd [ / path ] ]
+ # URL syntax: / repo [ / cmd [ / head [ / path ] ] ]
# cmd: log | commit | diff | tree | view | blob | snapshot
# repo and path (@extra) may both contain '/'
my $path_info = $env->{PATH_INFO};
my $vcs_lc = $repo_info->{vcs};
my $vcs = $VCS{$vcs_lc} or return r404();
my $mod;
+ my $h;
if (defined $cmd && length $cmd) {
$mod = $CMD{$cmd};
- unless ($mod) {
+ if ($mod) {
+ $h = shift @extra if @extra;
+ } else {
unshift @extra, $cmd;
$mod = 'Fallback';
}
- $req->{relcmd} = '../' x scalar(@extra);
+ $req->{relcmd} = '../' x (scalar(@extra) + 1);
} else {
$mod = 'Summary';
$cmd = 'summary';
pop @extra;
++$tslash;
}
-
+ $req->{h} = $h;
+ $req->{-tip} = defined $h ? $h : 'HEAD';
return no_tslash($env) if ($tslash && $NO_TSLASH{$mod});
$req->{tslash} = $tslash;
like($body, qr!<pre\s*[^>]+>\* header:\n add header</pre>!,
'body wrapped in <pre>');
- $res = $cb->(GET($req . '/'));
- my $sl = dechunk($res);
- is($body, $sl, 'slash returned identical to non-trailing slash');
-
- $res = $cb->(GET($req . '/foo.txt'));
+ $res = $cb->(GET($req . '/master/foo.txt'));
is($res->code, 200, 'got 200');
$body = dechunk($res);
like($body, qr{\bhref="http://[^/]+/test\.git/}, 'hrefs OK');
my ($cb) = @_;
my $path = '/path/to/something';
my $req = 'http://example.com/test.git/commit';
- my $res = $cb->(GET($req . $path));
- is($res->code, 301, 'got 301 to anchor');
- is($res->header('Location'), "$req#path:to:something",
- 'redirected to anchor from path');
-
- my $q = '?id=deadbeef';
- $res = $cb->(GET($req . $path . $q));
- is($res->code, 301, 'got 301 with query string');
- is($res->header('Location'), "$req$q#path:to:something",
- 'redirected to anchor from path with query');
+ my $res;
$res = $cb->(GET($req));
is($res->code, 200, 'got proper 200 response for default');
my $body = dechunk($res);
like($body, qr!</html>\z!, 'response body finished');
-
- $res = $cb->(GET($req.$q));
- is($res->code, 404, 'got 404 response for bad id');
});
done_testing();
test_psgi($test->{app}, sub {
my ($cb) = @_;
- my $req = 'http://example.com/test.git/plain/dir';
+ my $req = 'http://example.com/test.git/plain/master/dir';
my $res = $cb->(GET($req));
is(200, $res->code, 'got 200 response from dir');
my $noslash_body = dechunk($res);
- like($noslash_body, qr{href="dir/dur">dur</a></li>}, 'path ok w/o slash');
+ like($noslash_body, qr{href="dir/dur">dur</a></li>},
+ 'path ok w/o slash');
my $slash = $req . '/';
my $r2 = $cb->(GET($slash));
my $slash_body = dechunk($r2);
like($slash_body, qr{href="\./dur\">dur</a></li>}, 'path ok w/ slash');
- $req = 'http://example.com/test.git/plain/foo.txt';
+ $req = 'http://example.com/test.git/plain/master/foo.txt';
my $blob = $cb->(GET($req));
like($blob->header('Content-Type'), qr!\Atext/plain\b!,
'got text/plain blob');
test_psgi($test->{app}, sub {
my ($cb) = @_;
- my $req = 'http://example.com/test.git/tree/dir';
+ my $req = 'http://example.com/test.git/tree/HEAD/dir';
my $res = $cb->(GET($req));
is(200, $res->code, 'got 200 response from dir');
my $noslash_body = dechunk($res);
- like($noslash_body, qr{href="dir/dur\?id=\w+">dur/</a>},
+ like($noslash_body, qr{href="dir/dur">dur/</a>},
'path ok w/o slash');
my $slash = $req . '/';
is(301, $r2->code, 'got 301 response from dir with slash');
is($req, $r2->header('Location'), 'redirected w/o slash');
- $req = 'http://example.com/test.git/tree/foo.txt';
+ $req = 'http://example.com/test.git/tree/master/foo.txt';
my $blob = $cb->(GET($req));
is($blob->header('Content-Type'), 'text/html; charset=UTF-8',
'got text/html blob');