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::loadplugins();
26 IkiWiki::checkconfig();
28 system "cd $gitrepo && git init >/dev/null 2>&1";
29 system "cd $gitrepo && echo dummy > dummy; git add . >/dev/null 2>&1";
30 system "cd $gitrepo && git commit -m Initial >/dev/null 2>&1";
31 system "git clone -l -s $gitrepo $config{srcdir} >/dev/null 2>&1";
34 @changes = IkiWiki::rcs_recentchanges(3);
36 is($#changes, 0); # counts for dummy commit during repo creation
37 is($changes[0]{message}[0]{"line"}, "Initial");
38 is($changes[0]{pages}[0]{"page"}, "dummy");
41 my $test1 = readfile("t/test1.mdwn");
42 writefile('test1.mdwn', $config{srcdir}, $test1);
43 IkiWiki::rcs_add("test1.mdwn");
44 IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo");
46 @changes = IkiWiki::rcs_recentchanges(3);
49 is($changes[0]{message}[0]{"line"}, "Added the first page");
50 is($changes[0]{pages}[0]{"page"}, "test1");
53 my $message = "Added the second page";
55 my $test2 = readfile("t/test2.mdwn");
56 writefile('test2.mdwn', $config{srcdir}, $test2);
57 system "cd $config{srcdir}; git add test2.mdwn >/dev/null 2>&1";
58 system "cd $config{srcdir}; git commit -m \"$message\" test2.mdwn >/dev/null 2>&1";
59 system "cd $config{srcdir}; git push origin >/dev/null 2>&1";
61 @changes = IkiWiki::rcs_recentchanges(3);
64 is($changes[0]{message}[0]{"line"}, $message);
65 is($changes[0]{pages}[0]{"page"}, "test2");
67 is($changes[1]{pages}[0]{"page"}, "test1");
71 writefile('test3.mdwn', $config{srcdir}, $test1);
72 IkiWiki::rcs_add("test3.mdwn");
73 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");
74 IkiWiki::rcs_commit_staged("Added the 4th page", "moo", "Joe User");
76 @changes = IkiWiki::rcs_recentchanges(4);
79 is($changes[0]{pages}[0]{"page"}, "test4");
81 ok(mkdir($config{srcdir}."/newdir"));
82 IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn");
83 IkiWiki::rcs_commit_staged("Added the 5th page", "moo", "Joe User");
85 @changes = IkiWiki::rcs_recentchanges(4);
88 is($changes[0]{pages}[0]{"page"}, "newdir/test5");
90 IkiWiki::rcs_remove("newdir/test5.mdwn");
91 IkiWiki::rcs_commit_staged("Remove the 5th page", "moo", "Joe User");