[Bps-public-commit] RT-Extension-MergeUsers branch, master, updated. 0.06-6-gbd8cc7f

Thomas Sibley trs at bestpractical.com
Mon Feb 25 16:33:03 EST 2013


The branch, master has been updated
       via  bd8cc7f047d65649eb028412c4ca6b02f6cc3c9a (commit)
       via  1ba88cadc7049380e8bffac5018cd68ca255d6bf (commit)
       via  4dd0b2ca8dc98789ead83cd5b0b251f9699e1116 (commit)
       via  26f9525eddd59e7b6f18b3b6d95871a50c56e9da (commit)
      from  4e7aea77f5fe77827dd3695dfdc5c3c2b816c80a (commit)

Summary of changes:
 .gitignore                                                |  2 ++
 Makefile.PL                                               | 15 ++++++++++++++-
 bin/{rt-merge-users => rt-merge-users.in}                 |  5 +++--
 bin/{rt-update-merged-users => rt-update-merged-users.in} |  3 ++-
 lib/RT/Extension/MergeUsers.pm                            | 10 +++++-----
 t/01merge_users.t                                         | 12 ++++--------
 t/change_email.t                                          | 10 ++++------
 7 files changed, 34 insertions(+), 23 deletions(-)
 rename bin/{rt-merge-users => rt-merge-users.in} (91%)
 rename bin/{rt-update-merged-users => rt-update-merged-users.in} (93%)

- Log -----------------------------------------------------------------
commit 26f9525eddd59e7b6f18b3b6d95871a50c56e9da
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Feb 25 13:21:10 2013 -0800

    Switch to modern RT::Test infrastructure for testing plugins
    
    This side-steps incorrect test plan counts due to new bundled tests in
    RT::Test itself.

diff --git a/t/01merge_users.t b/t/01merge_users.t
index bc079b8..36b1553 100644
--- a/t/01merge_users.t
+++ b/t/01merge_users.t
@@ -1,16 +1,12 @@
 #!/sw/bin/perl5.8.6
 
 use strict;
-use Test::More tests => 16;
-use RT::Test;
-
-RT->Config->Set('Plugins',qw(RT::Extension::MergeUsers));
+use RT::Test
+    tests   => 'no_declare',
+    testing => 'RT::Extension::MergeUsers';
 
 my ($id, $message);
 
-# make sure the extension is installed
-use_ok('RT::Extension::MergeUsers');
-
 # create N unique users  ($$ == our pid)
 my $primary_user = RT::User->new($RT::SystemUser);
 ($id, $message) = $primary_user->Create( EmailAddress => "primary-$$\@example.com" );
@@ -86,4 +82,4 @@ my $ticket2 = RT::Ticket->new($RT::SystemUser);
                      );
 ok($ticket2->RequestorAddresses =~ /secondary-$$\@example.com/, "Unmerges tickets properly: @{[$ticket2->RequestorAddresses]}");
 
-1;
+done_testing;
diff --git a/t/change_email.t b/t/change_email.t
index 592a714..0066e72 100644
--- a/t/change_email.t
+++ b/t/change_email.t
@@ -2,11 +2,9 @@
 
 use strict;
 use warnings;
-use Test::More tests => 8;
-use RT::Test;
-
-RT->Config->Set('Plugins',qw(RT::Extension::MergeUsers));
-use_ok('RT::Extension::MergeUsers');
+use RT::Test
+    tests   => 'no_declare',
+    testing => 'RT::Extension::MergeUsers';
 
 my ($id, $message);
 
@@ -40,4 +38,4 @@ ok($id, "Successfully merges users? $message");
     ok(!$user->EmailAddress, "secondary record has no email");
 }
 
-1;
+done_testing;

commit 4dd0b2ca8dc98789ead83cd5b0b251f9699e1116
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Feb 25 13:22:14 2013 -0800

    Unset EmailAddress by setting the empty string rather than undef
    
    RT doesn't support undef → NULL conversion yet, and everything in RT
    expects a defined value.  The empty string is the canonical "no email
    address" value.  In the future once RT moves to real NULLs, we can
    revert this commit.

diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index d9b73c1..90d67f3 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -298,7 +298,7 @@ sub SetEmailAddress {
     $tmp->LoadOriginal( EmailAddress => $value );
     if ( $tmp->id && $tmp->id != $self->id ) {
         # there is a different user record
-        $tmp->_Set( Field => 'EmailAddress', Value => undef );
+        $tmp->_Set( Field => 'EmailAddress', Value => "" );
     }
 
     return $self->_Set( Field => 'EmailAddress', Value => $value );

commit 1ba88cadc7049380e8bffac5018cd68ca255d6bf
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Feb 25 13:24:44 2013 -0800

    Record the merged/mergee's user Name if EmailAddress is empty
    
    This avoids uninitialized in concatenation warnings and is more useful
    than a blank in user comments.

diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index 90d67f3..ea20cd0 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -241,11 +241,11 @@ sub MergeInto {
 
     $canonical_self->SetComments( join "\n", grep /\S/,
         $canonical_self->Comments||'',
-        "Merged into ". $merge->EmailAddress ." (". $merge->id .")",
+        "Merged into ". ($merge->EmailAddress || $merge->Name)." (". $merge->id .")",
     );
     $merge->SetComments(join "\n", grep /\S/,
         $merge->Comments||'',
-        $canonical_self->EmailAddress." (".$canonical_self->id.") merged into this user",
+        ($canonical_self->EmailAddress || $canonical_self->Name)." (".$canonical_self->id.") merged into this user",
     );
     return (1, "Merged users successfuly");
 }
@@ -266,12 +266,12 @@ sub UnMerge {
     $current->Delete;
     $self->SetComments( join "\n", grep /\S/,
         $self->Comments||'',
-        "Unmerged from ". $merge->EmailAddress ." (".$merge->id.")",
+        "Unmerged from ". ($merge->EmailAddress || $merge->Name) ." (".$merge->id.")",
     );
 
     $merge->SetComments(join "\n", grep /\S/,
         $merge->Comments,
-        $self->EmailAddress ." (". $self->id .") unmerged from this user",
+        ($self->EmailAddress || $self->Name) ." (". $self->id .") unmerged from this user",
     );
 
     my $merged_users = $merge->GetMergedUsers;

commit bd8cc7f047d65649eb028412c4ca6b02f6cc3c9a
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Feb 25 13:31:19 2013 -0800

    Switch to .in files for substitution so as not to trash version-controlled files

diff --git a/.gitignore b/.gitignore
index 6e7221d..8eb13a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@ pm_to_blib
 *.bak
 /MY*
 /RT-Extension-MergeUsers*
+/bin/rt-merge-users
+/bin/rt-update-merged-users
diff --git a/Makefile.PL b/Makefile.PL
index 5634ed3..376db08 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -9,7 +9,20 @@ requires_rt('3.8.3');
 
 my ($lib_path) = $INC{'RT.pm'} =~ /^(.*)[\\\/]/;
 my $local_lib_path = "$RT::LocalPath/lib";
-substitute( { RT_LIB_PATH => join( ' ', $local_lib_path, $lib_path ), },
+
+# Straight from perldoc perlvar
+use Config;
+my $secure_perl_path = $Config{perlpath};
+if ($^O ne 'VMS') {
+    $secure_perl_path .= $Config{_exe}
+        unless $secure_perl_path =~ m/$Config{_exe}$/i;
+}
+
+substitute( {
+        RT_LIB_PATH => join( ' ', $local_lib_path, $lib_path ),
+        PERL        => $ENV{PERL} || $secure_perl_path,
+    },
+    { sufix => '.in' },
     'bin/rt-update-merged-users',
     'bin/rt-merge-users',
 );  
diff --git a/bin/rt-merge-users b/bin/rt-merge-users.in
similarity index 91%
rename from bin/rt-merge-users
rename to bin/rt-merge-users.in
index 65c7067..ffe82b4 100755
--- a/bin/rt-merge-users
+++ b/bin/rt-merge-users.in
@@ -1,4 +1,5 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
+### before: #!@PERL@
 
 use strict;
 use warnings;
@@ -9,7 +10,7 @@ my ($from, $into) = @ARGV;
 die "\n$usage\n" unless $from && $into;
 
 ### after: use lib qw(@RT_LIB_PATH@);
-use lib qw(/opt/rt3/local/lib /opt/rt3/lib);
+use lib qw(/opt/rt4/local/lib /opt/rt4/lib);
 use RT;
 RT::LoadConfig();
 RT::Init();
diff --git a/bin/rt-update-merged-users b/bin/rt-update-merged-users.in
similarity index 93%
rename from bin/rt-update-merged-users
rename to bin/rt-update-merged-users.in
index cdee73d..34b53bc 100755
--- a/bin/rt-update-merged-users
+++ b/bin/rt-update-merged-users.in
@@ -1,10 +1,11 @@
 #!/usr/bin/env perl
+### before: #!@PERL@
 
 use strict;
 use warnings;
 
 ### after: use lib qw(@RT_LIB_PATH@);
-use lib qw(/opt/rt3/local/lib /opt/rt3/lib);
+use lib qw(/opt/rt4/local/lib /opt/rt4/lib);
 use RT;
 RT::LoadConfig();
 RT::Init();

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



More information about the Bps-public-commit mailing list