Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add git post-commit hook to close tickets

Closes: 1b64e082-8dcd-11de-8211-a5bbe4e640b7
  • Loading branch information...
commit 4f04016383d1d36a54757bf2be5dbfa2807f2234 1 parent 2b57ba3
@spang spang authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 contrib/git-post-commit-close-ticket
View
17 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);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.