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");
41 IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo");
43 @changes = IkiWiki::rcs_recentchanges(3);
46 is($changes[0]{message}[0]{"line"}, "Added the first page");
47 is($changes[0]{pages}[0]{"page"}, "test1");
50 my $message = "Added the second page";
52 my $test2 = readfile("t/test2.mdwn");
53 writefile('test2.mdwn', $config{srcdir}, $test2);
54 system "cd $config{srcdir}; git add test2.mdwn >/dev/null 2>&1";
55 system "cd $config{srcdir}; git commit -m \"$message\" test2.mdwn >/dev/null 2>&1";
56 system "cd $config{srcdir}; git push origin >/dev/null 2>&1";
58 @changes = IkiWiki::rcs_recentchanges(3);
61 is($changes[0]{message}[0]{"line"}, $message);
62 is($changes[0]{pages}[0]{"page"}, "test2");
64 is($changes[1]{pages}[0]{"page"}, "test1");
68 writefile('test3.mdwn', $config{srcdir}, $test1);
69 IkiWiki::rcs_add("test3.mdwn");
70 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");
71 IkiWiki::rcs_commit_staged("Added the 4th page", "moo", "Joe User");
73 @changes = IkiWiki::rcs_recentchanges(4);
76 is($changes[0]{pages}[0]{"page"}, "test4");
78 ok(mkdir($config{srcdir}."/newdir"));
79 IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn");
80 IkiWiki::rcs_commit_staged("Added the 5th page", "moo", "Joe User");
82 @changes = IkiWiki::rcs_recentchanges(4);
85 is($changes[0]{pages}[0]{"page"}, "newdir/test5");
87 IkiWiki::rcs_remove("newdir/test5.mdwn");
88 IkiWiki::rcs_commit_staged("Remove the 5th page", "moo", "Joe User");