7 $dir="/tmp/ikiwiki-test-git.$$";
10 if (! -x $git || ! mkdir($dir)) {
12 use Test::More skip_all => "git not available or could not make test dir"
16 use Test::More tests => 18;
18 BEGIN { use_ok("IkiWiki"); }
20 %config=IkiWiki::defaultconfig();
22 $config{srcdir} = "$dir/src";
23 IkiWiki::loadplugins();
24 IkiWiki::checkconfig();
26 ok (mkdir($config{srcdir}));
27 is (system("./ikiwiki-makerepo git $config{srcdir} $dir/repo"), 0);
30 @changes = IkiWiki::rcs_recentchanges(3);
32 is($#changes, 0); # counts for dummy commit during repo creation
33 # ikiwiki-makerepo's first commit is setting up the .gitignore
34 is($changes[0]{message}[0]{"line"}, "initial commit");
35 is($changes[0]{pages}[0]{"page"}, ".gitignore");
38 my $test1 = readfile("t/test1.mdwn");
39 writefile('test1.mdwn', $config{srcdir}, $test1);
40 IkiWiki::rcs_add("test1.mdwn");
43 message => "Added the first page",
47 @changes = IkiWiki::rcs_recentchanges(3);
50 is($changes[0]{message}[0]{"line"}, "Added the first page");
51 is($changes[0]{pages}[0]{"page"}, "test1");
54 my $message = "Added the second page";
56 my $test2 = readfile("t/test2.mdwn");
57 writefile('test2.mdwn', $config{srcdir}, $test2);
58 system "cd $config{srcdir}; git add test2.mdwn >/dev/null 2>&1";
59 system "cd $config{srcdir}; git commit -m \"$message\" test2.mdwn >/dev/null 2>&1";
60 system "cd $config{srcdir}; git push origin >/dev/null 2>&1";
62 @changes = IkiWiki::rcs_recentchanges(3);
65 is($changes[0]{message}[0]{"line"}, $message);
66 is($changes[0]{pages}[0]{"page"}, "test2");
68 is($changes[1]{pages}[0]{"page"}, "test1");
72 writefile('test3.mdwn', $config{srcdir}, $test1);
73 IkiWiki::rcs_add("test3.mdwn");
74 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");
75 IkiWiki::rcs_commit_staged(message => "Added the 4th page");
77 @changes = IkiWiki::rcs_recentchanges(4);
80 is($changes[0]{pages}[0]{"page"}, "test4");
82 ok(mkdir($config{srcdir}."/newdir"));
83 IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn");
84 IkiWiki::rcs_commit_staged(message => "Added the 5th page");
86 @changes = IkiWiki::rcs_recentchanges(4);
89 is($changes[0]{pages}[0]{"page"}, "newdir/test5");
91 IkiWiki::rcs_remove("newdir/test5.mdwn");
92 IkiWiki::rcs_commit_staged(message => "Remove the 5th page");