summaryrefslogtreecommitdiff
path: root/bin/annex-checksum-reinject
blob: 39974530058689bee181e7d05e7ad503b8d8b31b (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
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env perl

# Copyright (C) 2019 Sean Whitton
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

use 5.028;
use strict;
use warnings;

use DBD::SQLite;
use Git::Wrapper;
use Try::Tiny;
use File::Spec::Functions qw(catfile);

my $git = Git::Wrapper->new('.');
try {
    $git->rev_parse({ git_dir => 1 });
}
catch {
    die "pwd doesn't look like a git repository ..\n";
};
my ($annex_dir) = $git->rev_parse({ git_path => 1 }, 'annex');
my $dbh
  = DBI->connect(
    "dbi:SQLite:dbname=" . catfile($annex_dir, "checksum-reinject"),
    "", "");

# TODO now build the database, but only if git-annex branch has
# changed since database was last edited?