]> Sergey Matveev's repositories - public-inbox.git/commitdiff
manifest: v2 epoch descriptions based on inbox->description
authorEric Wong <e@80x24.org>
Sun, 23 Jun 2019 17:42:05 +0000 (17:42 +0000)
committerEric Wong <e@80x24.org>
Sun, 23 Jun 2019 17:42:29 +0000 (17:42 +0000)
The default $GIT_DIR/description (provided by git.git templates)
isn't very useful for v2 epochs, so use the inbox description
and suffix it with the epoch number if it's otherwise unnamed.

Requested-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
  https://public-inbox.org/meta/20190620190017.GA27175@chatter.i7.local/

lib/PublicInbox/WwwListing.pm
t/www_listing.t

index e052bbffa938ec04f0946c09b109b7df903855e3..1d4029f047ed35a738ed7c75854d374f23ba93c2 100644 (file)
@@ -138,8 +138,8 @@ sub fingerprint ($) {
        $dig->hexdigest;
 }
 
-sub manifest_add ($$;$) {
-       my ($manifest, $ibx, $epoch) = @_;
+sub manifest_add ($$;$$) {
+       my ($manifest, $ibx, $epoch, $default_desc) = @_;
        my $url_path = "/$ibx->{name}";
        my $git_dir = $ibx->{mainrepo};
        if (defined $epoch) {
@@ -155,6 +155,13 @@ sub manifest_add ($$;$) {
        $owner = undef if $owner eq '';
        $desc = 'Unnamed repository' if $desc eq '';
 
+       # templates/hooks--update.sample and git-multimail in git.git
+       # only match "Unnamed repository", not the full contents of
+       # templates/this--description in git.git
+       if ($desc =~ /\AUnnamed repository/) {
+               $desc = "$default_desc [epoch $epoch]" if defined($epoch);
+       }
+
        my $reference;
        chomp(my $alt = try_cat("$git_dir/objects/info/alternates"));
        if ($alt) {
@@ -191,8 +198,9 @@ sub js ($$) {
        my $manifest = { -abs2urlpath => {}, -mtime => 0 };
        for my $ibx (@$list) {
                if (defined(my $max = $ibx->max_git_epoch)) {
+                       my $desc = $ibx->description;
                        for my $epoch (0..$max) {
-                               manifest_add($manifest, $ibx, $epoch);
+                               manifest_add($manifest, $ibx, $epoch, $desc);
                        }
                } else {
                        manifest_add($manifest, $ibx);
index d82a4a4a581345425d06a03bdfbc786a8c44c2c5..e5b797db7f9582c954702ac69d008fa4c453ae8a 100644 (file)
@@ -55,7 +55,12 @@ sub tiny_test {
                $res->{headers}->{'last-modified'},
                'modified field and Last-Modified header match');
 
-       ok($manifest->{'/v2/git/0.git'}, 'v2 epoch appeared');
+       ok(my $v2epoch0 = $manifest->{'/v2/git/0.git'}, 'v2 epoch 0 appeared');
+       like($v2epoch0->{description}, qr/ \[epoch 0\]\z/,
+               'epoch 0 in description');
+       ok(my $v2epoch1 = $manifest->{'/v2/git/1.git'}, 'v2 epoch 1 appeared');
+       like($v2epoch1->{description}, qr/ \[epoch 1\]\z/,
+               'epoch 1 in description');
 }
 
 my $pid;