[Bps-public-commit] r18338 - in Shipwright/trunk: . lib/Shipwright/Source

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Feb 11 03:33:27 EST 2009


Author: sunnavy
Date: Wed Feb 11 03:33:27 2009
New Revision: 18338

Added:
   Shipwright/trunk/lib/Shipwright/Source/Git.pm
Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/lib/Shipwright/Source.pm

Log:
 r19779 at sunnavys-mb:  sunnavy | 2009-02-11 16:26:09 +0800
 added git source type


Modified: Shipwright/trunk/lib/Shipwright/Source.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Source.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Source.pm	Wed Feb 11 03:33:27 2009
@@ -84,10 +84,10 @@
     }
 
     # prefix that can be omitted
-    for my $type (qw/svn http ftp/) {
+    for my $type (qw/svn http ftp git/) {
         if ( $$source =~ /^$type:/i ) {
             $$source =~ s{^$type:(?!//)}{}i;
-            return uc $type;
+            return $type eq 'git' ? 'Git' : uc $type;
         }
     }
 

Added: Shipwright/trunk/lib/Shipwright/Source/Git.pm
==============================================================================
--- (empty file)
+++ Shipwright/trunk/lib/Shipwright/Source/Git.pm	Wed Feb 11 03:33:27 2009
@@ -0,0 +1,107 @@
+package Shipwright::Source::Git;
+
+use warnings;
+use strict;
+use Carp;
+use File::Spec::Functions qw/catdir/;
+
+use base qw/Shipwright::Source::Base/;
+
+=head2 new
+
+=cut
+
+sub new {
+    my $class = shift;
+    my $self  = $class->SUPER::new(@_);
+
+    $self->name( $self->just_name( $self->source ) ) unless $self->name;
+    return $self;
+}
+
+=head2 run
+
+=cut
+
+sub run {
+    my $self = shift;
+    $self->log->info( "prepare to run source: " . $self->source );
+    $self->_update_url( $self->name, 'git:' . $self->source );
+
+    $self->_run();
+    my $s;
+    if ( $self->is_compressed ) {
+        require Shipwright::Source::Compressed;
+        $s = Shipwright::Source::Compressed->new( %$self, _no_update_url => 1 );
+    }
+    else {
+        require Shipwright::Source::Directory;
+        $s = Shipwright::Source::Directory->new( %$self, _no_update_url => 1 );
+    }
+    $s->run(@_);
+}
+
+=head2 _run
+
+=cut
+
+sub _run {
+    my $self   = shift;
+    my $source = $self->source;
+
+    my @cmds = (
+        [
+            $ENV{'SHIPWRIGHT_GIT'}, 'clone', $self->source,
+            catdir( $self->download_directory, $self->name ),
+        ],
+    );
+
+# TODO handle the version stuff
+
+    push @cmds,
+    [
+        'rm', '-rf',
+        catdir( $self->download_directory, $self->name, '.git' ),
+    ];
+
+    $self->source( catdir( $self->download_directory, $self->name ) );
+    Shipwright::Util->run($_) for @cmds;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Shipwright::Source::Git - git source
+
+
+=head1 DESCRIPTION
+
+
+=head1 DEPENDENCIES
+
+None.
+
+
+=head1 INCOMPATIBILITIES
+
+None reported.
+
+
+=head1 BUGS AND LIMITATIONS
+
+No bugs have been reported.
+
+=head1 AUTHOR
+
+sunnavy  C<< <sunnavy at bestpractical.com> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright 2007-2009 Best Practical Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.



More information about the Bps-public-commit mailing list