My hooks for Captain Hook.
Install with Composer:
composer require --dev xwillq/captains-hooks
Runs code formatter before commit, only formats changes that were staged and applies fixes to working tree. Uses Laravel Pint by default.
Can be used only as pre-commit
hook. Configuration:
{
"action": "\\Xwillq\\Hooks\\Hooks\\FormatPHPFilesInCommit",
"options": {
// Exclude files from formatting.
"excluded-files": [
// Specify file path.
"src/FormatPHPFilesInCommit.php",
// Patterns starting with / are treated as a regex.
"/tests\/.*/",
// Glob pattern.
"config/*"
],
// Command to execute. Placeholder `{}` gets replaced with path to file.
// `vendor/bin/pint {}` is the default value.
"formatter": "vendor/bin/pint {}"
}
}
When merging, PHPStorm adds list of conflicts to commit message body as comments. This hook removes them.
Can be used only as prepare-commit-msg
hook. Configuration:
{
"action": "\\Xwillq\\Hooks\\Hooks\\FixPHPStormMergeMessage"
}
Removes comments from commit message. Can be used to sanitize message before validation.
Can be used as pre-commit
, prepare-commit-msg
and commit-msg
hook.
Configuration:
{
"action": "\\Xwillq\\Hooks\\Hooks\\RemoveCommentsFromCommitMessage"
}