Created
September 18, 2018 06:35
-
-
Save BastienClement/7c69fc78ead6abc45058f3815e2bcbcb to your computer and use it in GitHub Desktop.
Git ticket ref hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$REF_PATTERN = "[A-Z]{3,}-\\d+"; | |
$branch = exec("git rev-parse --abbrev-ref HEAD"); | |
if (preg_match("/(bug|feature)\\/($REF_PATTERN)/", $branch, $matches)) { | |
$msg = file_get_contents($argv[1]); | |
$ticket = $matches[2]; | |
if (!preg_match("/\\[.*?$REF_PATTERN.*?\\]/", $msg)) { | |
file_put_contents($argv[1], "\n\nTicket: [$ticket]\n", FILE_APPEND); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment