[Bps-public-commit] SD branch, master, updated. 4f04016383d1d36a54757bf2be5dbfa2807f2234

spang at bestpractical.com spang at bestpractical.com
Thu Aug 20 18:10:56 EDT 2009


The branch, master has been updated
       via  4f04016383d1d36a54757bf2be5dbfa2807f2234 (commit)
      from  2b57ba33170e8356a51d68f042c6f26872636516 (commit)

Summary of changes:
 contrib/git-post-commit-close-ticket |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
 create mode 100755 contrib/git-post-commit-close-ticket

- Log -----------------------------------------------------------------
commit 4f04016383d1d36a54757bf2be5dbfa2807f2234
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Aug 20 23:09:20 2009 +0100

    Add git post-commit hook to close tickets
    
    Closes: 1b64e082-8dcd-11de-8211-a5bbe4e640b7

diff --git a/contrib/git-post-commit-close-ticket b/contrib/git-post-commit-close-ticket
new file mode 100755
index 0000000..28922bc
--- /dev/null
+++ b/contrib/git-post-commit-close-ticket
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+# Close sd tickets from git commit messages
+# To use, copy or symlink into .git/hooks with the name 'post-commit'
+
+my $UUID_REGEX = qr'(?:[0-9a-fA-F\-]{32,36}|[A-Za-z0-9\-\_]{22})';
+
+open( my $gitpipe, "git log -1 HEAD |" );
+my $commit_msg = do { local $/ = <$gitpipe> };
+my ($git_commit_sha1) = ($commit_msg =~ /^commit (.*)$/m);
+
+if ( $commit_msg =~ /Closes(?::)?\s+($UUID_REGEX)/i ) {
+    system( qw(git sd ticket comment), $1,
+        '-m', "Closed by git commit $git_commit_sha1" );
+    system( qw(git sd ticket close), $1);
+}

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list