From: Graeme Lawton Date: Sat, 20 Nov 2010 17:27:01 +0000 (+0000) Subject: Added post commit hooks X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FOyster.git;a=commitdiff_plain;h=47863b264b3dea236944334fe7692aa8db9a7c88 Added post commit hooks --- diff --git a/lib/Oyster/Deploy/Git.pm b/lib/Oyster/Deploy/Git.pm index 37ff0a8..8298724 100644 --- a/lib/Oyster/Deploy/Git.pm +++ b/lib/Oyster/Deploy/Git.pm @@ -5,6 +5,8 @@ use Git::Wrapper; use Error::Simple; use Data::Dumper; +use File::Copy; +use File::ShareDir ':ALL'; sub create { my $self = shift; @@ -17,8 +19,16 @@ sub create { mkdir($location); my $git = Git::Wrapper->new($location); + + copy(dist_file( 'Oyster', './bin/git/post-receive'), ($git->dir . '.git/hooks/')) + or Error::Simple->throw('Creating post commit hooks failed.'); + copy(dist_file( 'Oyster', './bin/git/post-update'), ($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')); + return 1; } -1; \ No newline at end of file +1; diff --git a/t/Deploy/git.t b/t/Deploy/git.t index 5ba2614..205665c 100644 --- a/t/Deploy/git.t +++ b/t/Deploy/git.t @@ -20,3 +20,5 @@ is($deploy->create("${tmpdir}/testapp"), 1, 'Create returned okay'); ok((-d "${tmpdir}/testapp"), "App directory created"); throws_ok(sub {$deploy->create("${tmpdir}/testapp")}, 'Error::Simple', "Directory already exists"); +ok((-f "${tmpdir}/testapp/.git/hooks/post-receive"), "Post reveive hook exists"); +ok((-f "${tmpdir}/testapp/.git/hooks/post-update"), "Post update hook exists"); \ No newline at end of file