[Bps-public-commit] Shipwright branch, master, updated. ea11422aa1eafd7671af655d7cea80d16835906b

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Jul 10 03:06:17 EDT 2009


The branch, master has been updated
       via  ea11422aa1eafd7671af655d7cea80d16835906b (commit)
       via  8963114b960ea8768175ae84851c88031427ae21 (commit)
      from  dd42aa83cae133de64f85cf19bf67f86c9f8954a (commit)

Summary of changes:
 lib/Shipwright/Backend.pm           |    3 ++-
 lib/Shipwright/Source.pm            |    3 ++-
 lib/Shipwright/Util.pm              |   10 ++++++++++
 share/etc/shipwright-perl-wrapper   |    2 +-
 share/etc/shipwright-script-wrapper |    2 +-
 5 files changed, 16 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit 8963114b960ea8768175ae84851c88031427ae21
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jul 10 14:35:15 2009 +0800

    make finding user home dir a method

diff --git a/lib/Shipwright/Backend.pm b/lib/Shipwright/Backend.pm
index 8d6cb8b..4a06465 100644
--- a/lib/Shipwright/Backend.pm
+++ b/lib/Shipwright/Backend.pm
@@ -5,6 +5,7 @@ use strict;
 use Carp;
 use UNIVERSAL::require;
 use Cwd qw/abs_path/;
+use Shipwright::Util;
 
 sub new {
     my $class = shift;
@@ -24,7 +25,7 @@ sub new {
     }
     elsif ( $args{repository} =~ m{^\s*fs:} ) {
         $args{repository} =~ s{^\s*fs:}{};
-        $args{repository} =~ s/^~/(getpwuid $<)[7]/e;
+        $args{repository} =~ s/^~/Shipwright::Util->user_home/e;
         my $abs_path = abs_path($args{repository});
         $args{repository} = $abs_path if $abs_path;
         $module = 'Shipwright::Backend::FS';
diff --git a/lib/Shipwright/Source.pm b/lib/Shipwright/Source.pm
index 3731776..8769ccc 100644
--- a/lib/Shipwright/Source.pm
+++ b/lib/Shipwright/Source.pm
@@ -7,6 +7,7 @@ use UNIVERSAL::require;
 use Hash::Merge qw/merge/;
 use File::Temp qw/tempdir/;
 use File::Spec::Functions qw/catfile catdir/;
+use Shipwright::Util;
 
 Hash::Merge::set_behavior('RIGHT_PRECEDENT');
 
@@ -104,7 +105,7 @@ sub _translate_source {
     if ( $$source =~ /^(file|dir(ectory)?|shipwright):~/i ) {
 
         # replace prefix ~ with real home dir
-        $$source =~ s/~/(getpwuid $<)[7]/e;
+        $$source =~ s/~/Shipwright::Util->user_home/e;
     }
 }
 
diff --git a/lib/Shipwright/Util.pm b/lib/Shipwright/Util.pm
index dec1318..e03f0bb 100644
--- a/lib/Shipwright/Util.pm
+++ b/lib/Shipwright/Util.pm
@@ -168,6 +168,16 @@ sub select {
     }
 }
 
+=head2 user_home
+
+return current user's home directory
+
+=cut
+
+sub user_home {
+    return (getpwuid $<)[7];
+}
+
 1;
 
 __END__

commit ea11422aa1eafd7671af655d7cea80d16835906b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jul 10 15:05:55 2009 +0800

    downgrade sh script to not use bash's regex thing

diff --git a/share/etc/shipwright-perl-wrapper b/share/etc/shipwright-perl-wrapper
index ed8d992..b5da954 100755
--- a/share/etc/shipwright-perl-wrapper
+++ b/share/etc/shipwright-perl-wrapper
@@ -6,7 +6,7 @@ else
     LINK=`readlink $0`
 fi
 
-if [ "$LINK" = '' ] || [[ $LINK =~ '../etc/shipwright-perl-wrapper' ]]; then
+if [ "$LINK" = '' ] || [ $LINK = '../etc/shipwright-perl-wrapper' ] || [ $LINK = '../../etc/shipwright-perl-wrapper' ]; then
     BASE=$0
     BASE_DIR=`dirname "$BASE"`
     BASE_DIR=` (cd "$BASE_DIR"; pwd) `
diff --git a/share/etc/shipwright-script-wrapper b/share/etc/shipwright-script-wrapper
index 5c7226c..d529d9c 100755
--- a/share/etc/shipwright-script-wrapper
+++ b/share/etc/shipwright-script-wrapper
@@ -6,7 +6,7 @@ else
     LINK=`readlink $0`
 fi
 
-if [ "$LINK" = '' ] || [[ $LINK =~ '../etc/shipwright-script-wrapper' ]]; then
+if [ "$LINK" = '' ] || [ $LINK = '../etc/shipwright-script-wrapper' ] || [ $LINK = '../../etc/shipwright-script-wrapper' ]; then
     BASE=$0
     BASE_DIR=`dirname "$BASE"`
     BASE_DIR=` (cd "$BASE_DIR"; pwd) `

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



More information about the Bps-public-commit mailing list