Too much Whitespace
[p5sagit/Oyster.git] / lib / Oyster / Deploy / Git.pm
CommitLineData
40056462 1package Oyster::Deploy::Git;
2
3use Moose;
4use Git::Wrapper;
5use Error::Simple;
6
7use Data::Dumper;
47863b26 8use File::Copy;
9use File::ShareDir ':ALL';
40056462 10
11sub create {
12 my $self = shift;
13 my $location = shift;
c0ce95cc 14
40056462 15 if( -f $location || -d $location ) {
16 Error::Simple->throw("$location already exists");
17 }
c0ce95cc 18
40056462 19 mkdir($location);
20 my $git = Git::Wrapper->new($location);
6b832bd6 21 $git->init();
c0ce95cc 22
6b832bd6 23 my ($postreceive, $postupdate);
c0ce95cc 24
6b832bd6 25 eval {
26 $postreceive = dist_file( 'Oyster', './deploy/git/post-receive');
27 $postupdate = dist_file( 'Oyster', './deploy/git/post-update');
28 };
29 #Beware there be deamons here
30 if ($@) {
31 $postreceive = './share/deploy/git/post-receive';
32 $postupdate = './share/deploy/git/post-update';
33 }
34
35
36 copy($postreceive, ($git->dir . '/.git/hooks/'))
47863b26 37 or Error::Simple->throw('Creating post commit hooks failed.');
c0ce95cc 38
6b832bd6 39 copy($postupdate, ($git->dir . '/.git/hooks/'))
47863b26 40 or Error::Simple->throw('Creating post commit hooks failed.');
c0ce95cc 41
6b832bd6 42 chmod(0x755, ($git->dir . '.git/hooks/post-receive', $git->dir . '.git/hooks/post-update'));
c0ce95cc 43
40056462 44 return 1;
45}
46
47
47863b26 481;