Using inlined code as Git::Wrapper fails tests on pristine install
[p5sagit/Oyster.git] / lib / Oyster / Deploy / Git.pm
1 package Oyster::Deploy::Git;
2 use strict;
3 use warnings;
4
5 #use Git::Wrapper;    # sorry fails tests!
6
7 our $post_receive = q{
8 #!/bin/sh
9 cd ..
10 env -i git reset --hard HEAD
11 dzil listdeps | xargs cpanm --local-lib=~/perl5
12 };
13
14 our $post_update = q{
15 #!/bin/sh
16 # This rather relies on being an account with permission to do this.
17 # Who does the script run as?  Presumably the owner of the repo as git will
18 # use ssh-keys to get onto the server.
19 #
20 # Realistically that user needs to be put in /etc/sudoers
21 #
22 # user ALL=NOPASSWD: /etc/init.d/lighttpd
23 #
24 # Restart server
25 sudo /etc/init.d/lighttpd restart
26 };
27
28 sub create {
29   my $self = shift;
30   my $location = shift;
31
32   if( -f $location || -d $location ) {
33     die("$location already exists");
34   }
35
36   mkdir($location);
37   #my $git = Git::Wrapper->new($location);
38   #$git->init();
39   qx{cd $location ; git init};
40
41   open my $fh_post_receive, '>', "$location/.git/hooks/post-receive"
42     or die "Cannot write to " .  "$location/.git/hooks/post-receive: $!";
43   print $fh_post_receive $post_receive;
44   close $fh_post_receive
45     or die "Cannot close " . "$location/.git/hooks/post-receive: $!";
46
47   open my $fh_post_update, '>', "$location/.git/hooks/post-update"
48     or die "Cannot write to " . "$location/.git/hooks/post-update: $!";
49   print $fh_post_update $post_update;
50   close $fh_post_update
51     or die "Cannot close " . "$location/.git/hooks/post-update: $!";
52
53   chmod(0x755, ("$location/.git/hooks/post-receive", "$location/.git/hooks/post-update"));
54
55   return 1;
56 }
57
58
59 1;