Skip to content

Instantly share code, notes, and snippets.

@mleko
Created July 16, 2018 13:31
Show Gist options
  • Save mleko/53f6db665a214492157f819f63b2891d to your computer and use it in GitHub Desktop.
Save mleko/53f6db665a214492157f819f63b2891d to your computer and use it in GitHub Desktop.
Include feature branch name in commit message
#!/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