8 $dir="/tmp/ikiwiki-test-git.$$";
12 if (! -x $git || ! mkdir($dir) || ! mkdir($gitrepo)) {
14 use Test::More skip_all => "git not available or could not make test dirs"
18 use Test::More tests => 11;
20 BEGIN { use_ok("IkiWiki"); }
22 %config=IkiWiki::defaultconfig();
24 $config{srcdir} = "$dir/src";
25 IkiWiki::checkconfig();
27 system "cd $gitrepo && git init >/dev/null 2>&1";
28 system "cd $gitrepo && echo dummy > dummy; git add . >/dev/null 2>&1";
29 system "cd $gitrepo && git commit -m Initial >/dev/null 2>&1";
30 system "git clone -l -s $gitrepo $config{srcdir} >/dev/null 2>&1";
33 @changes = IkiWiki::rcs_recentchanges(3);
35 is($#changes, 0); # counts for dummy commit during repo creation
36 is($changes[0]{message}[0]{"line"}, "Initial");
37 is($changes[0]{pages}[0]{"page"}, "dummy");
40 my $test1 = readfile("t/test1.mdwn");
41 writefile('test1.mdwn', $config{srcdir}, $test1);
42 IkiWiki::rcs_add("test1.mdwn");
43 IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo");
45 @changes = IkiWiki::rcs_recentchanges(3);
48 is($changes[0]{message}[0]{"line"}, "Added the first page");
49 is($changes[0]{pages}[0]{"page"}, "test1.mdwn");
52 my $message = "Added the second page";
54 my $test2 = readfile("t/test2.mdwn");
55 writefile('test2.mdwn', $config{srcdir}, $test2);
56 system "cd $config{srcdir}; git add test2.mdwn >/dev/null 2>&1";
57 system "cd $config{srcdir}; git commit -m \"$message\" test2.mdwn >/dev/null 2>&1";
58 system "cd $config{srcdir}; git push origin >/dev/null 2>&1";
60 @changes = IkiWiki::rcs_recentchanges(3);
63 is($changes[0]{message}[0]{"line"}, $message);
64 is($changes[0]{pages}[0]{"page"}, "test2.mdwn");
66 is($changes[1]{pages}[0]{"page"}, "test1.mdwn");