X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FOyster%2FDeploy%2FGit.pm;h=c70eb8e35347aa71171b245c283d91d0baa2410c;hb=c0ce95cc18f039ddbd57762ffe7e0581f9ecfcad;hp=9f9f891991d75b4edffebb326f9315732989a094;hpb=e74d6d9cf461eb98e13a8179119c66fcd96064ad;p=p5sagit%2FOyster.git diff --git a/lib/Oyster/Deploy/Git.pm b/lib/Oyster/Deploy/Git.pm index 9f9f891..c70eb8e 100644 --- a/lib/Oyster/Deploy/Git.pm +++ b/lib/Oyster/Deploy/Git.pm @@ -11,22 +11,36 @@ use File::ShareDir ':ALL'; sub create { my $self = shift; my $location = shift; - + if( -f $location || -d $location ) { Error::Simple->throw("$location already exists"); } - + mkdir($location); my $git = Git::Wrapper->new($location); - - - copy(dist_file( 'Oyster', './deploy/git/post-receive'), ($git->dir . '.git/hooks/')) + $git->init(); + + my ($postreceive, $postupdate); + + eval { + $postreceive = dist_file( 'Oyster', './deploy/git/post-receive'); + $postupdate = dist_file( 'Oyster', './deploy/git/post-update'); + }; + #Beware there be deamons here + if ($@) { + $postreceive = './share/deploy/git/post-receive'; + $postupdate = './share/deploy/git/post-update'; + } + + + copy($postreceive, ($git->dir . '/.git/hooks/')) or Error::Simple->throw('Creating post commit hooks failed.'); - copy(dist_file( 'Oyster', './deploy/git/post-update'), ($git->dir . '.git/hooks/')) + + copy($postupdate, ($git->dir . '/.git/hooks/')) or Error::Simple->throw('Creating post commit hooks failed.'); - - chmod(0x755, ('./bin/git/hooks/post-receive', './bin/git/hooks/post-update')); - + + chmod(0x755, ($git->dir . '.git/hooks/post-receive', $git->dir . '.git/hooks/post-update')); + return 1; }