]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/InboxWritable.pm
v2: some changes for ExtSearchIdx compatibility
[public-inbox.git] / lib / PublicInbox / InboxWritable.pm
index 752f199741ab39233723c19308d527e70e2cdd72..e97c7e2d7588b903a0917c803cc8f0cde4b81a91 100644 (file)
@@ -298,4 +298,25 @@ sub warn_ignore_cb {
        }
 }
 
+# v2+ only
+sub git_dir_n { "$_[0]->{inboxdir}/git/$_[1].git" }
+
+# v2+ only
+sub git_dir_latest {
+       my ($self, $max) = @_;
+       $$max = -1;
+       my $pfx = "$self->{inboxdir}/git";
+       return unless -d $pfx;
+       my $latest;
+       opendir my $dh, $pfx or die "opendir $pfx: $!\n";
+       while (defined(my $git_dir = readdir($dh))) {
+               $git_dir =~ m!\A([0-9]+)\.git\z! or next;
+               if ($1 > $$max) {
+                       $$max = $1;
+                       $latest = "$pfx/$git_dir";
+               }
+       }
+       $latest;
+}
+
 1;