Using inlined code as Git::Wrapper fails tests on pristine install
[p5sagit/Oyster.git] / lib / Oyster / Deploy / Git.pm
CommitLineData
40056462 1package Oyster::Deploy::Git;
73e49568 2use strict;
3use warnings;
40056462 4
680e65b6 5#use Git::Wrapper; # sorry fails tests!
40056462 6
73e49568 7our $post_receive = q{
8#!/bin/sh
9cd ..
10env -i git reset --hard HEAD
11dzil listdeps | xargs cpanm --local-lib=~/perl5
12};
13
14our $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
25sudo /etc/init.d/lighttpd restart
26};
40056462 27
28sub create {
29 my $self = shift;
30 my $location = shift;
c0ce95cc 31
40056462 32 if( -f $location || -d $location ) {
73e49568 33 die("$location already exists");
40056462 34 }
c0ce95cc 35
40056462 36 mkdir($location);
680e65b6 37 #my $git = Git::Wrapper->new($location);
38 #$git->init();
39 qx{cd $location ; git init};
c0ce95cc 40
680e65b6 41 open my $fh_post_receive, '>', "$location/.git/hooks/post-receive"
42 or die "Cannot write to " . "$location/.git/hooks/post-receive: $!";
73e49568 43 print $fh_post_receive $post_receive;
44 close $fh_post_receive
680e65b6 45 or die "Cannot close " . "$location/.git/hooks/post-receive: $!";
73e49568 46
680e65b6 47 open my $fh_post_update, '>', "$location/.git/hooks/post-update"
48 or die "Cannot write to " . "$location/.git/hooks/post-update: $!";
73e49568 49 print $fh_post_update $post_update;
50 close $fh_post_update
680e65b6 51 or die "Cannot close " . "$location/.git/hooks/post-update: $!";
c0ce95cc 52
680e65b6 53 chmod(0x755, ("$location/.git/hooks/post-receive", "$location/.git/hooks/post-update"));
c0ce95cc 54
40056462 55 return 1;
56}
57
58
47863b26 591;