[Bps-public-commit] SD branch, master, updated. 03d81ccb794e7ba05ddf3570ffdb1f3d9ef94d5f

spang at bestpractical.com spang at bestpractical.com
Thu Aug 27 20:01:38 EDT 2009


The branch, master has been updated
       via  03d81ccb794e7ba05ddf3570ffdb1f3d9ef94d5f (commit)
      from  461c879eb045b95b18210e4367b0b402aaf3699a (commit)

Summary of changes:
 lib/App/SD/Replica/gcode/PushEncoder.pm  |    6 ++++--
 lib/App/SD/Replica/github.pm             |   19 ++++++++++++++-----
 lib/App/SD/Replica/github/PushEncoder.pm |    5 ++++-
 lib/App/SD/Replica/hm.pm                 |    8 +++++++-
 lib/App/SD/Replica/redmine.pm            |   11 +++++++----
 lib/App/SD/Replica/rt.pm                 |    6 +++++-
 lib/App/SD/Replica/trac.pm               |    7 ++++++-
 7 files changed, 47 insertions(+), 15 deletions(-)

- Log -----------------------------------------------------------------
commit 03d81ccb794e7ba05ddf3570ffdb1f3d9ef94d5f
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Aug 27 20:07:47 2009 +0100

    GitHub UI improvements and related updates for prompt_for_login API change
    
    Now we prompt for the API token, not a 'password' (which is
    wrong), and point at a URL where you can get it from GitHub.

diff --git a/lib/App/SD/Replica/gcode/PushEncoder.pm b/lib/App/SD/Replica/gcode/PushEncoder.pm
index 9f75dc2..3b7001b 100644
--- a/lib/App/SD/Replica/gcode/PushEncoder.pm
+++ b/lib/App/SD/Replica/gcode/PushEncoder.pm
@@ -31,8 +31,10 @@ sub integrate_change {
     my $before_integration = time();
     my ( $email, $password );
     if ( !$self->sync_source->gcode->password ) {
-        ( $email, $password ) = $self->sync_source->prompt_for_login(
-            'gcode:' . $self->sync_source->project );
+        ( $email, $password )
+            = $self->sync_source->prompt_for_login(
+                uri => 'gcode:' . $self->sync_source->project,
+            );
         $self->sync_source->gcode->email($email);
         $self->sync_source->gcode->password($password);
     }
diff --git a/lib/App/SD/Replica/github.pm b/lib/App/SD/Replica/github.pm
index 581773f..19cfb68 100644
--- a/lib/App/SD/Replica/github.pm
+++ b/lib/App/SD/Replica/github.pm
@@ -29,14 +29,15 @@ sub BUILD {
     my ( $server, $owner, $repo ) =
       $self->{url} =~ m{^github:(http://.*?github.com/)?(.*?)/(.*)}
       or die
-"Can't parse Github server spec. Expected github:owner/repository or github:http://github.com/owner/repository";
+        "Can't parse Github server spec. Expected github:owner/repository or\n"
+        ."github:http://github.com/owner/repository.";
 
-    my ( $uri, $username, $apikey );
+    my ( $uri, $username, $api_token );
 
     if ($server) {
         $uri = URI->new($server);
         if ( my $auth = $uri->userinfo ) {
-            ( $username, $apikey ) = split /:/, $auth, 2;
+            ( $username, $api_token ) = split /:/, $auth, 2;
             $uri->userinfo(undef);
         }
     }
@@ -44,7 +45,15 @@ sub BUILD {
         $uri = 'http://github.com/';
     }
 
-    ( $username, $apikey ) = $self->prompt_for_login( $uri, $username ) unless $apikey ;
+    ( $username, $api_token )
+        = $self->prompt_for_login(
+            uri => $uri,
+            username => $username,
+            secret_prompt => sub {
+                my ($uri, $username) = @_;
+                return "GitHub API token for $username (from ${uri}account): ";
+            },
+        ) unless $api_token;
 
     $self->remote_url("$uri");
     $self->owner( $owner );
@@ -53,7 +62,7 @@ sub BUILD {
     $self->github(
         Net::GitHub->new(
             login => $username,
-            token => $apikey,
+            token => $api_token,
             repo  => $repo,
             owner => $owner,
         ) );
diff --git a/lib/App/SD/Replica/github/PushEncoder.pm b/lib/App/SD/Replica/github/PushEncoder.pm
index b92dc87..db34284 100644
--- a/lib/App/SD/Replica/github/PushEncoder.pm
+++ b/lib/App/SD/Replica/github/PushEncoder.pm
@@ -104,7 +104,10 @@ sub integrate_ticket_create {
     my $attr = $self->_recode_props_for_integrate($change);
     my $new =
       $ticket->open( $attr->{title}, $attr->{body} );
-
+    # TODO: better error handler?
+    if ( $new->{error} ) {
+        die "\n\n$new->{error}";
+    }
     return $new->{number};
 }
 
diff --git a/lib/App/SD/Replica/hm.pm b/lib/App/SD/Replica/hm.pm
index 3a34e1a..1a7ec4b 100644
--- a/lib/App/SD/Replica/hm.pm
+++ b/lib/App/SD/Replica/hm.pm
@@ -43,7 +43,13 @@ sub BUILD {
     }
     $self->remote_url("$uri");
     $self->foreign_username($username) if ($username);
-    ( $username, $password ) = $self->prompt_for_login( $uri, $username ) unless $password;
+
+    ( $username, $password )
+        = $self->prompt_for_login(
+            uri      => $uri,
+            username => $username,
+        ) unless $password;
+
     if ($props) {
         my %props = split /=|;/, $props;
         $self->props( \%props );
diff --git a/lib/App/SD/Replica/redmine.pm b/lib/App/SD/Replica/redmine.pm
index 2be176c..f31bc37 100644
--- a/lib/App/SD/Replica/redmine.pm
+++ b/lib/App/SD/Replica/redmine.pm
@@ -30,13 +30,16 @@ sub BUILD {
 
     $self->remote_url( $uri->as_string );
 
-    ($username, $password) = $self->prompt_for_login( $uri, $username )
-        unless $password;
+    ($username, $password)
+        = $self->prompt_for_login(
+            uri      => $uri,
+            username => $username,
+        ) unless $password;
 
     $self->redmine(
         Net::Redmine->new(
-            url => $self->remote_url,
-            user => $username,
+            url      => $self->remote_url,
+            user     => $username,
             password => $password
         ));
 
diff --git a/lib/App/SD/Replica/rt.pm b/lib/App/SD/Replica/rt.pm
index 31c6b98..90f2e5b 100644
--- a/lib/App/SD/Replica/rt.pm
+++ b/lib/App/SD/Replica/rt.pm
@@ -40,7 +40,11 @@ sub BUILD {
     $self->query( ( $query ?  "($query) AND " :"") . " Queue = '$type'" );
     $self->rt( RT::Client::REST->new( server => $server ) );
 
-    ( $username, $password ) = $self->prompt_for_login( $uri, $username ) unless $password;
+    ( $username, $password )
+        = $self->prompt_for_login(
+            uri      => $uri,
+            username => $username,
+        ) unless $password;
 
     $self->rt_username($username);
 
diff --git a/lib/App/SD/Replica/trac.pm b/lib/App/SD/Replica/trac.pm
index c9d04a6..3f0c669 100644
--- a/lib/App/SD/Replica/trac.pm
+++ b/lib/App/SD/Replica/trac.pm
@@ -35,7 +35,12 @@ sub BUILD {
     }
     $self->remote_url( $uri->as_string );
 
-    ( $username, $password ) = $self->prompt_for_login( $uri, $username ) unless $password;
+    ( $username, $password )
+        = $self->prompt_for_login(
+            uri      => $uri,
+            username => $username,
+        ) unless $password;
+
     $self->trac(
         Net::Trac::Connection->new(
             url      => $self->remote_url,

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list