about summary refs log tree commit homepage
path: root/public-inbox-index
blob: 1104bbc8238eeaac4599300afa3e7825c91f837b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl -w
# Copyright (C) 2015, all contributors (git clone git://80x24.org/public-inbox)
# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
# Basic tool to create a Xapian search index for a git repository
# configured for public-inbox.
# Usage with libeatmydata <https://www.flamingspork.com/projects/libeatmydata/>
# highly recommended: eatmydata public-inbox-index GIT_DIR

use strict;
use warnings;
my $usage = "public-inbox-index GIT_DIR";
use PublicInbox::Config;
eval { require PublicInbox::Search };
if ($@) {
	print STDERR "Search::Xapian required for $0\n";
	exit 1;
}

sub usage { print STDERR "Usage: $usage\n"; exit 1 }
usage() unless @ARGV;

foreach my $dir (@ARGV) {
	index_dir($dir);
}

sub index_dir {
	my ($git_dir) = @_;
	-d $git_dir or die "$git_dir does not appear to be a git repository\n";
	my $s = PublicInbox::Search->new($git_dir, 1);
	$s->index_sync;
}