summaryrefslogtreecommitdiff
path: root/t/lib/t/Setup.pm
blob: d92b2889b61452ea70f768a8a2b02260ba5c294b (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
package t::Setup;

use 5.028;
use strict;
use warnings;

use Exporter 'import';
use File::Slurp;
use File::Temp qw(tempdir);
use Git::Wrapper;
use File::Spec::Functions qw(catfile);

our @EXPORT = qw( with_temp_annex );

sub with_temp_annex (&) {
    my $temp = tempdir CLEANUP => 1;
    my $git = Git::Wrapper->new($temp);
    $git->init;
    $git->annex("init");
    write_file catfile($temp, "foo"), "my cool big file\n";
    $git->annex(qw(add foo));
    $git->commit({message => "add"});
    &{$_[0]}($temp);
}

1;