xwillq/captains-hooks

Additional hooks for CaptainHook

1.1.0 2022-09-04 17:19 UTC

This package is auto-updated.

Last update: 2024-05-04 21:07:53 UTC


README

My hooks for Captain Hook.

Installation

Install with Composer:

composer require --dev xwillq/captains-hooks

Available hooks

FormatPHPFilesInCommit

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 {}"
    }
}

FixPHPStormMergeMessage

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"
}

RemoveCommentsFromCommitMessage

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"
}