webgriffe/captainhook

Provides some useful custom actions to be used with Captain Hook (a PHP GIT hooks library)

2.1.0 2021-09-28 08:35 UTC

README

A collection of useful conditions and actions to be used with CaptainHook.

Build Status

Install

Given that you already have CaptainHook in your project you can simply use Composer to have these webgriffe/captainhook actions available:

composer require --dev webgriffe/captainhook

Actions

Here follows the list of implemented actions.

1. Prevent forced push on protected branches

For example, you can prevent forced push on master branch with the following CaptainHook's config:

    // captainhook.json
    // ...
    "pre-push": {
        "enabled": true,
        "actions": [
            {
                "action": "\\Webgriffe\\CaptainHook\\PreventPushForce",
                "options": {"protected-branches": ["master"]}
            }
        ]
    }
    // ...

You can use the protected-branches option to add other branches to the protected branches list.

2. Prevent commit if the diff is included in the message

    // captainhook.json
    // ...
    "commit-msg": {
        "enabled": true,
        "actions": [
            {
                "action": "\\Webgriffe\\CaptainHook\\PreventCommitMessageWithDiff"
            }
        ]
    },
    // ...

3. Prevent commit if some files have the same name but different case

    // captainhook.json
    // ...
    "commit-msg": {
        "enabled": true,
        "actions": [
            {
                "action": "\\Webgriffe\\CaptainHook\\PreventCommitCaseSensitiveSameFilename"
            }
        ]
    },
    // ...

License

This library is under the MIT license. See the complete license in the LICENSE file.

Credits

Developed by Webgriffe®.