7 $dir="/tmp/ikiwiki-test-git.$$";
12 use Test::More skip_all => "git not available"
19 use Test::More tests => 18;
21 BEGIN { use_ok("IkiWiki"); }
23 %config=IkiWiki::defaultconfig();
25 $config{srcdir} = "$dir/src";
26 IkiWiki::loadplugins();
27 IkiWiki::checkconfig();
29 ok (mkdir($config{srcdir}));
30 is (system("./ikiwiki-makerepo git $config{srcdir} $dir/repo"), 0);
33 @changes = IkiWiki::rcs_recentchanges(3);
35 is($#changes, 0); # counts for dummy commit during repo creation
36 # ikiwiki-makerepo's first commit is setting up the .gitignore
37 is($changes[0]{message}[0]{"line"}, "initial commit");
38 is($changes[0]{pages}[0]{"page"}, ".gitignore");
41 my $test1 = readfile("t/test1.mdwn");
42 writefile('test1.mdwn', $config{srcdir}, $test1);
43 IkiWiki::rcs_add("test1.mdwn");
46 message => "Added the first page",
50 @changes = IkiWiki::rcs_recentchanges(3);
53 is($changes[0]{message}[0]{"line"}, "Added the first page");
54 is($changes[0]{pages}[0]{"page"}, "test1");
57 my $message = "Added the second page";
59 my $test2 = readfile("t/test2.mdwn");
60 writefile('test2.mdwn', $config{srcdir}, $test2);
61 system "cd $config{srcdir}; git add test2.mdwn >/dev/null 2>&1";
62 system "cd $config{srcdir}; git commit -m \"$message\" test2.mdwn >/dev/null 2>&1";
63 system "cd $config{srcdir}; git push origin >/dev/null 2>&1";
65 @changes = IkiWiki::rcs_recentchanges(3);
68 is($changes[0]{message}[0]{"line"}, $message);
69 is($changes[0]{pages}[0]{"page"}, "test2");
71 is($changes[1]{pages}[0]{"page"}, "test1");
75 writefile('test3.mdwn', $config{srcdir}, $test1);
76 IkiWiki::rcs_add("test3.mdwn");
77 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");
78 IkiWiki::rcs_commit_staged(message => "Added the 4th page");
80 @changes = IkiWiki::rcs_recentchanges(4);
83 is($changes[0]{pages}[0]{"page"}, "test4");
85 ok(mkdir($config{srcdir}."/newdir"));
86 IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn");
87 IkiWiki::rcs_commit_staged(message => "Added the 5th page");
89 @changes = IkiWiki::rcs_recentchanges(4);
92 is($changes[0]{pages}[0]{"page"}, "newdir/test5");
94 IkiWiki::rcs_remove("newdir/test5.mdwn");
95 IkiWiki::rcs_commit_staged(message => "Remove the 5th page");