Help language development. Donate to The Perl Foundation

LibGit2 cpan:CTILMES last updated on 2020-08-18

use Test;
use File::Temp;
use LibGit2;

plan 15;

my $testdir = tempdir;

isa-ok my $repo = Git::Repository.init($testdir), Git::Repository, 'init';

$repo.commit(:root, message => 'Initial root commit');

for <a b c>
    $testdir.IO.child("{$_}file").spurt("This is some content for file $_.\n");

$repo.commit(message => 'Add afile');


isa-ok my $status = $repo.status-file('afile'), Git::Status::File,
	'status-file afile';

is $, True, 'is-current';
is $, False, 'is not ignored';
is $, False, 'is not conflicted';

isa-ok $status = $repo.status-file('bfile'), Git::Status::File,
	'status-file bfile';

is $, False, 'is not current';
is $, True, 'is index new';
is $, False, 'is not workdir new';

isa-ok $status = $repo.status-file('cfile'), Git::Status::File,
	'status-file cfile';

is $, False, 'is not current';
is $, False, 'is not index new';
is $, True, 'is workdir new';

for $repo.status-each
    ok .path ~~ /(b|c) file/, 'path';