[Bps-public-commit] r12074 - Shipwright/trunk/lib/Shipwright/Backend

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon May 5 08:21:21 EDT 2008


Author: sunnavy
Date: Mon May  5 08:21:21 2008
New Revision: 12074

Modified:
   Shipwright/trunk/lib/Shipwright/Backend/SVK.pm
   Shipwright/trunk/lib/Shipwright/Backend/SVN.pm

Log:
backend for version support

Modified: Shipwright/trunk/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/SVK.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/SVK.pm	Mon May  5 08:21:21 2008
@@ -529,6 +529,42 @@
     }
 }
 
+=head2 version
+
+get or set version
+
+=cut
+
+sub version {
+    my $self   = shift;
+    my %args = @_;
+
+    croak "need dist arg" unless $args{dist};
+
+    if ($args{version}) {
+        my $dir = tempdir( CLEANUP => 1 );
+        my $file = File::Spec->catfile( $dir, 'version.yml' );
+
+        $self->checkout(
+            path   => '/shipwright/version.yml',
+            target => $file,
+        );
+
+        my $version = Shipwright::Util::LoadFile( $file );
+        $version->{$args{dist}} = $args{version};
+
+        Shipwright::Util::DumpFile( $file, $version );
+        $self->commit( path => $file, comment => "set version for $args{dist}" );
+        $self->checkout( detach => 1, target => $file );
+    }
+    else {
+        my ($out) = Shipwright::Util->run(
+            [ 'svk', 'cat', $self->repository . '/shipwright/version.yml' ] );
+        $out = Shipwright::Util::Load($out) || {};
+        return $out->{$args{dist}}; 
+    }
+}
+
 1;
 
 __END__

Modified: Shipwright/trunk/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/SVN.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/SVN.pm	Mon May  5 08:21:21 2008
@@ -538,6 +538,41 @@
     }
 }
 
+=head2 version
+
+get or set version
+
+=cut
+
+sub version {
+    my $self   = shift;
+    my %args = @_;
+
+    croak "need dist arg" unless $args{dist};
+
+    if ($args{version}) {
+        my $dir = tempdir( CLEANUP => 1 );
+        my $file = File::Spec->catfile( $dir, 'version.yml' );
+
+        $self->checkout(
+            path   => '/shipwright',
+            target => $dir,
+        );
+
+        my $version = Shipwright::Util::LoadFile( $file );
+        $version->{$args{dist}} = $args{version};
+
+        Shipwright::Util::DumpFile( $file, $version );
+        $self->commit( path => $file, comment => "set version for $args{dist}" );
+    }
+    else {
+        my ($out) = Shipwright::Util->run(
+            [ 'svn', 'cat', $self->repository . '/shipwright/version.yml' ] );
+        $out = Shipwright::Util::Load($out) || {};
+        return $out->{$args{version}}; 
+    }
+}
+
 1;
 
 __END__



More information about the Bps-public-commit mailing list