Created
July 16, 2018 13:31
-
-
Save mleko/53f6db665a214492157f819f63b2891d to your computer and use it in GitHub Desktop.
Include feature branch name in commit message
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 | |
$commitMsgFile = $argv[1]; | |
$commitMsg = file_get_contents($commitMsgFile); | |
if(!\in_array(substr($commitMsg, 0, 1), ["\n", "\r"], true)) { | |
return; | |
} | |
$pattern = "@On branch feature/(?P<feature>\w+-\d+)@"; | |
if(preg_match($pattern, $commitMsg, $matches)) { | |
file_put_contents($commitMsgFile, "#[".strtoupper($matches["feature"])."]"."\n".$commitMsg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment