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 => 16;
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");
70 writefile('test3.mdwn', $config{srcdir}, $test1);
71 IkiWiki::rcs_add("test3.mdwn");
72 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");
73 IkiWiki::rcs_commit_staged("Added the 4th page", "moo", "Joe User");
75 @changes = IkiWiki::rcs_recentchanges(4);
78 is($changes[0]{pages}[0]{"page"}, "test4.mdwn");
80 ok(mkdir($config{srcdir}."/newdir"));
81 IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn");
82 IkiWiki::rcs_commit_staged("Added the 5th page", "moo", "Joe User");
84 @changes = IkiWiki::rcs_recentchanges(4);
87 is($changes[0]{pages}[0]{"page"}, "newdir/test5.mdwn");
89 IkiWiki::rcs_remove("newdir/test5.mdwn");
90 IkiWiki::rcs_commit_staged("Remove the 5th page", "moo", "Joe User");