7 $dir="/tmp/ikiwiki-test-git.$$";
12 use Test::More skip_all => "git not available"
19 use Test::More tests => 22;
21 BEGIN { use_ok("IkiWiki"); }
23 %config=IkiWiki::defaultconfig();
25 $config{srcdir} = "$dir/src";
26 $config{diffurl} = '/nonexistent/cgit/plain/[[file]]';
27 IkiWiki::loadplugins();
28 IkiWiki::checkconfig();
30 ok (mkdir($config{srcdir}));
31 is (system("./ikiwiki-makerepo git $config{srcdir} $dir/repo"), 0);
34 @changes = IkiWiki::rcs_recentchanges(3);
36 is($#changes, 0); # counts for dummy commit during repo creation
37 # ikiwiki-makerepo's first commit is setting up the .gitignore
38 is($changes[0]{message}[0]{"line"}, "initial commit");
39 is($changes[0]{pages}[0]{"page"}, ".gitignore");
42 my $test1 = readfile("t/test1.mdwn");
43 writefile('test1.mdwn', $config{srcdir}, $test1);
44 IkiWiki::rcs_add("test1.mdwn");
47 message => "Added the first page",
51 @changes = IkiWiki::rcs_recentchanges(3);
54 is($changes[0]{message}[0]{"line"}, "Added the first page");
55 is($changes[0]{pages}[0]{"page"}, "test1");
58 my $message = "Added the second page";
60 my $test2 = readfile("t/test2.mdwn");
61 writefile('test2.mdwn', $config{srcdir}, $test2);
62 system "cd $config{srcdir}; git add test2.mdwn >/dev/null 2>&1";
63 system "cd $config{srcdir}; git commit -m \"$message\" test2.mdwn >/dev/null 2>&1";
64 system "cd $config{srcdir}; git push origin >/dev/null 2>&1";
66 @changes = IkiWiki::rcs_recentchanges(3);
69 is($changes[0]{message}[0]{"line"}, $message);
70 is($changes[0]{pages}[0]{"page"}, "test2");
72 is($changes[1]{pages}[0]{"page"}, "test1");
76 writefile('test3.mdwn', $config{srcdir}, $test1);
77 IkiWiki::rcs_add("test3.mdwn");
78 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");
79 IkiWiki::rcs_commit_staged(message => "Added the 4th page");
81 @changes = IkiWiki::rcs_recentchanges(4);
84 is($changes[0]{pages}[0]{"page"}, "test4");
86 ok(mkdir($config{srcdir}."/newdir"));
87 IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn");
88 IkiWiki::rcs_commit_staged(message => "Added the 5th page");
90 @changes = IkiWiki::rcs_recentchanges(4);
93 is($changes[0]{pages}[0]{"page"}, "newdir/test5");
95 IkiWiki::rcs_remove("newdir/test5.mdwn");
96 IkiWiki::rcs_commit_staged(message => "Remove the 5th page");
99 ok(mkdir($config{srcdir}."/diffurl_dir"));
100 my $test3 = readfile("t/test1.mdwn");
101 writefile('test3.mdwn', $config{srcdir}."/diffurl_dir", $test3);
102 IkiWiki::rcs_add("diffurl_dir/test3.mdwn");
104 file => "diffurl_dir/test3.mdwn",
105 message => "Added a page in diffurl_dir",
109 @changes = IkiWiki::rcs_recentchanges(5);
112 is($changes[0]{pages}[0]{"page"}, "diffurl_dir/test3");
115 $changes[0]{pages}[0]{"diffurl"},
117 q{path separators are preserved when UTF-8scaping filename}
120 system "rm -rf $dir";