ADD: added command to add post commit hook
AGIM-f284da79: #closed
This commit is contained in:
parent
aefed27597
commit
e475f7d8fb
35
lib/App/Git/IssueManager/AddHook.pm
Normal file
35
lib/App/Git/IssueManager/AddHook.pm
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package App::Git::IssueManager::AddHook;
|
||||||
|
#ABSTRACT: class implementing the Add-Hook command of the GIT IssueManager
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use MooseX::App::Command;
|
||||||
|
extends qw(App::Git::IssueManager);
|
||||||
|
use Git::LowLevel;
|
||||||
|
use Git::IssueManager;
|
||||||
|
use Git::IssueManager::Issue;
|
||||||
|
|
||||||
|
use Term::ANSIColor;
|
||||||
|
use Try::Tiny;
|
||||||
|
|
||||||
|
|
||||||
|
command_short_description 'add the post-commit hook for managing git issues to the repository';
|
||||||
|
command_usage 'git issue add-hook';
|
||||||
|
|
||||||
|
sub run
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
die("No .git directory found\n") unless -d ".git";
|
||||||
|
die("A post-commit hook is already installed. Please add hook manually\n") unless ! -e ".git/hooks/post-commit";
|
||||||
|
|
||||||
|
open my $hook,">",".git/hooks/post-commit";
|
||||||
|
print $hook "#!/bin/sh\n";
|
||||||
|
print $hook "git-issue-commit-hook\n";
|
||||||
|
close $hook;
|
||||||
|
|
||||||
|
system("chmod a+x .git/hooks/post-commit");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
Loading…
Reference in New Issue
Block a user