2 # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
3 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
8 use Ssoma
::GitIndexInfo
;
9 use File
::Temp qw
/tempdir/;
10 my $tmpdir = tempdir
(CLEANUP
=> 1);
11 my $git = Ssoma
::Git
->new("$tmpdir/gittest");
14 ok
(-d
"$tmpdir/gittest", "git repo created");
17 my $v = `GIT_DIR=$tmpdir/gittest git config ssoma.repoversion`;
18 is
(0, $?
, "git config succeeded");
20 is
(1, $v, "ssoma.repoversion is set to 1");
23 is
(0, $git->tmp_git_do(sub { system(qw(git config ssoma.test foo)) }),
24 "setting config works");
26 is
("foo\n", $git->tmp_git_do(sub { `git config ssoma.test` }),
27 "reading config works");
29 $git->tmp_git_do(sub {
31 $git->tmp_index_do(sub {
32 my $gii = Ssoma
::GitIndexInfo
->new;
34 my $sha1 = `echo hello world | git hash-object -w --stdin`;
35 is
(0, $?
, "hashed one object");
38 is
(1, $gii->update(100644, $sha1, 'hello/world'),
39 "add hashed object to index");
42 my $tree = `git write-tree`;
43 is
(0, $?
, "wrote tree out");
46 $commit = `git commit-tree -m 'hi' $tree`;
47 is
(0, $?
, "committed tree");
50 is
(0, system(qw(git update-ref refs/heads/master), $commit),
56 is
($git->mid2path("<hello world>"),
57 $git->mid2path("\t<hello world>\t"),
58 "mid2path ignores leading/trailing whitespace");