ADD: added post-commit hook for managing issues
This commit is contained in:
parent
f8512006c8
commit
6b4192dd74
42
bin/git-issue-commit-hook
Executable file
42
bin/git-issue-commit-hook
Executable file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Try::Tiny;
|
||||
use Git::IssueManager;
|
||||
use Git::LowLevel;
|
||||
use utf8;
|
||||
|
||||
#
|
||||
# main program
|
||||
#
|
||||
|
||||
my $manager = Git::IssueManager->new(repository=>Git::LowLevel->new(git_dir=> "."));
|
||||
|
||||
warn("IssueManager not yet initialize ignoring commit\n") unless $manager->ready();
|
||||
exit(0) unless $manager->ready();
|
||||
|
||||
my $tag = $manager->tag();
|
||||
|
||||
my $help=readpipe("git log -1 HEAD");
|
||||
my @lines=split /\n/, $help;
|
||||
|
||||
my $commit="";
|
||||
for my $line (@lines)
|
||||
{
|
||||
#check for commit
|
||||
if ($line =~ /^commit\s([0-9abcdef]+)$/)
|
||||
{
|
||||
$commit=$1;
|
||||
}
|
||||
|
||||
#search for an issue tag within the commit message
|
||||
if ($line =~ /($tag-[0-9abcdef]{8})/)
|
||||
{
|
||||
my $id=$1;
|
||||
# check for all possible commit issue commands
|
||||
if ($line =~ /#close/)
|
||||
{
|
||||
$manager->close($id, $commit);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user