[#12]: Fixed storing credentials for newer SVN clients.
authorStanislaw Klekot <dozzie@jarowit.net>
Tue, 30 Aug 2011 20:23:24 +0000 (22:23 +0200)
committerStanislaw Klekot <dozzie@jarowit.net>
Fri, 2 Sep 2011 14:15:00 +0000 (16:15 +0200)
lib/Cron/Builder/Repo/svn.pm

index 8447e1c..7ef3b89 100644 (file)
@@ -19,7 +19,7 @@ use strict;
 use base qw{Cron::Builder::Repo};
 
 use Cron::Builder qw{spawn};
-use File::Path qw{rmtree};
+use File::Path qw{mkpath rmtree};
 use File::Find;
 
 #-----------------------------------------------------------------------------
@@ -72,7 +72,17 @@ sub new {
   my ($class, %opts) = @_;
 
   my $self = bless { %opts }, $class;
-  $opts{statedir} ||= "./svn-config";
+  if (not defined $self->{statedir}) {
+    $self->{statedir} = "./svn-config";
+  }
+
+  if (! -f "$self->{statedir}/servers") {
+    mkpath($self->{statedir}) if not -d $self->{statedir};
+    open my $f, ">", "$self->{statedir}/servers" or
+      die "Can't prepare SVN configuration";
+    printf $f "[global]\nstore-plaintext-passwords = yes\n";
+    close $f;
+  }
 
   if (not -d $self->{workdir} or not -d "$self->{workdir}/.svn") {
     if (not defined $self->{url}) {