[Bps-public-commit] r11451 - SVN-PropDB/lib/Prophet/Sync/Source

clkao at bestpractical.com clkao at bestpractical.com
Thu Apr 3 19:56:36 EDT 2008


Author: clkao
Date: Thu Apr  3 19:56:36 2008
New Revision: 11451

Modified:
   SVN-PropDB/lib/Prophet/Sync/Source/RT.pm

Log:
process authinfo from rt url, or attempt to get from terminal
user input.


Modified: SVN-PropDB/lib/Prophet/Sync/Source/RT.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source/RT.pm	(original)
+++ SVN-PropDB/lib/Prophet/Sync/Source/RT.pm	Thu Apr  3 19:56:36 2008
@@ -30,10 +30,31 @@
     my $self = shift;
     my ($server, $type, $query) = $self->{url} =~ m/^rt:(.*?):(tickets):(.*)$/
         or die "Can't parse rt server spec";
-    $self->rt_url( $server );
+    my $uri = URI->new($server);
+    my ($username, $password);
+    if (my $auth = $uri->userinfo) {
+        ($username, $password) = split /:/, $auth, 2;
+        $uri->userinfo(undef);
+    }
+    $self->rt_url( "$uri" );
     $self->rt_query( $query );
     $self->rt( RT::Client::REST->new(server => $server) );
-    $self->rt->login(username => 'guest', password => 'guest');
+    unless ($username) {
+        # XXX belongs to some CLI callback
+        use Term::ReadKey;
+        local $| = 1;
+        print "Username for $uri: ";
+        ReadMode 1;
+        $username = ReadLine 0;
+        chomp $username;
+        print "Password for $username @ $uri: ";
+        ReadMode 2;
+        $password = ReadLine 0;
+        chomp $password;
+        ReadMode 1;
+        print "\n";
+    }
+    $self->rt->login(username => $username, password => $password);
     my $orz = tempdir();
     $self->{___Orz} = $orz;
     SVN::Repos::create($orz, undef, undef, undef, undef);



More information about the Bps-public-commit mailing list