]> sipb.mit.edu Git - sipb-www.git/blobdiff - import-trac
import-trac: strip out ^M from newlines
[sipb-www.git] / import-trac
index 1d1656f5744e9bbae450cefb8c611fd7ee7d22e7..aadee09f336345ea2119acee7e8d05c73e3c6b96 100755 (executable)
@@ -2,6 +2,10 @@
 use DBI;
 use IPC::Open2;
 
+system('mkdir doc') && die;
+chdir('doc');
+qx{git init};
+
 $password = qx(perl -F= -lane 'print \$F[1] if (\$F[0] eq "password")' \\
                /mit/sipb-www/.my.cnf);
 chomp $password;
@@ -12,8 +16,10 @@ foreach $row (@$rows) {
   next if $row->{author} eq 'trac';
   print "Processing revision $row->{version} of $row->{name} by $row->{author}...";
 
+  ($text = $row->{text}) =~ s/\r\n/\n/g;
+
   $pid = open2(OUT, IN, qw(git hash-object -w --stdin));
-  print IN $row->{text};
+  print IN $text;
   close(IN);
   chomp($blob = <OUT>);
   waitpid $pid, 0;
@@ -36,3 +42,5 @@ foreach $row (@$rows) {
 
   print "committed as $head.\n";
 }
+
+qx{git reset --hard $head};